Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

refactor(components): owner-partitioned stacked persistence for V/U (flagship muon sharding)#989

Draft
ocg-goodfire wants to merge 2 commits into
feature/muonfrom
feature/muon-owner-sharding
Draft

refactor(components): owner-partitioned stacked persistence for V/U (flagship muon sharding)#989
ocg-goodfire wants to merge 2 commits into
feature/muonfrom
feature/muon-owner-sharding

Conversation

@ocg-goodfire

Copy link
Copy Markdown
Collaborator

Design B from the flagship muon-sharding discussion (bridge: component-norm-optimizer): the V/U masters (+ optimizer moments) persist as same-shape stacks(Vs [g, d_in, C], Us [g, C, d_out]) per shape group + a static site_slots index — replacing 2·n_sites per-site leaves.

Placement (hybrid HSDP rule): stack axis ÷replicate (whole matrices owned per node-group → zero cross-node weight collectives per step; muon NS node-local), matrix dims ÷fsdp (NVLink), C ÷tp. Total ÷N — same memory as intra-matrix ZeRO-1. Per-group fallback to intra-matrix sharding when a stack doesn't tile replicate (site subsets, e.g. L18-only). At replicate=1 the layouts coincide (zero change single-node).

Why: at 32L/dp32 the per-kind stacks the scan already consumes become static slices of the resting representation (the per-step 32-way restack disappears); ENTRY's cross-replicate gather and the backward's grad reduce land in collectives that must exist anyway; muon's NS runs on whole owned matrices with no cross-node reshard — the Kimi owner-partitioned recipe expressed GSPMD-natively, with the trainer's existing structures.

Muon interplay: V/U leaves are now 3D, so both optimizer groups use stacked_muon_dimension_numbers (renamed from chunk_stacked_*) — optax's default 2D rule would silently Adam every V/U leaf.

Validation: full suite 535 passed / 11 xfail; multidevice 5 passed (placement + bit-parity init pinned to the new rule); invariance_check at 4 sim devices OK (worst rel 9.6e-6 — the SPEC D4 anchor: same math, different layout). SPEC D4 amended (2026-07-15, Oli-requested). Includes cherry-pick of f63dcd5 (invariance_check int-tokens fix that was stranded on its bridge branch).

Known follow-ups before landing: one-off checkpoint layout migration for pre-change runs (restore-onto-reference means old per-site checkpoints don't open at tip; migrate_c49k_checkpoint.py is precedent); grad_norms/components* per-leaf wandb keys now path through stacks (summaries unchanged); CI-fn masters deliberately keep intra-matrix ZeRO-1 (their owner-partitioning is a separate decision).

Stacked on #982 (base: feature/muon).

Bridge thread: component-norm-optimizer

🤖 Generated with Claude Code

https://claude.ai/code/session_01SwEM9ZetQw9W4yjH8okwaH

ocg-goodfire and others added 2 commits July 15, 2026 04:41
…PEC D4)

The check predated the S18 amendment that made the model input token ids
(Int[B,T] -> embed_tokens indexing); its float32 'resid' batch crashed
clean_output with 'Indexer must have integer or boolean type'. Draw random
int tokens like the llama8b tests do. Same failure family as the slow-eval
hidden_acts crash fixed by #919.

Verified: XLA_FLAGS=--xla_force_host_platform_device_count=4 passes
(worst rel 1.02e-04 within tol).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…/U masters

DecompVU persists as same-shape stacks — one (Vs [g,d_in,C], Us [g,C,d_out])
pair per shape group + a static site->(shape,slot) index — instead of 2*n_sites
per-site leaves. Placement (hybrid HSDP rule): stack axis /replicate (whole
matrices owned per node-group: zero cross-node weight collectives per step,
muon NS node-local), matrix d dims /fsdp, C /tp — total /N, same memory as the
retired intra-matrix ZeRO-1; per-group fallback to intra-matrix sharding when a
stack doesn't tile replicate (site subsets). SPEC D4 amended 2026-07-15
(Oli-requested).

- llama8b _stack_per_kind_vu: contiguous-slot fast path = a static slice of the
  resting stack (the per-step 32-way restack disappears for full-model runs);
  _per_kind_dims reads shapes statically off site_slots.
- init_decomp_vu_placed: one jit, 2*n_shapes outputs (the stack/unstack fan-out
  and its transient copy are gone).
- muon: the V/U tree is all-3D now, so BOTH optimizer groups label leaves via
  stacked_muon_dimension_numbers (renamed from chunk_stacked_*; optax's default
  2D rule would silently Adam every V/U leaf).
- decomp_vu_from_sites: explicit per-site-dict constructor (toys/tests).
- cherry-pick f63dcd5 (invariance_check int tokens — the fix was stranded on
  its bridge branch; harness needed here).

Validated: full suite 535 passed + multidevice 5 passed; invariance_check at 4
sim devices OK (worst rel 9.6e-6, reassociation-only — the D4 anchor for the
layout change). Known follow-ups: one-off checkpoint layout migration for
pre-change runs; grad_norms per-leaf wandb keys now path through stacks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SwEM9ZetQw9W4yjH8okwaH
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant