int8-weight LSTM built from a float lucid.nn.LSTM.
A dynamically quantized recurrent layer: every recurrent weight matrix
(weight_ih_l* / weight_hh_l*) is stored int8 (per-row symmetric) while
the biases stay float. A float nn.LSTM shell, held outside the module
registry so its float weights never enter the state_dict, is the actual
compute engine — on each forward its weights are overwritten with the values
dequantized from the int8 buffers, so only the int8 form is the persistent,
device-tracked state. No calibration is required; the per-timestep activation
quantization inside the cell is left to the real low-precision kernel. Build
instances with lucid.quantization.quantize_dynamic, the recommended
path for LSTM-heavy inference.
Parameters
shelllucid.nn.LSTMfrom_float quantizes to int8.Notes
The shell is stored via object.__setattr__ so it stays out of the module
registry, keeping the serialized state limited to the int8 weight buffers, the
per-row scales, and the float biases.
Used by 1
Class methods
1Instance methods
2Override to add extra repr info (e.g. Linear shows in_features, etc.).
forward(input: Tensor | PackedSequence, hx: tuple[Tensor, Tensor] | None = None)Inject dequantized weights into the shell and run it.
Packed input passes straight through — the shell is a real
lucid.nn.LSTM, so it handles it.