[Bug]: Support parameters sharding across safetensors
System Info
NA
Who can help?
No response
Information
- [ ] The official example scripts
- [ ] My own modified scripts
Tasks
- [ ] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below)
Reproduction
use HF model that has sharded params. for example nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-NVFP4.
Expected behavior
linear op params should be initialized correctly
actual behavior
linear op params aren't initialized correctly
additional notes
When AD deals with quantized here it expects all parameters to be available in the same state_dict. when a linear op's params are sharded across safetensors, this means the condition isn't triggered, and the params for that linear aren't initialized.
Need to make the load_hook robust to these kind of scenearios
Before submitting a new issue...
- [x] Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
Hi, I'd like to work on this issue if the maintainers agree with the scope.
I reproduced the shard-boundary failure on current main (602718366c40e7078cec1d520c531a4fd119ccc2) using the real accelerate.load_checkpoint_in_model(..., full_state_dict=False) path and a tiny CPU-only safetensors fixture. Environment: macOS arm64, Python 3.11.15, PyTorch 2.12.1, Accelerate 1.14.0, safetensors 0.8.0.
The fixture isolates the key-co-presence contract used by the current AutoDeploy NVFP4 load hook:
| checkpoint layout | complete hook calls | resulting alpha | resulting input scale |
|---|---|---|---|
| one safetensors file | 1 | 6.0 | 0.5 |
| sharded, all logical linear keys co-located | 1 | 6.0 | 0.5 |
| sharded between weight and scale keys | 0 | -1.0 (sentinel) | 2.0 (not inverted) |
In the failing layout the two hook invocations receive these disjoint key sets:
[linear.weight]
[linear.input_scale, linear.weight_scale, linear.weight_scale_2]
This confirms that the current all-required-keys condition can never become true when Accelerate processes the two shards independently. The full-file and co-located-shard controls pass in three consecutive repetitions.
My proposed narrow scope is:
- preserve the low-memory
disable_preload=Truebehavior rather than assembling the complete checkpoint on CPU; - make loading of one logical quantized-linear parameter group robust to physical safetensor shard boundaries;
- add a tiny synthetic sharded-checkpoint regression covering co-located, cross-cut, and missing-key cases, without downloading a model;
- keep the public API unchanged and document GPU/model validation as an upstream follow-up, separate from the CPU loading-contract test.
Could a TensorRT-LLM engineer confirm that this direction is acceptable and that the issue is available for an external contribution before I implement it?