Skip to content
module

quantized

27 members
lucid.nn.quantized

lucid.nn.quantized — quantized inference modules.

The int8-weight counterparts of the float lucid.nn layers, produced by lucid.quantization.convert from a calibrated model. Under the sidecar representation (design B) they store int8 weights + scale / zero_point buffers and compute in float (dequantize → op → fake-quantize). QuantizedLinearMLX is the exception and runs the engine's own low-precision GEMM instead; the two agree to 5e-07, which is what makes the float path a usable reference for it.

Also holds the boundary markers QuantStub / DeQuantStub placed in a float model and their runtime forms Quantize / DeQuantize.

Sub-packages

Classes

classELU2 methods

Quantized lucid.nn.ELU — elu(x, alpha) then output fake-quant.

classHardsigmoid2 methods

Quantized lucid.nn.Hardsigmoid — hardsigmoid(x) then fake-quant.

classHardswish2 methods

Quantized lucid.nn.Hardswish — hardswish(x) then output fake-quant.

classLeakyReLU2 methods

Quantized lucid.nn.LeakyReLU — leaky_relu(x, slope) then fake-quant.

classSigmoid2 methods

Quantized lucid.nn.Sigmoid — sigmoid(x) then output fake-quant.

classTanh2 methods

Quantized lucid.nn.Tanh — tanh(x) then output fake-quant.

classConv1d3 methods

Quantized 1-D convolution — int8 kernel, dequantize-to-float compute.

classConv2d3 methods

Quantized 2-D convolution — int8 kernel, dequantize-to-float compute.

classConv3d3 methods

Quantized 3-D convolution — int8 kernel, dequantize-to-float compute.

classConvTranspose1d3 methods

Quantized 1-D transposed (fractionally-strided) convolution.

classConvTranspose2d3 methods

Quantized 2-D transposed (fractionally-strided) convolution.

classConvTranspose3d3 methods

Quantized 3-D transposed (fractionally-strided) convolution.

classFloatFunctional6 methods

Float-domain quantizable merge ops whose output prepare observes.

classQFunctional7 methods

Quantized element-wise merges — each result fake-quantized to one grid.

classConvReLU1d1 methods

Quantized 1-D convolution with a fused ReLU — int8 kernel, float compute.

classConvReLU2d1 methods

Quantized 2-D convolution with a fused ReLU — int8 kernel, float compute.

classConvReLU3d1 methods

Quantized 3-D convolution with a fused ReLU — int8 kernel, float compute.

classLinearReLU1 methods

Quantized linear layer with a fused ReLU — int8 weight, float compute.

classLinear4 methods

Quantized linear (fully-connected) layer — int8 weight, float compute.

classQuantizedLinearMLX4 methods

Weight-only int4/int8 linear backed by a real Metal low-precision GEMM.

classDeQuantize2 methods

Runtime exit from the quantized region — identity under design B.

classDeQuantStub2 methods

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

classQuantize2 methods

Runtime entry into the quantized region — fake-quantizes the input.

classQuantStub2 methods

Float→quantized boundary marker — the entry stub of a quantizable model.

classQuantWrapper2 methods

Wrap an arbitrary float model with QuantStub / DeQuantStub.

classEmbedding4 methods

Quantized embedding lookup table — per-row int8, dequantize-on-lookup.

classEmbeddingBag4 methods

Quantized EmbeddingBag — per-row int8 table, pooled dequant lookup.