mixle.engines.qlut module¶
Quantized function lookup tables – every scalar nonlinearity becomes table[code].
The corollary of quantization: once an operand is the integer code round(x/step), any scalar
function f is a precomputed table indexed by that code – no transcendental ever runs. This turns the
nonlinear ops of a model (activations: sigmoid/tanh/GELU/SiLU/softplus; the exp/log that convert between
the log (LNS) and linear domains; the Gaussian-log of mixle.engines.lns) into integer gathers.
Combined with integer-add products and the integer logsumexp, a fully-quantized forward pass has
no floating-point exp/log at all.
Nearest-code lookup has error <= (step/2) * sup|f'| on the tabulated range (e.g. sigmoid: 0.125*step).
Unbounded functions (GELU, softplus, ReLU) extrapolate linearly beyond the range using the boundary slope,
so the table need only cover the curved region. Measured 1.5-8x faster than the real transcendental.
- class QuantizedFunction(func, step, lo, hi)[source]
Bases:
objectA scalar function tabulated over quantized inputs;
f(x) ≈ table[round(x/step)]with linear tails.- lookup(code)[source]
Gather directly from integer codes already in the quantized domain (the pure-integer path).
- quantized_activation(name, step=0.01, span=20.0)[source]
A common NN activation as a quantized LUT (
sigmoid/tanh/gelu/silu/softplus/relu).
- quantized_exp(log_step=0.01, lo_log=-30.0)[source]
expfrom an LNS log-code (units oflog_step) back to the linear domain – a pure table gather.Call with integer log-codes via
QuantizedFunction.lookup(); this is the softmax/attention “back to linear” step, with no realexp.
- error_bound(sup_abs_derivative, step)[source]
The nearest-code lookup error bound
(step/2) * sup|f'|(e.g. sigmoid sup|f’|=0.25).
- table_bytes(step, lo, hi, itemsize=8)[source]
Bytes a table spanning
[lo, hi]atstepoccupies (cache-residency check).