Expand description
PLE n-gram row ids: EOS-aware right-shift plus the multiply-XOR hash.
Pure token-id arithmetic — no device, no weights — which is why it is
tested bit-exactly against the reference in tests.rs and runs in CI.
This does NOT transfer from LongCat (#746). LongCat accumulates a
polynomial rolling hash (acc += shift[d] * m[d], then % rows). Qwen
multiplies each shifted token by a SplitMix64-derived odd multiplier and
XORs them, then takes a per-head prime modulus and adds a per-head
offset into one 320M-row table. The two produce different rows from the
same tokens, and both produce VALID rows — so a mix-up is silent.
Reference: Qwen4ExpTextNGramEmbedding.forward /
_shift_right_ignore_eos, bench/qwen4_exp/ref/modeling_qwen4_exp.py.
Structs§
- PleId
Dims - Geometry for one PLE site, read from the checkpoint rather than derived.
Functions§
- ple_
ngram_ ids - Row ids for every head, one row per token in
tokens.