loopyt 32d3d2c6bf docs(h20): plan the FlagGems integration, with the first operator already proven
Opens `h20-sm90-flaggems` to replace `tile_kernels`'s torch reference with FlagGems' Triton kernels.
The point is not "runs without TileLang" -- that landed already. It is speed: the compat layer is
plain torch today, so every activation in the hot path is going through eager PyTorch.

Wrote the plan down because the tempting framing is wrong. `tile_kernels` and `flag_gems` are not
substitutes; they overlap in three layers and only the first is a clean fit:

* generic ops (quant, rotary, rms_norm, topk) -- FlagGems' home turf, 251 ops
* DeepSeek-specific fused ops (mhc_*, engram_*, the five-way swiglu+quant) -- partial overlap, and
  almost none of the signatures match 1:1
* the engine kernel backend (tilelang_ops) -- already done, unrelated

De-risked the highest-value one first, since per-token quantisation runs on every activation.
`ab_quant.py`, 5 shapes: `per_token_group_quant_fp8(scale_ue8m0=True, column_major_scales=True)`
against `per_token_cast(fmt="e4m3", 128, round_sf=True, use_packed_ue8m0=False,
use_tma_aligned_col_major_sf=True)` -- **quantised values bitwise identical, scales and dequantised
values exactly zero difference**. The two `round_sf` spellings are the same function: DeepInfer does
`(int + 0x7FFFFF) & 0x7F800000`, which carries into the exponent field, i.e. ceiling to a power of
two; FlagGems does `exp2(ceil(log2(s)))`. Same function, so the test demands exactness rather than
tolerance and reports any difference.

`ab_import_side_effects.py` pins the mechanism that makes this safe: import is inert,
`only_enable(include=[...])` touches exactly what it names. Recorded also that the package root
pulls Triton TLE -> libflagcx, so selective imports or vendoring stay the default posture rather
than reaching for `enable()`.

Two questions the plan puts ahead of the work, because without answers the payoff is unknowable:
nothing on this line has ever been measured for speed, and `batched_transpose_weight_sf` is still
the only path operator never A/B'd -- it rewrites every weight's scale factor and is the leading
suspect for the token divergence. Fixing that could be worth more than any op swap here.

Also names what is deliberately off the table: `enable()` with no arguments, swapping tilelang_ops
again, and churning broadcast-only micro-ops that were never the bottleneck.
2026-10-25 14:38:14 +08:00
..
flaggems_port docs(h20): plan the FlagGems integration, with the first operator already proven 2026-10-25 14:38:14 +08:00
simulate_no_tilelang feat(h20): make the pure-torch kernel references usable without TileLang 2026-10-22 16:08:46 +08:00
sparse_mla_port docs: correct what importing flag_gems actually does 2026-10-25 14:37:59 +08:00
tile_kernels_patch fix(h20): let the reference backend sync, and stop the reference raising under the guard 2026-10-24 19:10:49 +08:00
ab_cases.py test(h20): catch a factory that returns nothing before eight ranks do 2026-10-22 14:16:41 +08:00
build_vendor.sh initial commit 2026-10-20 12:09:42 +08:00
build.sh initial commit 2026-10-20 12:09:42 +08:00
compare_layers.py fix(sm90): expand expert scales on the contraction axis only 2026-10-21 16:50:31 +08:00
copy_site_packages.py feat(h20): make the FlagTree image setup reproducible instead of a shell history 2026-10-22 13:20:03 +08:00
enable_torch_kernel_refs.sh feat(h20): make the pure-torch kernel references usable without TileLang 2026-10-22 16:08:46 +08:00
flagtree_triton_probe.py docs(h20): record what a FlagTree/FlagOS image can and cannot do 2026-10-22 10:53:47 +08:00
format_csrc.sh initial commit 2026-10-20 12:09:42 +08:00
gen_stub.sh initial commit 2026-10-20 12:09:42 +08:00
h20_ask.py style(sm90): satisfy ruff and add the missing type annotations 2026-10-21 17:09:08 +08:00
h20_attn_check.py style(sm90): satisfy ruff and add the missing type annotations 2026-10-21 17:09:08 +08:00
h20_e2e_report.sh docs(h20): point at the setup script, and let the report script carry its own defaults 2026-10-22 13:20:08 +08:00
h20_engram_check.py style(sm90): satisfy ruff and add the missing type annotations 2026-10-21 17:09:08 +08:00
h20_expert_weight_check.py style(sm90): satisfy ruff and add the missing type annotations 2026-10-21 17:09:08 +08:00
h20_index_decode_check.py test(sm90): rule out the KV cache and the decode indexer 2026-10-21 20:02:19 +08:00
h20_kv_roundtrip.py test(sm90): rule out the KV cache and the decode indexer 2026-10-21 20:02:19 +08:00
h20_ops_ab.py test(h20): catch a factory that returns nothing before eight ranks do 2026-10-22 14:16:41 +08:00
h20_philox_check.py feat(triton): reproduce cuRAND's Philox stream, so the sampler can be ported 2026-10-22 08:37:08 +08:00
h20_quant_check.py test(sm90): decode FP4 by table lookup in the quant check 2026-10-21 17:15:16 +08:00
h20_real_requant_check.py style(sm90): satisfy ruff and add the missing type annotations 2026-10-21 17:09:08 +08:00
h20_recipe_probe.py debug: capture final logits, and keep the profile forward out of the dumps 2026-10-21 17:44:21 +08:00
h20_rng_dump.py feat(triton): reproduce cuRAND's Philox stream, so the sampler can be ported 2026-10-22 08:37:08 +08:00
h20_smoke_check.py style(sm90): satisfy ruff and add the missing type annotations 2026-10-21 17:09:08 +08:00
h20_state_check.py test(h20): check what the model actually says, in a file rather than on the command line 2026-10-22 10:53:01 +08:00
h20_topk_check.py style(sm90): satisfy ruff and add the missing type annotations 2026-10-21 17:09:08 +08:00
ref_layer_dump.py debug: capture final logits, and keep the profile forward out of the dumps 2026-10-21 17:44:21 +08:00
ref_next_token.py debug: per-step decode dumps, and prove the flip is decode-only 2026-10-21 19:07:49 +08:00
setup_flagtree_image.sh feat(h20): make the FlagTree image setup reproducible instead of a shell history 2026-10-22 13:20:03 +08:00
verify_tile_kernels_patch.py feat(h20): make the pure-torch kernel references usable without TileLang 2026-10-22 16:08:46 +08:00