loopyt 3c15952e76 debug: add layer-wise dump + reference comparison for H20 bring-up
Narrows the SM90 numerical divergence to layer 0's FFN. The sparse MLA attention
kernel is not the problem: at layer 0 its output matches the reference with
cos=0.99897 / rel_err=4.7e-2, while the full layer output is already at 12.7% and the
error compounds to cos=0.865 by layer 11, which finally flips the top-1 token.

Tooling
- `h20_ops/debug_dump.py`: opt-in capture (`DEEPINFER_DUMP_LAYERS=<dir>`), last
  position only, reduced over `hc_mult`, written to `.npz` at exit.
  `DEEPINFER_DUMP_TOKENS=<n>` gates on the real prompt length, because the engine
  runs a dummy profile forward with a different token count before it allocates the
  KV cache and that dump would otherwise be mistaken for the real one.
- `scripts/ref_layer_dump.py`: the same anchors from the reference model via forward
  hooks (block output, attention sub-layer output, embedding), plus the final
  logits and greedy token.
- `scripts/compare_layers.py`: cosine similarity, relative L2 error and norm ratio
  per layer, reporting the first layer above a tolerance.

Two traps this had to fix before the numbers meant anything
- `decoder_layer` returns the *sub-layer* output; the residual stream lives in
  `residual` (`HCLazyPostData`, hc_mult=4). Comparing without merging them through
  `hc_post` produced a bogus cos of 0.02 at every layer.
- `DEEPINFER_DEBUG_NAN` and the dump both need a host copy inside the forward, so
  both take `allow_cuda_sync()` rather than fighting the engine's sync guard.

Also documents the reproduction case and the findings in H20-DEBUG-PLAN.md.
2026-10-21 16:16:53 +08:00
..
_C initial commit 2026-10-20 12:09:42 +08:00
distributed initial commit 2026-10-20 12:09:42 +08:00
engine initial commit 2026-10-20 12:09:42 +08:00
entrypoints initial commit 2026-10-20 12:09:42 +08:00
h20_ops debug: add layer-wise dump + reference comparison for H20 bring-up 2026-10-21 16:16:53 +08:00
hugging_face feat: add SM90 (Hopper) support for DeepSeek-V4.1 inference 2026-10-21 15:18:56 +08:00
model_executor debug: add layer-wise dump + reference comparison for H20 bring-up 2026-10-21 16:16:53 +08:00
npu_ops feat: add SM90 (Hopper) support for DeepSeek-V4.1 inference 2026-10-21 15:18:56 +08:00
structure_output initial commit 2026-10-20 12:09:42 +08:00
ve initial commit 2026-10-20 12:09:42 +08:00
worker feat: add SM90 (Hopper) support for DeepSeek-V4.1 inference 2026-10-21 15:18:56 +08:00
__init__.py initial commit 2026-10-20 12:09:42 +08:00
attrdict.py initial commit 2026-10-20 12:09:42 +08:00
config.py initial commit 2026-10-20 12:09:42 +08:00
environ.py initial commit 2026-10-20 12:09:42 +08:00
load_class.py initial commit 2026-10-20 12:09:42 +08:00
logger.py initial commit 2026-10-20 12:09:42 +08:00
model_config_loader.py initial commit 2026-10-20 12:09:42 +08:00
multimodal_tokens.py initial commit 2026-10-20 12:09:42 +08:00
platform.py feat: add SM90 (Hopper) support for DeepSeek-V4.1 inference 2026-10-21 15:18:56 +08:00
py.typed initial commit 2026-10-20 12:09:42 +08:00
sampling_params.py initial commit 2026-10-20 12:09:42 +08:00
sequence.py initial commit 2026-10-20 12:09:42 +08:00
shared_memory.py initial commit 2026-10-20 12:09:42 +08:00
testing.py initial commit 2026-10-20 12:09:42 +08:00
timer.py initial commit 2026-10-20 12:09:42 +08:00
utils.py initial commit 2026-10-20 12:09:42 +08:00