feat(optim): bf16 Adam m/v storage for the V/U + CI-fn optimizers (moments_dtype)#944
Open
ocg-goodfire wants to merge 2 commits into
Open
feat(optim): bf16 Adam m/v storage for the V/U + CI-fn optimizers (moments_dtype)#944ocg-goodfire wants to merge 2 commits into
ocg-goodfire wants to merge 2 commits into
Conversation
…ments_dtype) New `OptimizerConfig.moments_dtype` knob (default float32 — bit-unchanged, pinned by test): `bfloat16` stores BOTH Adam moments bf16 while the fp32 masters stay untouched (SPEC N1) and update arithmetic still promotes to fp32 — optax's `mu_dtype` covers m, and a tiny init wrapper pins nu's storage dtype (optax's `cast_like(nu, state.nu)` preserves it every step). m/v inherit the masters' ZeRO-1 ÷N sharding via zeros_like/astype. ~-6 GiB/GPU of the full32L b128 optimizer block. Plus the same-seed 10k-step pile-4L PPGD-bsc A/B config pair (quality gate; harness shape from lp-bf16-source-ab / PR #938). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CbD62cDit2QPQBHUT3fzkk
…le-and-exit) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CbD62cDit2QPQBHUT3fzkk
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.
What
New
OptimizerConfig.moments_dtype: float32 | bfloat16(defaultfloat32— bit-unchanged, pinned by a new test):bfloat16stores BOTH Adam moments of the components (V/U) and CI-fn optimizers in bf16 while the fp32 masters stay untouched (SPEC N1). Item #5 of the lower-precision roadmap (bridge tasklp-bf16-adam-moments-vu; followslp-bf16-source-ab/ #938 which validated the same technique on the PPGD source Adam).Implementation is deliberately tiny: optax's
mu_dtypecovers the first moment natively, and itsscale_by_adamupdate ends withnu = cast_like(nu, state.nu)— so the second moment's storage dtype is whatever it was initialized with._with_nu_dtypewraps only the init. Update arithmetic still promotes to fp32; bf16 is storage rounding only. m/v inherit the masters' ZeRO-1 ÷N sharding viazeros_like/astype; the #927 fsdp-major reconstruct gathers masters only, so sharding/layout is untouched (confirmed by the memprobe: temp identical, 96.9 GiB both arms).Validation
Memory (full32L b128/dp32 memprobes, 4 scavenge nodes each):
Quality (same-seed 10k-step pile-4L PPGD-bsc A/B, runs p-6a9bc1ce fp32 / p-4731b0d9 bf16):
Tests: new tests pin (a) bf16 m/v dtype persists across updates, (b) bf16 trajectory tracks fp32 within storage-rounding scale, (c) fp32 default is bit-identical to plain
optax.adamw. Optim-parity/checkpoint/equivalence/stacked-parity suites green at default + 4 sim devices.The A/B + memprobe config pairs are included (derived from
pile_ppgd_bsc.yaml/llama8b_full32L_HSDP_b128_dp32.yaml).🤖 Generated with Claude Code
https://claude.ai/code/session_01CbD62cDit2QPQBHUT3fzkk