Skip to content
class

NoopObserver

extendsPlaceholderObserver
NoopObserver(qscheme: QScheme = per_tensor_affine, qdtype: QDtype = quint8, eps: float = 1e-08)

A no-op PlaceholderObserver — pure identity, collects no statistics.

The intent-revealing name for a PlaceholderObserver: a tensor should flow through the observed graph without any statistic gathering at all. Whereas a bare PlaceholderObserver reads as "qparams come from elsewhere (dynamic quant)", NoopObserver reads as "this tensor is deliberately not quantized here" — an already-quantized input, a residual passed straight through, or a layer explicitly excluded from calibration. Behaviourally the two are identical: forward is the identity and calculate_qparams raises. Only the name (and the reader's intent) differs.

When to pick it. Use it to annotate a passthrough tensor in a QConfig / mapping so the tooling records the "leave alone" intent explicitly rather than by omission. When qparams really are produced at runtime, prefer PlaceholderObserver; when a fixed grid is known, use FixedQParamsObserver.

Like its parent it holds no statistic and its qparams query is an error:

forward(x)=x,calculate_qparams()  ⇒  raise RuntimeError\text{forward}(x) = x,\qquad \text{calculate\_qparams}() \;\Rightarrow\; \textbf{raise } \texttt{RuntimeError}

Parameters

qschemeQScheme= per_tensor_affine
Target quantization scheme recorded for downstream consumers (metadata only).
qdtypeQDtype= quint8
Target quantized dtype recorded for downstream consumers (metadata only).
epsfloat= 1e-8
Retained for interface symmetry; unused (no range is derived).

Notes

  • Pure alias. Inherits the qscheme / qdtype / eps constructor and all behaviour of PlaceholderObserver unchanged; it overrides nothing.
  • Identity forward, raising qparams — same contract as the parent; the class exists to make "no observation" a first-class, greppable choice.
  • No buffers, so nothing is added to the state_dict beyond the metadata.

Examples

>>> import lucid
>>> import lucid.quantization as Q
>>> obs = Q.NoopObserver()
>>> x = lucid.randn(2, 3)
>>> bool((obs(x) == x).all().item())         # identity passthrough
True
>>> isinstance(obs, Q.PlaceholderObserver)   # it *is* a PlaceholderObserver
True

See Also

Used by 1