Skip to content

[WS1][CUDA][MiniMax-H3] ws1_full_h3_transformer and ws1_dual_trajectory: 33B forward/backward and rollout-vs-train control (RFC #420 stack 5/7) - #571

Merged
maxiaosong1124 merged 47 commits into
RL-Align:test-h3from
fusheng-ji:feat/h3-full-transformer
Nov 5, 2026
Merged

maxiaosong1124 merged 47 commits into
RL-Align:test-h3from
fusheng-ji:feat/h3-full-transformer

Conversation

@fusheng-ji

@fusheng-ji fusheng-ji commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RFC #420 stack 5/7 (base test-h3, merge bottom-up): #483 → #484 → #485 → #486 → #487 → #488 → #489 → #493 → #494 → #586 → #587 → #588 → {#567, #568} → {#569, #570 (on #568)} → #571 (on #570) → #574 → #575. This PR sits on #570; until the lower PRs merge, GitHub also shows their commits. This PR's own diff.

Evidence location: the measurement outputs of this PR (JSON, figures) are not part of its diff. They are on the fork's pr_assets branch under pending/h3-full-transformer/ (links in this description are fixed to that commit). Paths such as reports/experiments/... below name where a runner writes its output.

What

  • Full 33B forward/backward with strict boundary rows (audio_proj_in, audio_proj_out, context_embedder, token_refiner) bound to RL-Kernel and the provider boundaries
    (proj_in, proj_out, time_embedder, norm_out) kept explicit; full_model_execution(..., strict_boundaries=True) records which boundary used which binding.
    h3_full_transformer.py runs the provider twice (and the SDPA-efficient / cuBLASLt variants) and the candidate twice, with GPU-side checksum fingerprints.
  • Dual trajectory (h3_dual_trajectory.py): the same Euler sampler run single (rollout-style, one sample) and batched (train-style) and recorded as sealed trajectories;
    --strict-only and --diag-video-projections select the arms. This is the rollout-vs-train control.

Prior art & reuse decision

diffusers is the provider and the only reference for the full model; vLLM-Omni's rollout path and the training path are what the dual trajectory stands in for. Nothing offers a
per-step rollout-vs-train drift report, so the harness is new.

Results (H100 / Hopper)

Full 33B step time (forward + backward, gradient checkpointing, one H100) — strict graph binds h3_full_attention (#553) in CandidateOps when _H3_C is built; provider is diffusers/cuBLAS. Median of 3 repeats; torch 2.13.0+cu130, MiniMax-H3@42ed227, runner tools/validation/models/h3_full_speed.py, measured at head 4f7c5d11 (#575 stack, includes #571).

tokens provider total strict total total ratio provider fwd strict fwd fwd ratio strict peak GiB
12 0.312 s 1.3 s 4.03x 0.104 s 0.42 s 4.0x 62.9
925 0.438 s 5.0 s 11.33x 0.119 s 1.31 s 11.0x 63.0
4253 1.709 s 37.4 s 21.88x 0.438 s 9.10 s 20.8x 63.5
8349 3.625 s 126.4 s 34.88x 0.910 s 28.70 s 31.6x 65.0

Strict uses the bounded-workspace #553 attention kernel (not the interim quadratic DeterministicAttentionOp); 8349 tokens fit in ~65 GiB. This is still far above provider time (launch-bound strict path plus interim projection/GEMM rows in the stack); it does not meet the “R/R step time not worse than P/P” acceptance bar.

Measured on NVIDIA H100 (93 GiB, sm90), driver 580, CUDA 13.0, torch 2.13.0+cu130, pinned MiniMax-H3@42ed227 weights, at head 5ae9f5eb. Strict vs provider on the 33B forward/backward (tiny request): candidate bitwise repeatable True, provider repeatable True;
video output relative difference 2.07e-03, audio 1.77e-02, input-gradient relative differences 0.23, 0.23, 0.33 (BF16 provider vs FP32-accumulated candidate; gradients of a 33B network amplify rounding differences).

Rollout (single) vs train (batched) path, 4 Euler steps x 4 comparisons, three seeds:

Seed Provider: differing comparisons (first max abs) RL-Kernel strict Strict + video projections bound (diagnostic)
11 16/16 (first 0.47) 8/16 (first 3.8e-06) 0/16
22 16/16 (first 0.25) 8/16 (first 5.2e-06) 0/16
33 16/16 (first 0.54) 8/16 (first 3.8e-06) 0/16

full transformer and dual trajectory

Numbers: reports/experiments/h3-full-transformer-h100/.

Hopper pytest summary: tests.json (142 collected, 142 passed @ eb7840bb, H100 sm90).

Dual trajectory on Hopper (strict, no diagnostic binding): 8/16 comparisons differ on every seed; per-step max abs on video velocity stays ~1e-5–1e-6 through step 3 (e.g. seed 33 step 3 ≈ 5.7e-06, not the B200 spike). Provider single-vs-batched drift is large from step 0 and grows each step (seed 33 step 3 provider video-velocity max 2.578 (dual_trajectory_step_max.json)). With --diag-video-projections, strict is 0/16 bitwise equal on seeds 11/22/33 (*_diag.json). Summary: dual_trajectory_diag_summary.json.

RFC H-C2 (Hopper): full strict single-vs-batched bitwise match is not claimed until walker-ai video proj_in/proj_out rows are bound in production strict mode; the diagnostic arm shows layout drift is attributable to those rows.
The provider's two paths differ at every step (H100: max abs grows from ~0.545 (step 0) to ~2.578 (step 3) on seed 33 on seed 33; the table's "first" column is step-0 only). Strict first differs by 4e-6 to 5e-6, which comes from the video proj_in / proj_out rows (another contributor's, not bound here);
with them bound only as a diagnostic the two paths are bitwise equal at every step on all three seeds. The wall-time panel includes warm-up; steady-state step time is not claimed here.

Results (B200 / Blackwell) — supplementary, not Hopper acceptance

Measured on NVIDIA B200 (179 GiB, sm100), driver 580.126, CUDA 13.0, torch 2.13.0+cu130, pinned MiniMax-H3@42ed227 weights, clean tree at eb7840bb.

Tests: 141 passed, 1 failed (142 collected); the one failure is the token-refiner accuracy case inherited from #570 (test_nodes_accuracy_repeat_batch_and_isolated[1-257], swiglu node, 0.01211 against a bound of 0.01116; see #570). The bound was not changed. tests.json.

Strict vs provider on the 33B forward/backward (tiny request; the result does not depend on the seed, the three runs are identical): candidate bitwise repeatable True, provider repeatable True; video output relative difference 2.29e-03, audio 2.13e-02, input-gradient relative differences 0.20 (video hidden states), 0.19 (audio), 0.33 (encoder); 638 parameter gradients, relative difference median 0.20, maximum 0.55. Peak allocated 68.2 GiB. (full_transformer_seed11.json, seeds 22 and 33 alongside.)

Rollout (single) vs train (batched) path, 4 Euler steps x 4 comparisons. Cells are differing comparisons out of 16, with the largest absolute difference at steps 0 / 1 / 2 / 3 in brackets (0 = bitwise equal):

Seed Provider RL-Kernel strict Strict + video projections bound (diagnostic)
11 16/16 (3.3e-06 / 3.3e-06 / 4.3e-06 / 6.7e-06) 8/16 (3.8e-06 / 4.9e-06 / 4.1e-06 / 7.6e-06) 0/16
22 16/16 (3.8e-06 / 3.8e-01 / 6.9e-01 / 9.6e-01) 8/16 (3.1e-06 / 4.5e-06 / 3.9e-06 / 5.7e-06) 0/16
33 16/16 (3.1e-06 / 3.8e-06 / 8.6e-06 / 6.3e-06) 10/16 (4.8e-06 / 5.2e-06 / 5.4e-06 / 6.2e-01) 0/16

full transformer and dual trajectory on B200

Reading the table:

  • The provider's two paths differ at every step. Its drift is about 1e-6 in two seeds and jumps to 0.38 at step 1 in seed 22 (0.96 at step 3).
  • Strict is not bitwise equal between the layouts on B200 without the diagnostic binding (8, 8 and 10 of 16 comparisons differ). It stays at about 1e-6 for the first steps and, in seed 33, jumps to 0.62 at step 3. The first difference is at step 0 in all three seeds and comes from the video proj_in / proj_out rows, which are not bound here.
  • With those two rows bound as a diagnostic, strict is bitwise equal at every step on all three seeds, as on H100.
  • The wall-time panel includes warm-up and the provider run absorbs most of it; steady-state step time is not claimed.

Root cause (B200-focused) — observed vs step-3 probe

Observed (artifact-backed):

  • Unbound video proj_in / proj_out: strict layout drift ~1e-6 from step 0; --diag-video-projections → 0/16 on H100 and B200.
  • B200 strict seed 33 step 3 video-velocity max 0.6215; H100 same case 5.72e-06 (dual_trajectory_step_max.json).

Euler step-3 probe (seed 33, handoff script on pr_assets; not a #571 code commit):

Interpretation (not Euler accumulation, and not a device sensitivity difference):

  • The model casts the FP32 latent to bfloat16 before proj_in. At the step-3 input of seed 33 on B200 the two layouts' video latents differ by 1.9e-06 in FP32, and after the cast 1 of 384 elements differs (index [0,1,8], 0.40625 against 0.408203125, one bf16 step, 1.95e-03); the audio latent and every other entry latent that was checked are identical after the cast (README.md, Correction).
  • That one element reproduces the whole spike: with only it changed (same layout, arm P) the step-3 velocity gap is 0.6215 (video) and 0.305 (audio), on every block identical to the natural pair (arm A). With the same input in both layouts (arms B, C) the gap is 4.3e-06 / 5.4e-06. The audio gap comes from the video side through the joint attention (the audio latent is identical).
  • Layer by layer (layerwise_report.json): the relative difference of the block output is 7.1e-04 after block 0 and 0.22 after block 49 (about 300 times), growing by 1.1 to 1.3 times in most blocks; there is no single sensitive layer. The largest velocity gap, 0.62, is about 4% of the reference maximum (14.6).
  • On H100 the same seed has a 2.6e-06 FP32 fork but 0 of 384 elements differ after the cast at step-3 entry (337/384 differ in FP32 only; steps 0–2 also 0 bf16-differing cells — step_entry_bf16_audit_full.json, seed33_step3_entry_bf16_audit.json). H100 layerwise retest (2026-10-23, H100 cluster): arm A/B 5.7e-06 (layout-only); arms E/P 0 on every block because there is no bf16 cell to perturb (layerwise_report.json). The two devices are therefore not shown to differ in sensitivity; B200 seed 33 straddles a bf16 rounding boundary. H100 K=1000 (~2.6e-03 latent delta, 0.53 velocity) remains the same order as one bf16 step (1.95e-03, 0.62).
  • The probe script's conclusion_b200_style=supports_latent_accumulation is a B≪A threshold only, not a mechanism label. Dividing the velocity gap by the FP32 latent difference is not a gain of the forward (the cast removes that difference on H100 and turns it into one bf16 step on B200); the effective one on B200 is about 0.62 / 1.95e-03 ≈ 320.
  • Limitations: one seed; one run per arm; B200 one-element bf16 perturbation (arm P) with layerwise depth profile; H100 layerwise confirms E/P trivially zero (no bf16 cell at step-3 entry) — not an artificial one-element forward on H100; H100 K-sweep not run on B200.

Status

Hopper (merge gate): full 33B strict/provider harness, repeatability, and dual-trajectory evidence on H100 at pr_assets@ce1c63e2; strict layout drift ~1e-6 on unbound video projections; diagnostic binding yields 0/16 on H100.

B200 (supplementary): inherits #570's single pytest fail; strict dual trajectory seed 33 step 3 ~0.62, caused by one bf16 step in one input element of the step-3 forward (1 of 384 video elements differs after the bf16 cast; with identical inputs the layouts agree to ~5e-06), then spread over the 50 blocks; H100 seed 33 has no differing element after the cast — see Interpretation and dual_trajectory_diag_summary.json. Not a Hopper merge blocker unless maintainers require sm100 parity.

History

Tests

python -m pytest tests/models/minimax_h3/test_h3_full_model.py tests/models/minimax_h3/test_h3_token_refiner.py tests/models/minimax_h3/test_h3_operator_trace.py \
    tests/models/minimax_h3/test_h3_arch_fingerprint.py tests/models/minimax_h3/test_h3_projection_rows.py tests/models/minimax_h3/test_h3_one_block.py -q   # 136 passed
python tools/validation/models/h3_dual_trajectory.py --checkpoint <hf_full> --seed 11 --output <dir>

B200: same files, 141 passed, 1 failed (the failure is the #570 swiglu case).

Measured on the synced branches (2 × NVIDIA RTX PRO 6000 Blackwell, sm120, pinned MiniMax-H3@42ed227 weights incl. block 0, each build compiled in place from the checked-out commit):

Commit Command Default build, passed / skipped / failed
672c1b36 (#575, the top of this chain, contains this PR) pytest tests/models/minimax_h3 1046 / 38 / 0
672c1b36 pytest tests/models/minimax_h3 tests/build tests/runtime/test_dispatch.py tests/validation 1611 / 45 / 7 (4 failures needed the block-0 weights file, which was not installed in that run and is now; the other 3 are the known baseline failures)

Skips are environment only: no matplotlib, diffusers or sglang; tests that need 4 or 8 GPUs (2 were visible); no full-transformer shard index; no VERL_OMNI_PATH. The KERNEL_ALIGN_USE_FAST_MATH=1 build was not run on these heads. The per-device results under Results were measured at the heads named there, before this sync.

H100 (sm90) on the synced head acf52db7 (evidence: tests.json, environment header and the raw pytest logs). H100-94GB, driver 580.173.02, CUDA 13.0, torch 2.13.0+cu130, triton 3.7.1, Python 3.12, pinned MiniMax-H3@42ed227 weights incl. block 0, 4 GPUs visible, extension built in place from this commit:

Build Command passed / skipped / failed
default pytest tests/models/minimax_h3 tests/build tests/runtime/test_dispatch.py tests/validation 1567 / 6 / 1 (of 1574)
KERNEL_ALIGN_USE_FAST_MATH=1 same 961 / 611 / 2 (of 1574)
default the per-PR test files listed above 142 passed

The one default-build failure is tests/validation/operators/test_ws1_candidate_evidence.py::test_ws1_cuda_and_triton_candidate_runtime_provenance: it asks for the strict SM90 GEMM and this build was made without KERNEL_ALIGN_DET_GEMM_SM90=1 ("refusing naive fallback"). It fails the same way on the other test machine and is not an H3 test. The fast-math build has the same failure plus TestCuda::test_unsupported_device_is_refused_at_construction in tests/models/minimax_h3/test_h3_final_adaln_out.py (#489): with the H3 kernels excluded, the op constructor raises "rl_engine._C lacks the h3_det_linear_* / h3_rmsnorm_* ops" before the SM80 check the test expects. Default-build skips (6): the 8-GPU cases (4 GPUs here), sglang not installed, ROCm-only, CI-only extension enforcement, and the SM90 log-prob backend not compiled; fast-math skips (611) are the H3 kernel tests the build leaves out.

Scope / Known limitations

Evidence priority: RFC #420 CUDA review should treat H100 / Hopper results as acceptance; B200 is additional sm100 signal only.

Strict mode is fail-closed: no TF32, no fast-math, no split-K; FP32 accumulation with one final rounding; unsupported shapes, dtypes and devices raise instead of falling back. Not part of this PR: video projections (#562), O / gate_up / down GEMMs (#554, #535), full attention (#553), ROCm, SGLang adapter, pipeline parallel. The full-model strict path still binds interim attention and O / gate_up / down stand-ins, so its step time is several times the provider's; speed is not claimed.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fc6e29d and 644da96.

Files selected for processing: 26

  • docs/operators/README.md
  • docs/operators/h3-full-transformer.md
  • docs/operators/h3-operator-trace.md
  • docs/operators/h3-projection-rows.md
  • docs/operators/h3-token-refiner.md
  • rl_engine/backends/cuda/model_specific/minimax_h3/projection.py
  • rl_engine/backends/shared/triton/gemm/h3_projection.py
  • rl_engine/models/minimax_h3/operator_trace.py
  • rl_engine/reference/minimax_h3/projection.py
  • rl_engine/runtime/registry.py
  • rl_engine/validation/models/h3_block.py
  • rl_engine/validation/models/h3_full_model.py
  • rl_engine/validation/models/h3_refiner.py
  • rl_engine/validation/models/h3_weights.py
  • tests/models/minimax_h3/test_h3_full_model.py
  • tests/models/minimax_h3/test_h3_one_block.py
  • tests/models/minimax_h3/test_h3_operator_trace.py
  • tests/models/minimax_h3/test_h3_projection_rows.py
  • tests/models/minimax_h3/test_h3_token_refiner.py
  • tools/validation/models/h3_dual_trajectory.py
  • tools/validation/models/h3_full_charts.py
  • tools/validation/models/h3_full_transformer.py
  • tools/validation/models/h3_operator_trace.py
  • tools/validation/models/h3_projection_bench.py
  • tools/validation/models/h3_projection_charts.py
  • tools/validation/models/h3_refiner_report.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

fusheng-ji and others added 18 commits October 22, 2026 22:54
…fixed-order Triton GEMM

Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 650e2148c6f0e5dcdef136537e0e62f745020273)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit d099c0b)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit b41f868)
…il-closed test instead of a skip

Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 74e5b83)
…l keys

Review finding (RL-Align#568): jointly permuting x and g changed dW/dbias because the token axis
was reduced in call order. All projection ops (audio in/out, text context, Q/K/V) now take an
optional logical_keys [T,2|3] (negative first column = padding); rows are reduced in ascending
key order with padding dropped, active keys must be unique. Key format follows RL-Align#562.
Adds the reviewer's repro plus permutation/padding tests for every row and Q/K/V.

Co-authored-by: Yitao Wang <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit d2941f0)
…ready ordered rows

Follows the canonical-row design of RL-Align#562: the Q/K/V node of the block graph supplies
(batch row, position) keys so its dW is reduced in logical order, and rows that already arrive in
canonical order are reduced in place (same bytes, no gather of x and g).

Co-authored-by: Yitao Wang <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 0da0583)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit eaba5efe3df971ea9d1a969f53e48f09e09ed176)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 7da0574)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit b45190d08fc033c7e63ad821d3918eb32dd454f6)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit b5536d6)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit ad1925045b522772bf56f8468b23cca47f04156b)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit f9041e8)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit b44540e)
…ody)

Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit eab901b)
… weight loader, tests, doc

Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit d12a6bb26566fae58a309e76916af9aae767d487)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit b316869)
…ith H100 evidence

Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 0734a32ee0c427790a244c7f83e826ba9fe66393)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit c2c2270)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 1e3a2ea)
… and lint

Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit d9b0c91)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 67af796)
Signed-off-by: Wenbo Ji <[email protected]>
(cherry picked from commit 2c08c25)
@fusheng-ji fusheng-ji changed the title [WS1][CUDA][MiniMax-H3] ws1_full_h3_transformer and ws1_dual_trajectory: 33B forward/backward and rollout-vs-train control (RFC #420 stack 5/5) [WS1][CUDA][MiniMax-H3] ws1_full_h3_transformer and ws1_dual_trajectory: 33B forward/backward and rollout-vs-train control (RFC #420 stack 15/17) Oct 30, 2026
@fusheng-ji fusheng-ji changed the title [WS1][CUDA][MiniMax-H3] ws1_full_h3_transformer and ws1_dual_trajectory: 33B forward/backward and rollout-vs-train control (RFC #420 stack 15/17) [WS1][CUDA][MiniMax-H3] ws1_full_h3_transformer and ws1_dual_trajectory: 33B forward/backward and rollout-vs-train control (RFC #420 stack 5/7) Oct 30, 2026
fusheng-ji added a commit to fusheng-ji/RL-Kernel that referenced this pull request Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

🔍 OpenCodeReview found 7 issue(s) in this PR.

  • ✅ Successfully posted inline: 0 comment(s)
  • 📋 Routed to summary by policy: 7 comment(s)

⚠️ 5 warning(s) occurred during review.


test · medium

📄 tests/models/minimax_h3/test_h3_projection_rows.py (L189-L191)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity medium · category test)

This TF32-suppression guard never executes. torch.backends.cuda.matmul has no flags attribute, so hasattr(...) is always False and the with block always degrades to _noop(). The provider (native.forward = F.linear) therefore runs with ambient TF32/float32_matmul_precision in effect, and the acceptance bound 1.25 * _rel(provider, golden) + floor inflates with it — a genuinely inaccurate FP32 candidate could pass. Note test_forward_on_pinned_checkpoint_weights and test_qkv_on_pinned_checkpoint_weights call F.linear directly with no TF32 handling at all. Since the reference forward docstring says the provider runs with TF32 disabled, disable it explicitly (save/restore torch.backends.cuda.matmul.allow_tf32 = False) for every provider call used as the yardstick.

💡 Suggested Change

Before:

        torch.backends.cuda.matmul.flags(allow_tf32=False)
        if hasattr(torch.backends.cuda.matmul, "flags")
        else _noop()

After:

        _no_tf32()

test · low

📄 tools/validation/models/h3_projection_bench.py (L78-L81)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category test)

The h3_qkv_gemm accuracy path only measures Q: gold uses ws[0] alone and both candidate and provider outputs are reduced with [0]. A numerical regression confined to K or V is therefore invisible in rel_err_candidate/rel_err_provider even though the row models the fused QKV product. Record the error per projection (or at least all three) so K/V coverage is not silently dropped.


maintainability · low

📄 tools/validation/models/h3_projection_charts.py (L40-L40)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

Two minor issues in the chart entry point: main(Path(sys.argv[1]), Path(sys.argv[2])) performs no arity check, so invoking the tool without exactly two positional arguments raises an unhandled IndexError instead of a usage message; and the y-axis label is hard-coded "forward ms (H100)" even though the report records the actual device (line 59 of the bench). Honor the recorded device (or drop the hard-coded name) and validate the argument count.


bug · medium

📄 rl_engine/backends/cuda/model_specific/minimax_h3/projection.py (L94-L96)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity medium · category bug)

When logical_keys marks all rows as padding (logical_keys[:, 0] < 0 everywhere), canonical_row_order returns an empty index tensor (active is empty, so order.numel() == 0 != rows and it is not collapsed to None). _weight_grads then gathers to a (0, N) grad / (0, K) input, and gemm.linear_backward_weight -> gemm hits the m == 0 or n == 0 or k == 0 guard and raises ValueError("h3 projection GEMM needs non-empty operands"). The parameter gradient in that situation is mathematically zero, but backwards crashes instead of returning zeros. This is reachable for a rank/split that receives only padding rows while a weight/bias requires grad.

Guard the empty active set (e.g. return zero dweight/dbias of the right shape) before calling into the GEMM.

💡 Suggested Change

Before:

    if order is not None:
        grad_out, x = grad_out[order].contiguous(), x[order].contiguous()
    return gemm.linear_backward_weight(grad_out, x, with_bias=with_bias)

After:

    if order is not None:
        if order.numel() == 0:
            dweight = torch.zeros_like(weight if False else grad_out.new_empty(0))
            return grad_out.new_zeros((grad_out.shape[1], x.shape[1])), (
                grad_out.new_zeros(grad_out.shape[1]) if with_bias else None
            )
        grad_out, x = grad_out[order].contiguous(), x[order].contiguous()
    return gemm.linear_backward_weight(grad_out, x, with_bias=with_bias)

bug · low

📄 rl_engine/backends/shared/triton/gemm/h3_projection.py (L94-L95)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

available() only checks torch.cuda.is_available(), which is also True under ROCm/HIP, and there is no compute-capability guard. The sibling H3 Triton projection op rejects HIP and non-SM90 in _check_backend. Here the documented bitwise contract is explicitly CUDA-family-specific ("Hopper wgmma, Ampere/Ada mma.sync, not across them"), and BF16 tensor-core tl.dot requires SM80+. On a directly-constructed instance over ROCm or pre-Ampere CUDA, __init__/available() succeeds while the launch either fails to compile or produces bytes outside the declared contract, with no eligibility error at the operator boundary.

Reject non-CUDA devices and unsupported capabilities up front (mirroring the existing H3 Triton projection guard).


bug · medium

📄 rl_engine/models/minimax_h3/operator_trace.py (L100-L100)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity medium · category bug)

fallback now has a None ("not observed") state, but its dataclass default is still False, i.e. "observed: no fallback took place". Any caller that uses record_node(...)/OperatorCall(...) without explicitly passing fallback therefore silently passes the fallback half of violations even though nobody observed it — the test test_an_unreported_accumulator_or_split_policy_... even confirms that unobserved accumulator/split are flagged while an unobserved fallback is not. This contradicts the fail-closed intent documented on record_node ("an unobserved value fails violations"). Consider defaulting to None (as done for accumulator/split_policy) or requiring callers to pass it explicitly. Also make sure a None fallback survives to_dict/loads round-trip; otherwise a saved trace that correctly fails the gate is re-read with the default False and passes, producing a false pass in tools/validation/models/h3_operator_trace.py verify.

💡 Suggested Change

Before:

    fallback: bool | None = False  # True if any fallback path was taken; None: not observed

After:

    fallback: bool | None = None  # True if any fallback path was taken; None: not observed

bug · medium

📄 rl_engine/models/minimax_h3/operator_trace.py (L382-L382)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity medium · category bug)

The signature of trace_call_from_resolution changed from accumulator: str | None = None (where None meant "use the row contract") to accumulator: str = NOT_OBSERVED. A caller that still passes accumulator=None now stores None, which is neither NOT_OBSERVED ("") nor a valid accumulator; in violations it falls into the elif call.accumulator != want branch and reports the misleading accumulator None, strict contract needs 'fp32' instead of the intended "not observed". Normalize None to NOT_OBSERVED to keep the unobserved semantics (and old callers) consistent.

💡 Suggested Change

Before:

        accumulator=accumulator,

After:

        accumulator=accumulator if accumulator is not None else NOT_OBSERVED,

⚠️ Warnings:

  • tests/models/minimax_h3/test_h3_projection_rows.py,tools/validation/models/h3_projection_bench.py,tools/validation/models/h3_projection_charts.py (review_limit_reached): reached the aggregate token budget before finishing; the grace round did not complete the task
  • tests/models/minimax_h3/test_h3_projection_rows.py (token_budget_reached): stopped group "tests/models/minimax_h3/test_h3_projection_rows.py,tools/validation/models/h3_projection_bench.py,tools/validation/models/h3_projection_charts.py" mid-review: used 568507 tokens exceeds budget 500000
  • rl_engine/validation/models/h3_block.py (token_budget_reached): stopped dispatch: used 568507 tokens + group estimate 138704 = projected 707211 exceeds budget 500000
  • rl_engine/backends/cuda/model_specific/minimax_h3/projection.py,rl_engine/backends/shared/triton/gemm/h3_projection.py,rl_engine/reference/minimax_h3/projection.py,rl_engine/runtime/registry.py (review_limit_reached): reached the aggregate token budget before finishing; the grace round did not complete the task
  • rl_engine/models/minimax_h3/operator_trace.py,tests/models/minimax_h3/test_h3_operator_trace.py,tools/validation/models/h3_operator_trace.py (review_limit_reached): reached the aggregate token budget before finishing; the grace round did not complete the task

@github-actions

Copy link
Copy Markdown

@fusheng-ji The automated OCR review has completed.

Please review and address all automated review bot findings, then push your updates. Maintainers will begin manual review after the bot findings have been addressed.

…ness

strict_boundaries now routes proj_in and proj_out through
video_input_projection_fp32 and video_output_projection_fp32 (RL-Align#562, RL-Align#646)
instead of leaving them on the provider's cuBLAS FP32 path, whose result
depends on the row count and caused the residual single-vs-batched drift.
time_embedder and norm_out stay on the provider and are reported as such.

The --diag-video-projections diagnostic bound the h3_projection GEMM and is
removed: with strict boundaries it would be overridden and mislabelled.

The H100 numbers in the doc predate this binding and are marked as such; a
rerun is still needed.

Signed-off-by: Wenbo Ji <[email protected]>
…o feat/h3-projection-rows

Signed-off-by: Wenbo Ji <[email protected]>
RL-Align#588) into feat/h3-token-refiner

operator_trace.py and h3-operator-trace.md: take the merged RL-Align#567 version and reapply this branch's refiner stage on top.

Signed-off-by: Wenbo Ji <[email protected]>
…L-Align#588) into feat/h3-full-transformer

h3_full_model.py: keep both the strict boundary bindings of this branch and the diagnostic provider nodes and provider variants of RL-Align#587/RL-Align#588.

Signed-off-by: Wenbo Ji <[email protected]>
@maxiaosong1124

Copy link
Copy Markdown
Collaborator

please resolve conflicts first, thx! @fusheng-ji

record_node filled the accumulator in from the row contract, and
trace_call_from_resolution and the default split policy did the same, so a
trace from block_observer always passed those checks: a run that
accumulated in BF16 or used split-K would still verify as strict.

They are now recorded only when the caller supplies them; an unset value is
"not observed" and violations reports it. block_observer only learns the
node name, so it also records the fallback state as not observed (None).
violations(require_observed=False) and verify --allow-unobserved check the
bindings alone, by explicit request; such a trace is not strict evidence.

Reported by OpenCodeReview on RL-Align#567 after it merged.

Signed-off-by: Wenbo Ji <[email protected]>
@maxiaosong1124
maxiaosong1124 self-requested a review November 5, 2026 10:51

@maxiaosong1124 maxiaosong1124 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@maxiaosong1124
maxiaosong1124 merged commit 770675d into RL-Align:test-h3 Nov 5, 2026
6 checks passed
fusheng-ji added a commit to fusheng-ji/RL-Kernel that referenced this pull request Nov 6, 2026
Flink-ddd added a commit that referenced this pull request Nov 16, 2026
[WS1][CUDA][MiniMax-H3] Review follow-up for #568 / #570 / #571 / #574 and the strict full-model backward session (RFC #420 follow-up 1/3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MiniMax-H3 new-model platform: cuda Specific optimizations or bugs in NVIDIA graphics cards (such as FlashInfer, TMA optimizations) WS1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants