loopyt ec5f37821d fix(h20): let the reference backend sync, and stop the reference raising under the guard
Running end to end surfaced two things the per-kernel A/B could not.

The engine wraps the forward pass in `forbid_cuda_sync()`, which sets torch's sync debug mode to
"error". The compiled kernels never sync; the torch references do, and not by oversight:

* `tile_kernels/torch/cast.py` built `torch.tensor(-1.0, device="cuda")` (and three more like it)
  for use as a `torch.where` operand. Constructing a device tensor from a Python scalar is a
  host-to-device copy, so it syncs -- and it is unnecessary, because `torch.where` accepts a plain
  scalar and passes it to the kernel. Patched via `patch_torch_ref_sync.py` (idempotent,
  reversible), which is a fix worth having on its own: the same cast raises for any caller that
  holds the device clean.
* `get_mapping_from_psum` reads the expert prefix-sum to the host to compute alignment ranges in
  Python, and `moe_topk_gate_forward` compacts rows with `nonzero()` and branches on `.any()`.
  Those cannot be made sync-free without rewriting how the reference addresses, which is the wrong
  trade for a fallback whose job is being runnable. So each compat module wraps its reference
  module once and every call through it runs inside `allow_cuda_sync()`.

Not done, deliberately: `set_sync_debug_mode("default")` process-wide. That would also stop the
guard catching accidental syncs in the compiled path, which is what it is for.

Also fixed: my own `bool(force_random.any())` in the gate adapter was itself a sync, outside the
reference, so it raised before the adapter could decide anything.

End to end now completes: exit=0, all 8 DP ranks agree, coherent answers. It is not token-identical
to the compiled path -- 16/16 samples differ, with a control run confirming the harness is
deterministic (two cuda runs are bit-identical), so the difference is real. Recorded in the doc as
the next thing to attribute rather than papered over.
2026-10-24 19:10:49 +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 feat(h20): route tile_kernels calls through a compat layer, so the model runs without TileLang 2026-10-22 18:10:14 +08:00
hugging_face feat(h20): route tile_kernels calls through a compat layer, so the model runs without TileLang 2026-10-22 18:10:14 +08:00
model_executor feat(h20): route tile_kernels calls through a compat layer, so the model runs without TileLang 2026-10-22 18:10:14 +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
tk_compat fix(h20): let the reference backend sync, and stop the reference raising under the guard 2026-10-24 19:10:49 +08:00
ve initial commit 2026-10-20 12:09:42 +08:00
worker feat(h20): route tile_kernels calls through a compat layer, so the model runs without TileLang 2026-10-22 18:10:14 +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
debug_dump.py fix(debug): move debug_dump out of h20_ops so other platforms can import it 2026-10-21 22:37:49 +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