vllm.models.hy_v4_flash.common.engram_ops
¶
Fused Triton kernels for the HY V4 Flash Engram layer.
Functions:
-
gated_update–Apply the gated Engram update to the hyper-connection streams.
-
lookup_norm–Gather, dequantize and RMS-normalize Engram table rows per head.
-
ngram_hashes–Write the global Engram buckets of the n-grams ending at each token.
gated_update(hidden, proj, hashes, key_norm, query_norm, pre_gamma, hc_scales)
¶
Apply the gated Engram update to the hyper-connection streams.
Parameters:
-
(hidden¶Tensor) –[T, hc, dim]streams. -
(proj¶Tensor) –[T, (hc + 1) * dim]reduced key projections followed by the value projection. -
(hashes¶Tensor) –[T, n_hash_cols]; tokens whose hashes are all negative pass through unchanged. -
(key_norm¶Tensor) –[hc, dim]key RMSNorm weights. -
(query_norm¶Tensor) –[hc, dim]query RMSNorm weights. -
(pre_gamma¶Tensor) –[dim]value RMSNorm weight. -
(hc_scales¶Tensor) –[hc, dim]per-stream update scales.
Returns:
-
Tensor–[T, hc, dim]updated streams.
Source code in vllm/models/hy_v4_flash/common/engram_ops.py
lookup_norm(table, scales, hashes, vocab_start, vocab_end, gamma, dtype)
¶
Gather, dequantize and RMS-normalize Engram table rows per head.
Parameters:
-
(table¶Tensor) –[vocab_end - vocab_start, dim]local table rows (FP8 or BF16), possibly a CUDA view of pinned host memory. -
(scales¶Tensor | None) –[vocab_end - vocab_start]FP8 row scales, or None for BF16 tables. -
(hashes¶Tensor) –[T, heads]global buckets; a bucket outside[vocab_start, vocab_end), including a negative one, zeroes its head. -
(vocab_start¶int) –First global bucket of
table. -
(vocab_end¶int) –End of the global buckets of
table. -
(gamma¶Tensor) –[heads, dim]per-head norm weights. -
(dtype¶dtype) –output dtype.
Returns:
-
Tensor–[T, heads * dim]normalized rows.
Source code in vllm/models/hy_v4_flash/common/engram_ops.py
ngram_hashes(input_ids, lookback, starts, seq_lens, num_live, token_map, multipliers, primes, offsets, pad_id, skip_ids, out)
¶
Write the global Engram buckets of the n-grams ending at each token.
Parameters:
-
(input_ids¶Tensor) –[T]token ids of the batch. -
(lookback¶Tensor) –[requests, depth]ids preceding each request's chunk, nearest first; negative ids are unknown. -
(starts¶Tensor) –[requests + 1]query start offsets. -
(seq_lens¶Tensor) –[requests]sequence lengths including the chunk. -
(num_live¶int) –Rows at or past this count are padding.
-
(token_map¶Tensor) –[vocab]compressed id of each token. -
(multipliers¶Tensor) –[layers, max_ngram]per-layer hash multipliers. -
(primes¶Tensor) –[layers, columns]bucket count of each hash column. -
(offsets¶Tensor) –[layers, columns]first global bucket of each column. -
(pad_id¶int) –Compressed id standing in for missing history.
-
(skip_ids¶tuple[int, ...]) –Up to three token ids (pad and visual tokens) whose rows get no buckets.
-
(out¶Tensor) –[layers, T, columns]INT32 buckets; skipped rows are -1.