Repository navigation
[optim, ckpt] feat: add fp32 masters and selective cpu adamw #1226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YLlllllllllll
wants to merge
290
commits into
ByteDance-Seed:main
Choose a base branch
from
YLlllllllllll:qwen38-base-optimizer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 137 commits
Commits
Show all changes
290 commits
Select commit
Hold shift + click to select a range
c61c733
[checkpoint] remove unsupported divergent-layout test
YLlllllllllll cf0b6ab
[optim, docs] document rank-local AdamW checkpoint adapters
YLlllllllllll 17f5903
[docs] fix SeedOmni runtime source anchors
YLlllllllllll 8884950
[checkpoint] verify legacy expert provenance across targets
YLlllllllllll 79309ef
Refresh remaining SeedOmni documentation links
YLlllllllllll f321d91
Mark optimizer adapter coverage as CPU-only
YLlllllllllll a2ca5eb
Fix AnyPrecision checkpoint state dtype and ownership
YLlllllllllll 7795c53
Mark extra parallel layout tests as CPU by default
YLlllllllllll dcc195d
Correct remaining SeedOmni documentation anchors
YLlllllllllll 5b11c02
Test asymmetric EP expert checkpoint recovery
YLlllllllllll 924e8ec
Reject mismatched trainer and optimizer checkpoints
YLlllllllllll c25cf3f
Document rank-local adapter and support nested Omni hooks
YLlllllllllll 13745a3
Ignore transient-only cache aliases in checkpoint identity
YLlllllllllll a38c191
Reject unproven dynamic RoPE checkpoint recovery
YLlllllllllll 6669054
Apply canonical checkpoint layout to Omni modules
YLlllllllllll 4ed0d45
Keep expert cold resume coverage on production checkpoint path
YLlllllllllll 1105150
Exercise EP checkpoint tests with fresh optimizer state
YLlllllllllll 01f6728
Merge main and preserve checkpoint layout precision
YLlllllllllll 6ba0494
Merge checkpoint layout fixes into FP32 optimizer
YLlllllllllll 2b7cdcd
Simplify checkpoint guards under trusted runtime contract
YLlllllllllll d9232af
Preserve lazy state under PyTorch DCP optimizer wrappers
YLlllllllllll c9aef75
Merge trusted checkpoint contract into CPU optimizer
YLlllllllllll 830f1fa
Merge lazy optimizer checkpoint fix
YLlllllllllll 9438e7a
Migrate optimizer CI fixtures to proven DCP recovery
YLlllllllllll e5902a5
Merge reviewer CI fixture fixes
YLlllllllllll c4050a0
[checkpoint] docs: classify multi-optimizer resume changes
YLlllllllllll 4e40d31
[checkpoint] fix: declare scheduler for proven resume
YLlllllllllll 77b63b1
Merge scheduler-safe checkpoint dependency
YLlllllllllll 09a428a
[checkpoint] fix: validate legacy expert sources
YLlllllllllll b48c9ec
Merge verified legacy expert checkpoint guards
YLlllllllllll 02f0753
[checkpoint] fix: keep export options keyword-only
YLlllllllllll 2e8c29e
Merge keyword-only checkpoint export options
YLlllllllllll f73d416
[checkpoint] allow trusted scheduler instrumentation
YLlllllllllll 1b95bce
[checkpoint] deduplicate step export and epoch save
YLlllllllllll 478ae4c
[checkpoint] prove EP1 source and simplify layout validation
YLlllllllllll 8ef9cfd
Merge commit '478ae4c3f' into HEAD
YLlllllllllll 830d625
[checkpoint] remove redundant leaf consensus checks
YLlllllllllll 43739c8
Merge commit '830d6254a9d44ddfdd865749e94415b5e729fa5b' into HEAD
YLlllllllllll 47401eb
[checkpoint] handle ENOSYS in legacy HF exports
YLlllllllllll bdc3f15
[checkpoint] preserve EP1 LoRA provenance during export
YLlllllllllll 1cb551d
[checkpoint] extend FUSE fallback to DCP LoRA export
YLlllllllllll 009e1a8
[test] cover LoRA FUSE fallback failures
YLlllllllllll 4f6a278
[docs] clarify collective legacy HF export
YLlllllllllll 2ae3848
[checkpoint] reuse proven MultiOptimizer export save
YLlllllllllll 749aee0
Merge proven MultiOptimizer export receipt
YLlllllllllll 462cdac
[test] preserve same-config RoPE failure coverage
YLlllllllllll e6df2c2
Merge same-config RoPE validator coverage
YLlllllllllll d18fd11
Reuse same-step exports across module checkpoint owners
YLlllllllllll eef3207
Merge multi-owner checkpoint cadence fixes
YLlllllllllll c917429
Reuse completed exports across empty epochs
YLlllllllllll bcfd462
Merge empty-epoch checkpoint reuse
YLlllllllllll 228c0af
Declare expert-only fixture without GDN layers
YLlllllllllll a267fae
Preserve proven checkpoint transactions after cold resume
YLlllllllllll e763f91
Merge commit 'a267fae88' into HEAD
YLlllllllllll 20219eb
Fail closed on checkpoint destination lookup errors
YLlllllllllll 1a7e153
Merge commit '20219eb20f969052df165801be5f83ccaffdc971' into HEAD
YLlllllllllll f3b4328
[checkpoint] remove unsupported rank-dependent fixture
YLlllllllllll c2098d5
Merge commit 'f3b43282e73f0d30bc743092f1383d5b0495c884' into HEAD
YLlllllllllll 8a4fbf0
[checkpoint] prove custom expert layouts and safe exports
YLlllllllllll 32871dd
[checkpoint] guard sparse and legacy extra-parallel states
YLlllllllllll ff5108b
[checkpoint] combine expert provenance with rank-local recovery
YLlllllllllll 9d1341d
[checkpoint] synchronize extra-parallel provenance guards
YLlllllllllll 612862f
[optimizer] integrate proven expert checkpoint layouts
YLlllllllllll 9385940
[checkpoint] remove counterfeit adapter fixture
YLlllllllllll a23284e
Merge commit '9385940c5230c301ec38e8b60dd065c164b05b75' into HEAD
YLlllllllllll 7d7d86d
[checkpoint] use consistent replica values in test
YLlllllllllll b482339
Merge commit '7d7d86db1861a38ea91d1c46f2cb3c77bc5bd722' into HEAD
YLlllllllllll 09481d3
Merge commit 'b482339bc5bb38a49872ddb20014ded238bdfc52' into HEAD
YLlllllllllll dbef082
[test] declare absent scheduler in expert cold test
YLlllllllllll 3745392
[checkpoint] keep configuration preflight local
YLlllllllllll c40f08d
[checkpoint] sync local config preflight
YLlllllllllll b4bc8a1
[docs] link optimizer adapter consumers and tests
YLlllllllllll 59abfa1
[docs] sync optimizer adapter links
YLlllllllllll 81c8bbe
[docs] link optimizer adapter context call sites
YLlllllllllll 0ef1fed
[docs] sync optimizer context references
YLlllllllllll 50c60ff
[checkpoint] defer dynamic RoPE checks to save and load
YLlllllllllll 98836e0
[checkpoint] reject unproven TP expert saves early
YLlllllllllll bf2a37f
[docs] clarify verified checkpoint migration wording
YLlllllllllll 8feba69
[test] cover replicated EP checkpoint preflight
YLlllllllllll 8a97fe9
[checkpoint] sync save preflight review fixes
YLlllllllllll 6d5f772
[docs] fix checkpoint manifest field link
YLlllllllllll 46bd970
[docs] sync manifest field reference
YLlllllllllll a50fdb6
[test] keep TP checkpoint checks within model contract
YLlllllllllll e2349e1
[test] sync TP preflight review changes
YLlllllllllll 3eef397
[checkpoint] test: enforce native preflight capacity
YLlllllllllll 7c8bb36
Merge /tmp/veomni-review-20261104/pr1397 into review-fix-pr1226
YLlllllllllll 366fa23
[checkpoint] prove TP FSDP source layouts
YLlllllllllll e3e3350
[test] remove preflight guard-only cases
YLlllllllllll 1768cca
[checkpoint] merge TP FSDP provenance guard
YLlllllllllll 95c690c
[checkpoint] sync source provenance and native preflight
YLlllllllllll 3e67bc4
[test] schedule TP provenance on its actual backend
YLlllllllllll 2ba4cf6
[test] derive checkpoint launch plans from geometry
YLlllllllllll d199b7e
Merge branch 'review-fix-pr1396' of /tmp/veomni-review-20261104/pr139…
YLlllllllllll c184c60
[test] sync checkpoint CI launch plans
YLlllllllllll 6dd9407
[test] fail assigned accelerator group shortages
YLlllllllllll ad518df
[test] fail assigned accelerator group shortages
YLlllllllllll 9be7026
[test] remove accelerator skip meta tests
YLlllllllllll 9454bb3
[test] remove accelerator skip meta tests
YLlllllllllll 4800b5e
[test] use CPU plan for expert layout tests
YLlllllllllll f6a449c
[test] use CPU plan for expert layout tests
YLlllllllllll 515d03c
[test] use CPU plan for expert layout tests
YLlllllllllll 845ccfd
[checkpoint, model] fix: preserve safe RoPE reset and dense layouts
YLlllllllllll 211f2a3
[checkpoint, model] fix: preserve safe RoPE reset and dense layouts
YLlllllllllll 0c9002d
[checkpoint] fix: bind dynamic RoPE table bytes on resume
YLlllllllllll b8ec343
[checkpoint] fix: bind dynamic RoPE table bytes on resume
YLlllllllllll 1a96e9b
[checkpoint] reject nonfinite RoPE tables without changing FP8 identity
YLlllllllllll dfe8326
[checkpoint] reject nonfinite RoPE tables and preserve FP8 identity
YLlllllllllll 80f61cf
[checkpoint] limit RoPE finiteness checks to supported types
YLlllllllllll f1b3e03
[checkpoint] document reserved runtime state keys
YLlllllllllll fa51d78
[checkpoint] limit RoPE finiteness checks to supported types
YLlllllllllll 13720ee
[checkpoint] document reserved runtime state keys
YLlllllllllll e4bdb9e
Merge upstream main and retain both feature paths
YLlllllllllll d075345
[docs] describe file-backed checkpoint abort hook
YLlllllllllll be924f2
Merge main and preserve extra-parallel CPU layouts
YLlllllllllll 34aa016
Merge main and guard expert offload checkpoint layouts
YLlllllllllll 8c97fbc
[checkpoint] unify scheduler identity validation
YLlllllllllll 230f18c
[checkpoint] Coordinate EP optimizer type preflight
YLlllllllllll ed055f7
[checkpoint] Coordinate optimizer type lookup errors
YLlllllllllll 3f7002e
[checkpoint] Coordinate EP preflight and align layouts
YLlllllllllll cccc1df
[checkpoint] Validate nested scheduler identity
YLlllllllllll ed21c45
Merge commit 'e6486d3847536d6a5cf72a433040914b69f1957d' into HEAD
YLlllllllllll d93e444
Merge commit 'ed21c456c' into HEAD
YLlllllllllll 6384c62
[checkpoint] fix standalone SwapAdamW recovery guards
YLlllllllllll 468d804
Merge commit '6384c62b1' into HEAD
YLlllllllllll 82fbfc9
[checkpoint] constrain scheduler identity to trusted runtime
YLlllllllllll be814f4
[checkpoint] fix: validate versioned expert ownership
YLlllllllllll 37b473e
[checkpoint] simplify extra-parallel optimizer preflight
YLlllllllllll 95d0855
[checkpoint] simplify extra-parallel optimizer preflight
YLlllllllllll 98709f3
[checkpoint] simplify trusted optimizer resume validation
YLlllllllllll a64fd96
[checkpoint] simplify multi-optimizer leaf coordination
YLlllllllllll 348d567
[checkpoint] support deterministic scheduler formatting
YLlllllllllll 8424b85
[checkpoint] support deterministic scheduler formatting
YLlllllllllll ec34eef
[docs] refresh checkpoint configuration references
YLlllllllllll da93122
[docs] fix checkpoint and offline cache anchors
YLlllllllllll 5a5520d
[test] fix SeedOmni offload config fixture
YLlllllllllll a656e43
[docs] fix checkpoint and offline cache anchors
YLlllllllllll 3d0b28e
[checkpoint] integrate canonical expert provenance
YLlllllllllll a2708c3
[test] retain historical checkpoint rejection coverage
YLlllllllllll 17b4bee
[checkpoint] sync canonical expert provenance
YLlllllllllll 340441f
[optim] preserve positional learning-rate compatibility
YLlllllllllll be8195a
[checkpoint] coordinate optimizer policy preflight
YLlllllllllll 82a1eec
[checkpoint] sync coordinated optimizer preflight
YLlllllllllll ada389b
Keep FUSE export coordination composable
YLlllllllllll a1ef83f
Bind FUSE adapter fallback independently of export flow
YLlllllllllll 1fefa13
fix: compose expert precision with parallel patch paths
YLlllllllllll 759e6fb
fix: coordinate cursor and optimizer checkpoint recovery
YLlllllllllll 78769c4
Merge commit '759e6fbc1a0132719d6b99a0b894c40cf2f50aef' into HEAD
YLlllllllllll ad278e3
ci: isolate selective expert test entries
YLlllllllllll ed45ea5
fix: coordinate invalid checkpoint snapshots
YLlllllllllll 6472d5b
Merge commit 'ed45ea520cb42bd562523ec80bfcc0c66817ede6' into HEAD
YLlllllllllll 9a8f1fe
fix: coordinate fatal optimizer generation failures
YLlllllllllll 28d2924
Merge commit '9a8f1fe3fc491d484e72897a79c3392da775ec23' into HEAD
YLlllllllllll 6f867fe
docs: clarify optimizer placement resume identity
YLlllllllllll 9e07fec
fix: keep adapter save import mergeable with GDN export
YLlllllllllll 4392697
fix: compose selective offload guard with optimizer setup
YLlllllllllll 8f1b7d3
test: run selective optimizer guard in existing CI suite
YLlllllllllll d03c6c3
Merge selective expert CPU offload with FP32 expert gradients
YLlllllllllll 2202497
Merge owner-aware checkpoint with selective expert offload
YLlllllllllll ef706d0
Merge optimizer precision and selective expert offload safely
YLlllllllllll 1b0f552
Clarify selective expert offload resume requirements
YLlllllllllll fa072c6
Merge offload documentation correction
YLlllllllllll 2f0012d
Synchronize offload documentation dependency
YLlllllllllll fdf88d1
Synchronize offload documentation dependency
YLlllllllllll 6d520d9
Initialize checkpoint manager config in failure fixture
YLlllllllllll b53d90c
Synchronize checkpoint fixture with cache configuration
YLlllllllllll 135f718
[docs] clarify legacy HF export collective
YLlllllllllll a47732c
[docs] clarify SeedOmni FP32 expert gradient scope
YLlllllllllll 5c2837c
[docs] clarify checkpoint resume and source links
YLlllllllllll 158d83e
[tests] fix: resolve checkpoint export CLI path
YLlllllllllll c051d9c
[checkpoint] clarify existing save destination
YLlllllllllll cfafa43
[test] guard invalid prefixed dynamic rope cache
YLlllllllllll e599980
[docs] align fp32 optimizer and runtime references
YLlllllllllll f111b91
[ci, tests] require assigned NPU and fix precision fixture
YLlllllllllll f222247
[checkpoint] bind model storage views for resume
YLlllllllllll 740b668
[ci, tests] require assigned NPU and fix precision fixture
YLlllllllllll b5a883b
[checkpoint] bind model storage views for resume
YLlllllllllll 276ad92
Merge remote-tracking branch 'upstream/main' into HEAD
YLlllllllllll 543ae79
Merge remote-tracking branch 'upstream/main' into HEAD
YLlllllllllll e63ffa5
Merge remote-tracking branch 'upstream/main' into HEAD
YLlllllllllll a502e9d
Merge proven MultiOptimizer checkpoint dependency
YLlllllllllll 25a42ab
Merge upstream main
YLlllllllllll 14e5e51
Merge upstream main
YLlllllllllll bdc4fcd
Merge upstream main and guard optimizer row masking
YLlllllllllll 37f5242
Align checkpoint prerequisite ancestry
YLlllllllllll 5926c99
[docs] fix HF export and cursor test anchors
YLlllllllllll 1687b82
[test] exercise checkpoint storage aliases on accelerators
YLlllllllllll 3ab98ca
Merge upstream MoE operator interface
YLlllllllllll efe34c2
Merge upstream checkpoint layouts and validate EP policy
YLlllllllllll f05a537
Normalize persistent shard axes in checkpoint preflight
YLlllllllllll e14b678
Check expert provenance before checkpoint overwrite
YLlllllllllll d3852e7
Merge split-layout checkpoint and model updates
YLlllllllllll 81ed593
Merge verified checkpoint provenance guards
YLlllllllllll ca843be
Merge NPU MoE precision interface coverage
YLlllllllllll 374dfb2
Merge current proven checkpoint recovery
YLlllllllllll 99ab50e
Refresh SeedOmni documentation source anchors
YLlllllllllll 7350de0
Merge main and protect HF adapter publication
YLlllllllllll 2ac0a21
Merge main while preserving NPU expert precision
YLlllllllllll 1daef50
Merge HF export and preserve canonical EP PLE layouts
YLlllllllllll a8f8824
Merge canonical EP PLE export with proven optimizer recovery
YLlllllllllll f227c1d
Merge NPU expert checkpoint safety updates
YLlllllllllll cebea11
Merge checkpoint recovery and fix optimizer integration
YLlllllllllll 2e2acdb
Bound merged expert weight copies during backward
YLlllllllllll 87f806b
Reject ambiguous optimizer instance serializers
YLlllllllllll 0fbb62b
Honor assigned NPU in expert precision tests
YLlllllllllll 33b9364
Respect the NPU test device lease
YLlllllllllll 2ca7be6
Merge expert rematerialization and retain device lease guards
YLlllllllllll a5d3c77
Check owned NPU capacity for distributed tests
YLlllllllllll 0abc35c
Sync native expert test lease guards
YLlllllllllll a8d49f7
Sync proven optimizer serialization and expert fixes
YLlllllllllll f6d7e5a
Bind scheduler checkpoint identity to declared recipes
YLlllllllllll 89a0560
Sync versioned scheduler recovery identities
YLlllllllllll a8b8f27
Assign CPU plan to canonical PLE checkpoint tests
YLlllllllllll f6b9f6c
Complete optimizer layout fixture for distributed preflight
YLlllllllllll 343c02c
Complete optimizer layout fixture for distributed preflight
YLlllllllllll 61222a8
Document custom checkpoint scheduler recipe contract
YLlllllllllll 61b9339
Use checkpoint converter under consistent model config
YLlllllllllll a0423f7
Reuse checkpoint load error coordination for row metadata
YLlllllllllll 9fa84fa
Use checkpoint converter under consistent model config
YLlllllllllll f333cb1
Use checkpoint converter under consistent model config
YLlllllllllll d6b4ab6
Document scheduler checkpoint consumers
YLlllllllllll e88ade0
Merge upstream gated MLP with expert precision support
YLlllllllllll fa7ef1e
Merge upstream and align checkpoint runtime contracts
YLlllllllllll ae131f7
Clarify unsupported model storage views
YLlllllllllll 5d5a7e2
Merge upstream and preserve optimizer checkpoint recovery
YLlllllllllll dc17e6d
Reject missing scheduler sidecars during training resume
YLlllllllllll 983faf7
Reject incomplete scheduler identity during optimizer resume
YLlllllllllll 7a4ae2c
Fix optimizer documentation source anchors
YLlllllllllll 865d5de
test: align checkpoint failure fixtures with CI contract
YLlllllllllll add3d66
Fix checkpoint documentation source anchors
YLlllllllllll 8a8ae7a
Fix checkpoint failure injection fixtures
YLlllllllllll 77043cd
Merge checkpoint recovery dependency
YLlllllllllll cd898b2
Fix checkpoint device test and documentation links
YLlllllllllll 9ed7716
Sync checkpoint test and documentation fixes
YLlllllllllll 6a111c7
Fix Float8 configuration documentation link
YLlllllllllll 7548aa9
Sync checkpoint documentation dependency
YLlllllllllll 0986dff
[model, ckpt] fix: align Janus weight source priority
YLlllllllllll a46acd1
[model, ops] fix: expand unsupported Ascend GDN head ratios
YLlllllllllll e349e38
[checkpoint] merge: align upstream model and resume safeguards
YLlllllllllll a3670d7
[checkpoint] merge: align HF source priority
YLlllllllllll d772a03
[checkpoint] merge: retain Ascend GDN ratio fallback
YLlllllllllll 09c471b
[docs] clarify Ascend GDN head expansion
YLlllllllllll 96bd7c5
[docs] merge: clarify Ascend GDN head expansion
YLlllllllllll 269143c
[optim] merge: preserve optimizer config compatibility
YLlllllllllll a29a30f
[optim] merge: sync foundation documentation
YLlllllllllll c94214f
[model] fix: sync standalone modeling with upstream main
YLlllllllllll a245081
[model, ops] fix: preserve precision contracts with per-site op selec…
YLlllllllllll 7aff1cb
[core] fix: reconcile upstream main with Qwen4 training support
YLlllllllllll 4164535
[test] fix: exercise checkpoint preflight with resolved accelerator c…
YLlllllllllll bf58e72
[test] fix: exercise checkpoint preflight with resolved accelerator c…
YLlllllllllll 82a37f8
[core] fix: reconcile upstream operator and checkpoint changes
YLlllllllllll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # Rank-local AdamW checkpoint adapters | ||
|
|
||
| `register_rank_local_adamw` is an internal extension point for an AdamW-like | ||
| optimizer whose master weights or moments must retain their own dtype or CPU | ||
| placement when restored through `MultiOptimizer` and `DistributedCheckpointer`. | ||
| It is not a generic optimizer plugin, a security boundary, or a conversion tool | ||
| for an incompatible checkpoint. Register trusted code only. | ||
|
|
||
| ## Registration and ownership | ||
|
|
||
| ```python | ||
| from contextlib import nullcontext | ||
|
|
||
| import torch | ||
|
|
||
| from veomni.optim.checkpoint_adapter import register_rank_local_adamw | ||
|
|
||
| # Illustrative callbacks for an AdamW-like optimizer that already implements | ||
| # precision-preserving state loading; MyAdamW is the application's own class. | ||
| register_rank_local_adamw( | ||
| MyAdamW, | ||
| context_factory=lambda optimizer: nullcontext(), | ||
| algorithm_identity=lambda optimizer: ("my-adamw-v1", str(optimizer.moment_dtype)), | ||
| state_dtype=lambda optimizer, param, field: ( | ||
| torch.float32 if field in ("step", "master_weight") else optimizer.moment_dtype | ||
| ), | ||
| state_is_offloaded=lambda optimizer, param: optimizer.is_offloaded(param), | ||
| ) | ||
| ``` | ||
|
|
||
| The registry is process-local and matches `type(optimizer)` **exactly**; | ||
| register each supported concrete optimizer type before saving or loading on | ||
| every rank. Duplicate registration raises an error. Registration does not make | ||
| an arbitrary optimizer compatible or automatically preserve its precision: the | ||
| optimizer and its adapter own the correctness of their serialization and load | ||
| behavior. `MasterFP32AdamW`, `FullFP32AdamW`, and `CPUOffloadAdamW` provide | ||
| concrete in-tree examples; the checkpoint adapter tests also contain an | ||
| illustrative registered implementation. | ||
|
|
||
| An initialized parameter entry must contain exactly `step`, `master_weight`, | ||
| `exp_avg`, and `exp_avg_sq`. The step is a rank-local plain scalar tensor, not | ||
| a scalar DTensor; the other fields have the parameter's shape. A parameter with | ||
| no optimizer state must stay absent, rather than receiving synthetic moments | ||
| or a synthetic step. The current adapter contract does not support additional | ||
| per-parameter fields. | ||
|
|
||
| ## Callback contract | ||
|
|
||
| | Callback | Signature and result | Responsibility | | ||
| | --- | --- | --- | | ||
| | `context_factory` | `context_factory(optimizer) -> context manager` | Entered while the framework obtains or applies that leaf optimizer's state. It may temporarily select an optimizer's supported serialization mode, but must expose the live initialized fields and group settings without mutating training state. On restore, it must allow the optimizer's loader to install the saved precision and placement without an implicit parameter-dtype cast. `nullcontext()` is sufficient only when the optimizer already has that behavior. | | ||
| | `algorithm_identity` | `algorithm_identity(optimizer) -> immutable value` | Describes non-group settings that change updates or restore semantics. Use `None`, booleans, integers, floats, strings, or tuples recursively composed of those types; encode dtypes as strings. Include an algorithm/schema version and all such settings. The checkpoint records this value and rejects a different identity on resume. Group settings and scheduler identity are checked separately. | | ||
| | `state_dtype` | `state_dtype(optimizer, param, field) -> torch.dtype` | Returns the expected stored dtype for each of `step`, `master_weight`, `exp_avg`, and `exp_avg_sq`, including when the state is not initialized yet. `step` describes the scalar dtype, not the moment dtype. The framework records the policy and validates existing and restored tensors against it; this callback does not cast tensors. | | ||
| | `state_is_offloaded` | `state_is_offloaded(optimizer, param) -> bool` | Reports whether that parameter's master and moment state belongs on CPU. The per-parameter policy is part of checkpoint identity and selects CPU versus parameter-device allocation during restoration. The scalar step follows the optimizer group's capturable/fused placement rules separately. | | ||
|
|
||
| Callbacks must be deterministic for the same training configuration and | ||
| stable across the save and load. `optimizer` is the live concrete leaf, and | ||
| `param` is a parameter owned by that leaf, possibly a DTensor. A fresh process | ||
| constructs new optimizer and parameter objects; callbacks must reconstruct the | ||
| same policies for them. Parameter ownership, optimizer group | ||
| membership, scheduler identity, state dtypes and offload selection must match | ||
| the saved checkpoint. Change these only with an explicitly verified migration. | ||
|
|
||
| ### Save and load call sites | ||
|
|
||
| [`_local_layout`](../../veomni/checkpoint/optimizer_resume_layout.py#L105) | ||
| records `algorithm_identity`, each parameter's `state_dtype`, and | ||
| `state_is_offloaded` in the checkpoint identity; a mismatch rejects resume | ||
| before applying state. During save, | ||
| [`_validate_source_optimizer_states`](../../veomni/checkpoint/multi_optimizer_checkpoint.py#L89) | ||
| uses `state_dtype` to check initialized fields against their declared precision. | ||
| During load, | ||
| [`_prepare_multi_optimizer_saved_states`](../../veomni/checkpoint/multi_optimizer_checkpoint.py#L408) | ||
| checks stored field dtypes and uses `state_is_offloaded` to allocate missing | ||
| destination state on CPU when the adapter specifies offload. | ||
| [`rank_local_adamw_context`](../../veomni/optim/checkpoint_adapter.py#L55) | ||
| uses `context_factory` around the optimizer's actual state read and load; | ||
| adapter implementations own correct placement and values. | ||
|
|
||
| The adapter contract tests include the | ||
| [`test_registered_optimizer_preserves_lazy_state_and_next_update`](../../tests/checkpoints/test_optimizer_checkpoint_adapter.py#L71) | ||
| round trip and the policy-mismatch checks | ||
| [`test_registered_optimizer_rejects_changed_algorithm_before_loading`](../../tests/checkpoints/test_optimizer_checkpoint_adapter.py#L114) | ||
| and | ||
| [`test_lazy_adapter_state_dtype_policy_is_part_of_checkpoint_identity`](../../tests/checkpoints/test_optimizer_checkpoint_adapter.py#L132). | ||
| The toy adapter in these tests reports no offload; actual device-to-CPU placement | ||
| must also be validated for an offloading implementation. | ||
|
|
||
| ## Framework call sites and restore behavior | ||
|
|
||
| 1. [`MultiOptimizer._sparse_state_dict()`](../../veomni/optim/optimizer.py#L565) | ||
| enters the context around PyTorch's | ||
| optimizer-state serialization. Registered adapter implementations must | ||
| preserve live state and serialize all initialized fields and group options | ||
| faithfully. State-empty leaves retain their parameter groups without | ||
| creating optimizer moments. | ||
| 2. Checkpoint layout construction records the algorithm identity, parameter | ||
| ownership, dtype policy and offload policy. Save validates the source state; | ||
| load checks the checkpoint's identity, field names, dtypes and shapes before | ||
| preparing initialized state for the saved owners. Rank-local ownership and | ||
| the supported parallel geometry are not automatically resharded. | ||
| 3. [`MultiOptimizer._dcp_load_state_dict()`](../../veomni/optim/optimizer.py#L603) | ||
| enters the context again while | ||
| PyTorch applies the optimizer state. The trusted adapter must restore every | ||
| validated field without changing its value or dtype. An optimizer may | ||
| implement its own precision-preserving loader; the adapter callbacks alone | ||
| do not repair a lossy one. | ||
|
|
||
| The currently supported exact-precision training-checkpoint path requires | ||
| `MultiOptimizer` and synchronous `DistributedCheckpointer` save/load. | ||
| `MultiOptimizer.load_state_dict()` and raw DCP `OptimizerState` reject | ||
| unproven recovery; an individual leaf's direct `load_state_dict()` cannot prove | ||
| the MultiOptimizer group, scheduler and generation identity. Unverified older | ||
| group layouts and changing the rank-local layout | ||
| require an explicit verified migration or fail closed. See | ||
| [MultiOptimizer recovery identity](../usage/checkpoint.md#multioptimizer-recovery-identity) | ||
| for the complete recovery constraints. Test an extension with initialized and | ||
| unused parameters, save, fresh-process restore, and the next update at its | ||
| actual dtype and placement; an adapter registration or a single forward pass | ||
| is not an acceptance test. | ||
|
|
||
| ## Optional file-backed state abort hook | ||
|
|
||
| An optimizer that owns file-backed state may provide the zero-argument | ||
| `checkpoint_abort_file_backed_state()` hook. If the final distributed barrier | ||
| in `ModelCheckpointManager.load()` fails after loading state, the manager | ||
| calls this hook on the optimizer and on each `MultiOptimizer` leaf that defines | ||
| it. The hook owns its optimizer's cleanup or invalidation: it should make any | ||
| partially restored file-backed state unusable until the optimizer is rebuilt | ||
| or explicitly recovered. It must not perform collectives and should be safe | ||
| to call more than once. The manager ignores ordinary cleanup exceptions so the | ||
| original barrier failure is propagated; it does not report the checkpoint as | ||
| successfully loaded. Optimizers without file-backed state need no hook. | ||
|
|
||
| The manager calls this hook only on its final-barrier failure path; it is not a | ||
| general notification for every earlier load error. File-backed optimizers and | ||
| checkpointers remain responsible for cleanup at their own failure sites. | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The adapter guide's links at lines 66, 70, 73, 91 and 102 now land on unrelated code after integration. Refresh them to the current definitions or context call sites so adapter implementers can trace state placement and restore behavior. The current definitions start at lines 170, 121, 466, 570 and 624 in their respective files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The five adapter-guide anchors now resolve correctly. F026 remains open for the SeedOmni links:
metric_meter.mdstill targets collection at 590 and meter save/restore at 142/300, while the current locations are 608 and 253/496. Please also refresh the remaininghf_layout.mdandoffline_encoding.mdlinks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The metric-meter and HF-layout anchors are repaired. Two links remain stale: the adapter guide targets
_local_layoutat 177, now an import (definition 171), andoffline_encoding.md:356targets test 417 instead of the cache-reader test at 440. Please update both targets.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in da93122: both links now point to the intended definitions. The same docs-only corrections were also synchronized to the dependent branches; no optimizer or training code changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The parallelizer link is repaired, but scheduler cleanup moved
_local_layoutto line 143 while this guide still targets 232._prepare_multi_optimizer_saved_states,_sparse_state_dict, and_dcp_load_state_dictnow start at 486, 589, and 640. Refresh these anchors and the selective-offload runtime link so extension authors reach the intended definitions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The latest integration moved
Float8TrainingConfigto line 643, but this link still targets line 627 insideTorchCompileConfig. Update the anchor to#L643so readers reach the configuration definition.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The new base integration moved
attach_hf_source_converterandsave_hf_source_checkpointto lines 615 and 883, but these links still target 587 and 854. Other HF-layout links and the offline-cache test links also shifted. Refresh the affected anchors so readers reach the named implementation and regressions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The HF-layout and offline-cache test links now target the current definitions, including
attach_hf_source_converterat 615 andsave_hf_source_checkpointat 883. The stale Float8 link disappeared with removal of the old page and configuration. The previously reported anchor defects are fixed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The new base integration shifted these links again:
_sparse_state_dictand_dcp_load_state_dictare at 580/630, but the guide targets 575/625. The selective-offload guide also targets 480/437 instead of 511/558. Refresh these and the shifted SeedOmni anchors so readers reach the named code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] The adapter, offload and metric-meter links are repaired.
offline_encoding.mdstill points its cache-reader return, offline-embedding freeze and frozen-module checkpoint links to 164/175/666; those behaviors are now at 204–205/207–209/705–715 inomni_module_runtime.py. Refresh these remaining targets.