Skip to content

GDN planner: price the dense projection work per GDN-owned token; refit the chain overheads and gate - #884

Draft
bradhilton wants to merge 12 commits into
mainfrom
gdn-planner-chain-gate
Draft

GDN planner: price the dense projection work per GDN-owned token; refit the chain overheads and gate#884
bradhilton wants to merge 12 commits into
mainfrom
gdn-planner-chain-gate

Conversation

@bradhilton

Copy link
Copy Markdown
Collaborator

Follow-up to #859 (the GDN-planner item of its follow-up list).

What the GDN planner got wrong

After the attention-to-GDN all-to-all the whole GDN layer — input projection, convolution, recurrence, output projection — runs on the GDN layout, so a rank pays the projections for every GDN token it owns, chained or not. The GDN planner's runtime model (GdnPlannerConfig) priced a rank's work by a recurrent rate alone (1,500 tokens/ms), fitted once on the 35B reference shape. On the paired A/B of #859 this showed as a 23% slowdown of one Qwen3.5-4B layout: the planner stopped chaining a 12.6k-token sequence across the ranks because it predicted a 4 ms saving against a 4 ms gate, while the measured saving was about 15 ms per layer.

Measurement

--gdn-ab times every layout of a cell under the production GDN planner and under two forced decisions that bracket its choice — never chain, chain every legal segment — in alternating rounds on the same node with the attention planner unchanged, so the paired difference is the GDN decision's own cost. Campaigns on Qwen3.5-4B (CP2, CP4), Qwen3.5-27B (CP2, CP4) and Qwen3.5-35B-A3B (CP2 EP1/EP2, CP4 EP2/EP4): 982 layouts. Chaining everything is the wrong move on most layouts (short segments; the chain overhead dominates), but where it wins the model missed it by 3–70×: one 12.5k-token sequence at CP4 measures 16.7 ms per GDN layer faster chained on 4B (predicted 3.8) and 48 ms on 27B.

Change

  • runtime_dense_tokens_per_ms: the projection work per GDN-owned token, from the model shape's FLOPs at the throughput the three campaigns fit jointly (156 TFLOP/s; 617 tokens/ms on the 4B shape, 224 on 27B, 772 on the 35B reference). It enters the per-rank critical path of the runtime prediction and the chain scoring; the owner search balances recurrent work only (pricing the dense work there moved local segments toward token balance at the cost of more layout exchange, measured as noise with a +14% outlier).
  • Chain overheads refit with the recurrent rates and exchange costs held at their shipped values: 2.2 ms per bucket launch (was 0.2), suffix scan 2.8 ms per bucket plus 3.5 segments/ms at the reference shape (was 2.0 and 15); the per-byte summary-exchange cost is not supported by the data and retires into the per-segment scan.
  • Chain gate 4.0 → 2.0 ms: every chain that measured slower on 4B was predicted to save under 2 ms per layer; 2 ms keeps 97% of the measured gain on 4B and 99% on 27B.
  • Model error on the paired deltas 10.1 → 5.2 ms per layer (rms); the regret of choosing between the two arms by the model 1,082 → 297 ms per layer summed over 982 layouts.

Validation against main's GDN planner (paired, same node, attention planner unchanged)

class layouts chain decision changed faster > 2% slower > 2% unchanged layouts production selection
Qwen3.5-4B 274 72, median −15.2% 69 1 (+3.0%) 174, ±0.5% −6.9% at CP4, 0.0% at CP2
Qwen3.5-27B 274 95, median −17.8% 90 1 151, ±0.3% 0.0% (production picks were already chained at CP4)
Qwen3.5-35B-A3B 574 119, median −3.7% 70 11 (worst +6.5%) 371 (+30 synthetic CP4 EP1), ±1% +0.5% to −0.3% per shape

Best layout per real-data group: −15% to −43% at CP4 and −21% to −34% at CP2 on 4B; up to −30% per layout on 27B; within ±1% on 35B. Known residual: the model over-predicts chain savings on 35B by about 2× (11 of 119 changed layouts slower by more than 2%).

Re-certification

table cells pairwise p95 regret max regret before
dense-h2560 (Qwen3.5-4B, Qwen3-4B) 58 99.0% 1.2% 1.9% 98.7% / 1.9% / 2.8%
gdn-moe-h2048 (Qwen3.5-35B-A3B) 80 97.8% 2.2% 4.2% 96.6% / 2.7% / 4.2%
dense-gdn-h5120 (Qwen3.5-27B) not refit 98.6% / 3.9% / 4.6% kept

Every admitted CP > 1 cell of the three GDN tables was re-measured by the validation campaign (its current-planner rows); the fitter now re-certifies from new evidence plus the previous certificate's aggregates for the cells a change does not touch (--from-certificate with evidence). The 27B refit fails its held-out gate on one cell (Ellavox g3 at CP4, 11.3%): the deep uniform_depth_3 layout's long GDN segments now chain and it becomes 10% faster than the shallow layouts the ten terms prefer; neither a CP-split of the GDN level term nor a fit on the CP > 1 cells alone recovers it. The shipped 27B table is kept: under the new planner its picks are within 2.7% of the new best on the other 13 CP4 cells and its g3 pick is 22% faster than before (regret against a new best, not a regression), and withholding the shape would hand the group to version 1, which loses up to 33% there. A second stage pricing shortlisted layouts with the planners' own calibrated models fixes g3 (4.0%) but mis-ranks two synthetic CP4 cells by 7–8% in its pure form; a fitted GDN-aware re-ranker is the follow-up.

Also in this PR

  • Harness: --gdn-ab, --gdn-legacy-ab; the contract phase admits the yield_empty flag of Support filtered trajectory copies and safe empty-rank forwarding #864.
  • Fitter: re-certification from evidence plus certificate aggregates (manifest fingerprints, completeness and export aware).
  • Regression test: an 8k-token sequence at CP4 chains under the dense term and stays on one rank without it.

Follow-ups

  • GDN-aware second stage for the layout selector (27B CP4 g3; the 35B chain tail).
  • 35B: chain overheads under expert parallelism (the model's 2× over-prediction there).

🤖 Generated with Claude Code

bradhilton and others added 10 commits September 9, 2026 02:07
Times every layout of a cell under the production GDN planner and under two
forced decisions that bracket its chain-versus-local choice — never chain
(the chain gate can never be met) and chain every legal segment (the gate is
always met and the beam search is skipped) — in alternating rounds on the
same node with the attention planner unchanged, so the paired difference is
the GDN decision's own cost. Rows carry planner_variant (gdn-local,
gdn-chain), which the fitter already ignores; candidate rows record each
variant's GDN decision (chained segments, per-rank GDN tokens, exchanged
tokens). The variant switch reuses the planner A/B installer, which now also
patches the GDN planner configuration builder.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…aggregates

--from-certificate together with evidence files now means re-certification:
cells the evidence re-measures are fitted from their rows, every other cell of
the certificate is carried as its recorded aggregates (medians, counts,
spreads, features, fingerprints). The manifest check counts carried cells as
present with their recorded fingerprints, the completeness check judges them
by their recorded row counts, and the exported certificate keeps their
fingerprints. A runtime change that affects some shapes only can then be
re-certified without re-measuring — or still having — the raw rows of the
unaffected cells.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
#864

forward_micro_batches and dp_rank_forward gained a keyword-only yield_empty
flag that defaults to False; with it off the pinned contract is unchanged, so
the contract phase accepts exactly that shape and still rejects anything else.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The GDN layer's input and output projections run on the GDN layout after the
attention-to-GDN exchange, so a rank pays them for every GDN token it owns,
chained or not; the runtime model priced the recurrent kernel alone. The
paired planner A/B on Qwen3.5-4B (--gdn-ab, 246 layouts at CP2 and CP4, never
chain versus chain everything) shows a rank holding one long sequence costs
about 2 us per token, twice the recurrent rate, and the model under-priced the
benefit of chaining such a sequence 3-70x (e.g. one 12.5k-token Ellavox
sequence at CP4: measured 16.7 ms per layer, predicted 3.8).

GdnPlannerConfig gains runtime_dense_tokens_per_ms, derived in
from_model_shape from the projection FLOPs (fused input projection to
2 x key width + 2 x value width + 2 x value heads, output projection back to
hidden, backward twice the forward) at the 280 TFLOP/s the campaign fitted
(1,108 tokens/ms on the 4B shape; 1,385 on the 35B reference, 403 on 27B).
The term enters the per-rank critical path of the runtime prediction, the
chain scoring and the owner search. On the 4B campaign the production
decision's regret against the faster measured arm falls from 421 to 42 ms per
layer summed over 216 layouts (47 layouts now chain where chaining measured
faster, one chains where it measured 2% slower); the chain gate and the
recurrent rates are unchanged pending the 27B and 35B campaigns.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
--gdn-legacy-ab times every layout under the production GDN planner and under
main's GDN planner before the recalibration (the dense projection term
disabled, nothing else changed) in alternating rounds on the same node, so
the recalibration can be validated on hardware exactly as the CP planner was.
Tested: the legacy arm differs in that one field and keeps an 8k-token
sequence on one rank where the production planner chains it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ree classes

Joint fit of the runtime model to the paired --gdn-ab campaigns on Qwen3.5-4B,
Qwen3.5-27B and Qwen3.5-35B-A3B (982 layouts, each timed under never-chain
and chain-everything in alternating rounds; the recurrent rates and the
layout-exchange and parent-state costs held at their shipped values): the
dense projection work runs at about 156 TFLOP/s (617 tokens/ms on the 4B
shape, 224 on 27B, 772 on the 35B reference), a bucket costs about 2.2 ms to
launch (was 0.2), the suffix scan 2.8 ms per bucket plus 3.5 segments/ms at
the reference shape (was 2.0 and 15), and the campaigns expose no per-byte
summary-exchange cost beyond that per-segment scan (the two are collinear;
the bandwidth is set high). Model error falls from 10.1 to 5.2 ms per layer
(rms); the decision regret against the faster measured arm from 1,082 to
297 ms per layer summed over the 982 layouts, and it is flat for chain gates
between 0 and 1 ms while the number of chains that measured slower halves at
1 ms, so the gate moves from 4.0 to 1.0 ms.

Replaying the production planner on the campaigns (layouts whose decision is
one of the two measured arms): regret 421 -> 31 ms per layer on 4B (44
layouts newly chained where chaining measured faster, none where slower),
1,471 -> 17 on 27B (53 / 2), 359 -> 75 on 35B (66 / 5, none above 2 ms).
Partial chains (42 / 74 / 62 layouts) are not covered by the two arms; the
paired validation against main's planner (--gdn-legacy-ab) covers them. The
harness's legacy arm restores every changed field.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The paired validation against main's GDN planner (Qwen3.5-4B complete, 27B
and 35B-A3B in progress) separates the two effects of the dense term. The
chain decisions carry every measured gain (4B: 75 of 83 changed layouts
faster, median -13.5%, best layout per real-data group -15% to -43% at CP4;
27B so far: 65 of 72, median -17.7%). The owner-assignment changes it also
caused were noise at the median with a +14% outlier on a heterogeneous
synthetic cell (more layout exchange for a slightly lower maximum load), so
the owner search balances recurrent work only, as before; the dense term
stays in the runtime prediction and the chain scoring.

Every chain on 4B that measured slower was predicted to save under 2 ms per
layer, and a 2 ms gate keeps 97% of the measured gain on 4B and 99% on 27B,
so the gate is 2.0 ms rather than 1.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Paired validation of the recalibrated GDN planner against main's on
Qwen3.5-4B (tr-gdnfin-4b, 274 layouts at CP2 and CP4, alternating rounds on
the same node; attention planner unchanged): the 72 layouts whose chain
decision changed are faster by a median 15.2% (69 faster, one slower by 3%);
the other 174 are unchanged within noise. Production selection -6.9% at CP4,
the best layout per cell -6.0% at CP4 (worst cell +1.1%), CP2 unchanged.

The table is refit from the campaign's current-planner rows for every CP2 and
CP4 cell of Qwen3.5-4B (plus its two-layer grpo-g8-long cell), carrying the
certificate's aggregates for the CP1, TP2 and Qwen3-4B cells the GDN planner
does not touch: 58 cells, 99.0% pairwise, p95 regret 1.2%, max 1.9% (was
98.7% / 1.9% / 2.8%), held-out gates pass.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Paired validation of the recalibrated GDN planner against main's on
Qwen3.5-35B-A3B (tr-gdnfin-35b at CP2 EP1/EP2 and CP4 EP2/EP4, tr-gdnfin-35b-cp4
at CP4 EP1 on the synthetic cells; 574 layouts): the 119 layouts whose chain
decision changed are faster by a median 3.7% (70 faster by more than 2%,
11 slower, worst +6.5%); production selection between +0.5% and -0.3% per
shape; the model over-predicts chain savings on this class by about 2x, so
its tail is the one this change leaves open.

The table is refit from the campaign's current-planner rows for every
admitted CP > 1 cell (60 cells), carrying the certificate's aggregates for
the 21 CP1 and TP2 cells: 80 cells, 97.8% pairwise, p95 regret 2.2%, max
4.2% (was 96.6% / 2.7% / 4.2%), held-out gates pass. The g2 Ellavox cell at
CP4 EP2 segfaults in the expert grouped GEMM as before (issue #851) and stays
excluded.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tion

The brief gains a section on the GDN planner: why the dense projection work
follows the GDN layout, the paired --gdn-ab campaigns and the joint fit, the
validation against main's planner on the three GDN classes, the
re-certification of the 4B and 35B tables, and why the 27B table is kept
as certified (the refit misses one held-out CP4 cell that the ten terms
cannot see; version 1 would be far worse; a GDN-aware second stage is the
follow-up). The README documents the two GDN harness modes; the 27B class
comment records the gap.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@bradhilton
bradhilton had a problem deploying to trainer-rank-gpu-validation September 10, 2026 06:36 — with GitHub Actions Failure
bradhilton and others added 2 commits September 10, 2026 06:52
CPU-only planning scores with the default dense table, which every
re-certification moves; the test now searches the shared-prefix length where
one saved copy stops paying for the extra level instead of pinning it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@bradhilton
bradhilton deployed to trainer-rank-gpu-validation September 10, 2026 06:54 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant