Repository navigation
Support root parameters in safetensors state dictionaries - #4990
AaravMehta-07 wants to merge 1 commit into
Conversation
Share prefix construction between flattening and reconstruction while preserving nested names. Cover real CPU plain/Int8 round trips, forward equivalence and deferred shard loading. Co-authored-by: OpenAI Codex Signed-off-by: Aarav <211792885+AaravMehta-07@users.noreply.github.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4990
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @AaravMehta-07! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
Support root-level parameter names in the safetensors flatten/unflatten helpers.
A standalone
nn.Linearhas state-dict keysweightandbias, rather than0.weightand0.bias. Today, unflattening even its ordinary tensors raisesValueErrorwhile splitting the name. After Int8 quantization, flattening fails earlier withIndexErrorfor the same assumption.Use one prefix helper based on
rpartitionfor both directions. Root subclass components become_weight_qdata,_weight_scale, etc.; existing nested component names such as0._weight_qdataremain unchanged.Add CPU regressions using real safetensors files, plain and Int8-quantized
Linearmodels, root and nested names, restored forward outputs, and deferred reconstruction of incomplete quantized shards. No dependency or quantization-kernel changes.Validation
ValueError/IndexError); 4 nested compatibility cases passed.python -m pytest test/prototype/safetensors -q: 8 passed, 31 skipped. The existing GPU-gated tests skipped because this machine has no CUDA/XPU; no new skips were added.git diff --checkpassed.Int8WeightOnlyConfig(version=2)tensors and their CPU forward operations were exercised. Existing import-time enum registration and test-collection TorchScript deprecation warnings occurred.The full suite, GPU formats, native extensions, and hardware performance were not validated. Any required CLA remains for the submitting human to accept; no CLA acceptance is asserted here.
AI assistance (Codex) was used for investigation, implementation, regression tests, and validation.