Skip to content
class

DeQuantStub

extendsModule
DeQuantStub(qconfig: object = None)

Quantized→float boundary marker — the exit stub of a quantizable model.

The exit-side counterpart of QuantStub: place it where the quantized region ends and ordinary float compute resumes. Like its entry-side twin it is a placeholder — an identity at float / calibration time whose only job is to give the tooling a named site — and lucid.quantization.convert swaps it for a runtime DeQuantize.

Under Lucid's sidecar representation (design B) activations are carried as (fake-quantized) float32 throughout the quantized region rather than as packed integer tensors, so "dequantizing" the exit is a no-op: there is no integer buffer to unpack back to float. The marker therefore never changes a tensor's values in either its stub or its converted form — it exists purely so the quantized graph is symmetric and walkable by tooling.

Parameters

qconfigobject= None
Quantization config attached to this boundary. When None (the default) no qconfig attribute is set and the module inherits the surrounding model's config during prepare / convert.

Notes

  • Holds no state and takes no runtime tensor arguments beyond the input.
  • Because activations stay float-carried, a model may omit DeQuantStub entirely and still produce correct numerics; it is kept for graph symmetry and to mark intent.
  • Converts to DeQuantize, which is likewise a pure identity — so a quantized region is bracketed by exactly one active boundary (Quantize on entry).

Examples

>>> import lucid, lucid.nn as nn
>>> dq = nn.quantized.DeQuantStub()
>>> x = lucid.randn(2, 3)
>>> bool((dq(x) == x).all().item())      # identity in every mode
True

See Also

Used by 1

Constructors

1
dunder

__init__

→None
__init__(qconfig: object = None)

Instance methods

1