[Perf][DSv4.1] Fold the mHC post block into the delayed pre projection (#56633)

Signed-off-by: Yongye Zhu <zyy1102000@gmail.com>
This commit is contained in:
Yongye Zhu
2026-09-14 18:57:37 +00:00
committed by GitHub
parent 56ca9904ce
commit 5372e72a98
8 changed files with 838 additions and 93 deletions
+5 -2
View File
@@ -491,7 +491,9 @@ def _check_dummy_hash_model_forward(
state.forward = lambda *args: ids.unsqueeze(1)
class Decoder(SimpleNamespace):
def __call__(self, hidden, positions, input_ids, *args):
# Engram hashes and the mask stay the last positional arguments;
# **kwargs absorbs the decoder's keyword-only flags.
def __call__(self, hidden, positions, input_ids, *args, **kwargs):
hashes, keep = args[-2:]
if dp_shared_memory and dp_rank == 1:
assert hashes is None and keep is None
@@ -504,7 +506,8 @@ def _check_dummy_hash_model_forward(
if dp_rank == 1:
assert torch.all(hashes == engram_ops.DEAD_ID)
output = engram.embed(hashes[:, 0])
return output, None, None, None, None
# Trailing None is previous_aux; this stub captures no aux states.
return output, None, None, None, None, None
model = SimpleNamespace(
use_mega_moe=False,