Skip to content

Gate the fitted layout score on measured execution classes (calibration expansion, stage 1) - #844

Draft
bradhilton wants to merge 1 commit into
mainfrom
trainer-rank-calibration-classes
Draft

Gate the fitted layout score on measured execution classes (calibration expansion, stage 1)#844
bradhilton wants to merge 1 commit into
mainfrom
trainer-rank-calibration-classes

Conversation

@bradhilton

Copy link
Copy Markdown
Collaborator

Stage 1 of the expanded cost-model calibration campaign (other hidden sizes, MoE), per the plan agreed with Codex: no new GPU evidence yet, only the machinery so that new execution classes can be measured, fitted and certified without loosening the current gate.

What changes

Admission by execution class, not by hidden size. A calibrated coefficient table applies only to the execution classes it was measured on:

  • ModelGeometry, read from the Megatron config (never a model name): hidden and FFN widths, attention head geometry, GDN state shape, expert geometry. Layer counts remain scoring facts, not identity.
  • DeviceClass: compute capability plus a memory-system bucket (the 80 GB H100 shares capability 9.0 with the H200 but is not admitted).
  • ParallelShape: TP × CP × EP × ETP.
  • CalibratedTable + select_scoring replace CalibrationProfile / coefficient_version_for. The shipped dense hidden-2,560 table admits exactly the Qwen3.5-4B and Qwen3-4B geometries at the four measured shapes (TP1 × CP1/2/4, TP2 × CP1). Consequently TP2 × CP2, CP8, TP4 and any expert parallelism now fall back to the version-1 score until measured (previously TP2 × CP2 would have used the fitted table unmeasured). CPU-only planning keeps the default table.
  • The table identity joins the coefficient version in the planner facts, the layout cache key and the memory-profile signature; the selector threads the table through the scorer.

Runtime facts. TrainerRank derives the geometry, EP/ETP and the MoE layer count from the runtime. Both admitted geometries were cross-checked against providers built on CPU for the two models (identical).

Harness. Cell rows record the geometry, device memory class, EP/ETP, MoE facts and the score the runtime actually used (the earlier rows recorded the module constant, which was wrong for fallback runtimes). New cell family cal-ellavox-qwen3 uses the Qwen3-tokenized Ellavox corpus Codex pointed at (git-ignored, SHA-pinned like the Qwen3.5 corpus; 44 groups, 261 histories, max id 151,668), with an explicit tokenizer-agreement check (vocabulary size and a decoded sample) that fails a cell loudly on mismatch.

Fitter. Cell keys carry |ep{n}/|etp{n} only when above one (existing keys unchanged); certificates name their table (--table-id) and record the admitted device classes, dtypes, geometries and shapes; per-model, per-shape and per-family gate reports, judged per group and never pooled, as Codex asked.

Certificate. Regenerated from the same 58-cell evidence with the class facts backfilled: identical table hash. The certificate test now asserts the admitted sets equal the production table's, that every geometry was measured at every admitted shape, and one geometry per model.

Checks

uv run prek run --all-files green; tests/acceptance/trainer_rank_planner + tests/unit/test_trainer_rank*.py + tests/unit/test_planner_cost*.py: 588 passed, 17 skipped (including the opt-in full refit). No GPU runs in this PR.

Next stages

  1. Qwen3.5-35B-A3B smoke, then the deconfounded TP1 lattice (CP1/EP1, CP2/EP1, CP2/EP2, CP4/EP1, CP4/EP2, CP4/EP4), the TP2/ETP1 pair and Ellavox groups.
  2. Dense controls (Qwen3-1.7B, Qwen3-8B, Qwen3.5-27B, Qwen3-14B) at CP1/CP2/CP4/TP2, plus TP2 × CP2 for the two 4B models.
  3. Per-class certificates.
  4. Attention-MoE (Qwen3-30B-A3B) and the normalized cross-model scorer as an offline leave-one-model-out study.

🤖 Generated with Claude Code

Prepares the cost-model calibration for more model families (other hidden
sizes, MoE): a coefficient table now applies only to the execution classes it
was measured on, and the harness, fitter and certificate carry those classes.

- `_planner_cost`: `ModelGeometry` (read from the Megatron config: widths,
  attention head geometry, GDN state shape, expert geometry; never a model
  name; layer counts stay scoring facts), `DeviceClass` (capability plus a
  memory-system bucket, so the 80 GB H100 is not admitted on the H200
  table), `ParallelShape` (TP x CP x EP x ETP) and `CalibratedTable`
  replace `CalibrationProfile`; `select_scoring` picks the admitting table
  or the version-1 fallback. The shipped dense hidden-2,560 table admits the
  Qwen3.5-4B and Qwen3-4B geometries at exactly the four measured shapes, so
  TP2 x CP2, CP8, TP4 and expert parallelism now fall back until measured.
  The table identity joins the coefficient version in the planner facts and
  layout cache key; the selector threads the table through the scorer.
- TrainerRank derives geometry, EP/ETP and MoE layer count from the runtime;
  the two admitted geometries were cross-checked against providers built on
  CPU for both models.
- Harness: rows record the geometry, device memory class, EP/ETP, MoE facts
  and the score the runtime actually used; a Qwen3-tokenized Ellavox corpus
  (`cal-ellavox-qwen3`, git-ignored, SHA-pinned) with an explicit tokenizer
  agreement check for Ellavox cells.
- Fitter: cell keys carry EP/ETP when above one; certificates name their
  table and record the admitted classes; per-model, per-shape and
  per-family gate reports (never pooled).
- Certificate regenerated from the same evidence with the class facts:
  identical table hash; the certificate test now asserts the admitted sets
  equal the production table's and that every geometry was measured at
  every admitted shape.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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