Price dense recompute by its traced stage and one input gradient - #986
Draft
bradhilton wants to merge 6 commits into
Draft
bradhilton wants to merge 6 commits into
bradhilton wants to merge 6 commits into
Conversation
For dense models TrainerRank charged one input gradient per saved boundary, which on dense Qwen3.8-27B at CP2 over-prices gradient waves by about 40%. Allocator traces show the recomputed layer's peak holds one input gradient and an MLP FC1 stage of 7F per row: the base output, the LoRA output and their sum, plus one F-wide tensor. When every decoder layer is the exact supported gated MLP, up to CP2, price that stage beside the recomputed mixer in both checkpoint floors and charge one gradient. Above CP2, or for any other structure, the per-boundary allowance stays. No-grad groups run one after another, so a CP2 multi-group no-grad wave's static floor now counts only the largest group's share of packed tokens. Single-group pricing is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
bradhilton
had a problem deploying
to
trainer-rank-gpu-validation
September 26, 2026 08:21 — with
GitHub Actions
Failure
bradhilton
had a problem deploying
to
trainer-rank-gpu-validation
September 26, 2026 08:30 — with
GitHub Actions
Failure
Review follow-ups: - A no-grad group in a covered dense model is charged its traced 6F + 6H transient per row, including beside retained gradient boundaries in mixed waves, instead of 4H. - Multi-group no-grad waves price the largest group's own rows at that width, and at least its share of the per-token floor, instead of converting through the wave's average packed-to-row ratio. - The gradient stage adds one more FC1 triplet (6F) for the early-run recompile residue seen in q062, so cold waves need no learned profile. - Only at CP2, where it was traced. TE workspace growth is charged for dense too. - The gate requires the traced fused-norm FC1, the unfused SwiGLU config, no hooks or overrides on the decoder, layers, mixers or MLP besides ART's GDN wrappers, the trainer's hidden size, and LoRA ranks up to 256, rechecked per active slot. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
bradhilton
had a problem deploying
to
trainer-rank-gpu-validation
September 26, 2026 08:43 — with
GitHub Actions
Failure
Round-2 review follow-ups: - The one-gradient decision uses the same slots as the floor, so an unsupported slot in any group keeps both allowances. - No-grad-only waves charge TE workspace growth too. - The gate requires Megatron's TransformerLayer, attention or GDN mixers whose class forward is the base one, and ART's GDN wrappers delegating to that class forward. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
bradhilton
had a problem deploying
to
trainer-rank-gpu-validation
September 26, 2026 08:57 — with
GitHub Actions
Failure
Training compile replaces each layer's _art_gdn_island_physical_forward with torch.compile's wrapper, so the gate rejected every layer of the compiled model it was traced on. Judge the callable Dynamo wraps. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
bradhilton
had a problem deploying
to
trainer-rank-gpu-validation
September 26, 2026 09:03 — with
GitHub Actions
Failure
The traced Qwen3.8-27B run uses Megatron Bridge's Qwen3VLSelfAttention (which overrides forward) and Bridge's fused SwiGLU (bias_activation_fusion=True), so the gate rejected every layer of it. Accept exactly the traced mixer types and the fused activation. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
bradhilton
deployed
to
trainer-rank-gpu-validation
September 26, 2026 09:13 — with
GitHub Actions
Active
The gate now walks every module under each decoder layer, not just the MLP: - no hooks or instance forwards except ART's GDN layer, mixer and empty-safe norm wrappers, which must delegate to the class forward; - every adapter, including the mixer's, is an exact LoRA with no selector override, within the rank limit; - every adapter's rank term is priced. Dense widths now require the checkpoint floor's own decoder conditions, so the multi-group no-grad discount always keeps its TE workspace growth. The split planner's optimistic lower bound drops the largest group's share of the per-token floor. That share shrinks as another group's rows grow, so it could exceed the exact cost and prune a feasible split. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
bradhilton
had a problem deploying
to
trainer-rank-gpu-validation
September 26, 2026 10:10 — with
GitHub Actions
Failure
bradhilton
deployed
to
trainer-rank-gpu-validation
September 26, 2026 10:30 — with
GitHub Actions
Active
bradhilton
marked this pull request as ready for review
September 26, 2026 15:46
bradhilton
had a problem deploying
to
trainer-rank-gpu-validation
September 26, 2026 15:46 — with
GitHub Actions
Failure
bradhilton
marked this pull request as draft
September 26, 2026 16:08
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For dense models TrainerRank charges one input gradient per saved layer boundary, on top of the boundaries themselves. It also prices several no-grad groups as if they ran at once. On dense Qwen3.8-27B at CP2 this over-prices gradient waves by about 40% and multi-group no-grad waves by up to about 2.5x. In q062 the planner refused a wider wave in 242 of 269 decisions.
Allocator traces of dense Qwen3.8-27B at CP2 (random init, reproducing q062's shapes exactly) show:
What changes (dense models at CP2 only, gated)
Structural gate.
_dense_mlp_recompute_bytes_per_tokenreturns the per-row gradient stage and no-grad transient only when every decoder layer matches the traced execution:TransformerLayerwith exactly the traced mixer types:SelfAttention, Bridge'sQwen3VLSelfAttentionorGatedDeltaNet;forward(through Dynamo's compile wrapper, as in training);LoRAthat selects its tensors the way execution does, with every adapter's rank priced.The traced model is a GDN/attention hybrid. A pure-attention dense model with the same MLP passes the gate on extrapolated widths.
Anything else returns 0 and keeps today's pricing.
Eligibility. Decided once over all of a wave's slots, so one unsupported slot keeps both allowances.
Gradient groups. Priced with the recomputed mixer, residual and norm, and the MLP stage. The stage also carries one more FC1 triplet (6F) for the early-run recompile residue seen in q062. The gradient is one row of H instead of one per boundary. This applies to both the busiest-rank floor and Price CP2 recompute per rank on each layer type's layout #978's per-layout floor, plus TE workspace growth (no-grad-only waves included).
No-grad groups. Charged their 6F + 6H transient, including beside retained gradient boundaries in mixed waves.
Multi-group no-grad waves. Priced at the largest group's own rows at that width, and at least its share of today's per-token floor. A single no-grad group also gains its per-row transient from the checkpoint floor, which is conservative. That share falls as another group's rows grow, so the split planner's lower bound keeps only the largest group's rows.
Not changed. CP1, CP>2, TP>1, MoE, the 1.10 factor and learned profiles.
Before/after (q062, 269 real waves held out from the trace fit)
Testing: 65 new unit tests cover the gate (43 structural negatives, including a compiled delegate, the Qwen attention class, mixer children and adapters, and LoRA selector overrides), named slots through the real slot lookup, per-slot ranks and mixed-slot fallback, the checkpoint-floor conditions, the split lower bound, one gradient, both floors, the no-grad transient in mixed waves, unequal group ratios and the CP2-only scope. Replay of older reports stays compatible. The trainer-rank suite passes.
On dense Qwen3.8-27B compiled as in training, the gate is active on the real model, including its walk over each layer's children. The GPU results below come from the previous revision, whose widths were 0.06% lower. On 2×H200 (CP2, random init), held-out single waves:
None is under. On q062-shaped batches, #986 packs 10 waves where main needs 11, but runs no faster. The binding limit is the ~36 GB of free memory, not the estimate.
Stacked on #978 (itself on #963); none of the stack is merged, so review in that order.
🤖 Generated with Claude Code