nemo_automodel.components.models.deepseek_v41.engram
nemo_automodel.components.models.deepseek_v41.engram
DeepSeek-V4.1 compressed-token Engram hashes and residual memory lookup.
The tokenizer normalization, per-layer hash seeds, and signed square-root gate
follow DeepSeek’s released inference/engram.py and inference/model.py.
V4.1 omits the short convolution used by earlier Engram architectures.
Module Contents
Classes
Functions
API
Bases: Module
Read a row-owner-sharded Engram table and update all HC residual streams.
Parameters:
Text configuration containing logical table sizes and HC width.
Zero-based decoder layer ID, present in engram_layer_ids.
Linear backend for the fused key/value projection.
Runtime row-owner group. None creates the complete table and is appropriate only when the configuration fits on one device.
Inject the normalized, signed-square-root-gated memory residual.
Parameters:
Tensor of shape [batch, sequence, hc_mult, hidden].
Integer tensor of shape [batch, sequence, hash_heads] containing logical table rows for this Engram layer. Under CP both inputs contain only this rank’s local sequence positions.
Optional bool tensor of shape [batch, sequence], with False for image/padding positions that must remain unchanged.
Returns: torch.Tensor
Tensor of shape [batch, sequence, hc_mult, hidden] in the input
Initialize the table, projection, and learned branch normalization weights.
Bases: Module
Build all Engram layers’ hashes from complete, uncached input sequences.
Parameters:
Text configuration containing the released Engram dimensions.
Fast tokenizer whose normalized vocabulary must have exactly
config.engram_compressed_vocab_size entries.
Hash unpacked sequences without crossing image or padding boundaries.
Parameters:
Integer tensor of shape [batch, sequence] containing raw tokenizer IDs for complete, unpacked sequences.
Optional boolean tensor of shape [batch, sequence]. False marks image or padding tokens and blocks all lookback through those positions. The caller also masks their residual gate.
Returns: torch.Tensor
Integer tensor of shape [batch, sequence, engram_layers, hash_heads],
Restore derived integer buffers after meta-device materialization.
Normalize decoded vocabulary entries using the released token-ID contract.
Find the first unused prime above start without an optional dependency.