[codex] DSv4: derive config from HF + legacy-load + exporter DTensor materialize#65
Draft
Meirtz wants to merge 1 commit into
Draft
[codex] DSv4: derive config from HF + legacy-load + exporter DTensor materialize#65Meirtz wants to merge 1 commit into
Meirtz wants to merge 1 commit into
Conversation
…aterialize Safe load/save-correctness split from the DSv4 load/train work. Excludes the mHC numeric change (parity-gated) and the dispatcher hash-routing change (golden-changing), which ship separately. - config.py: derive compress_ratios from layer_types/compress_rates and num_hash_layers from mlp_layer_types; parse nested rope_parameters (main/compress); add hc_eps/ rms_norm_eps fields and an untied-embeddings guard. - checkpoint.py: accept legacy model-rooted HF expert/attention/compressor key aliases on load; fix the expert-name double-dot (mlp.experts..N -> mlp.experts.N). - ckpt/hf_weights.py: materialize DTensor params to local cpu contiguous before safetensors save (avoids silent FSDP2-shard truncation on export). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Lingrui Mei <lmei@nvidia.com>
Owner
|
why do we need so many |
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.
Summary
The load/save-correctness half of the DSv4
load-trainwork, split out so it can landwithout the parts that change forward numerics. Three files, all additive/correctness:
config.py: derivecompress_ratiosfromlayer_types/compress_ratesandnum_hash_layersfrommlp_layer_types; parse nestedrope_parameters(main/compress);add
hc_eps/rms_norm_epsfields and an untied-embeddings guard. (Current code leavescompress_ratios=[]/num_hash_layers=3defaulted, which is wrong for realDeepSeek-V4-Flash configs.)
checkpoint.py: accept legacy model-rooted HF key aliases (expert/attention/compressor)on load; fix the expert-name double-dot (
mlp.experts..N→mlp.experts.N).ckpt/hf_weights.py: materialize DTensor params to local cpu-contiguous beforesafetensors save — avoids silent FSDP2-shard truncation on export.
Intentionally excluded (ship separately)
hca.py/mhc.py+ model call-sites) — changes DSv4 forward numericsvs the current golden; needs an HF-parity gate first (per the
basic.constitutionno-referencerule, same bar as fix(deepseek_v4): scale MTP aux-loss gradient via pre_forward_hook #56/ds4 (deepseek_v4): DSA indexer aux-loss scale hook + lift forced CP=1 (MTP/dense-CSA support CP>1) #59). Separate PR.
scatter_add_hash-routing parity — correctness toward HF but changes hash-layergolden; separate PR + golden refresh.
Validation status
py_compileclean; verified no references to the excluded mHC/dispatcher code.unit run (toy DSv4 load/export round-trip).