Skip to content

Conversation

@liangel-02
Copy link
Contributor

@liangel-02 liangel-02 commented Nov 5, 2025

Summary

Previously, our safetensors implementation for tensor subclasses didn't consider the possibility of different tensor attributes for one instance of a tensor subclass (ie qdata or scale for Float8Tensor) being sharded to different files.

This PR handles that case by:

  1. Defining the state dict outside of the loop that iterates through shard files
  2. After processing a full tensor subclass in unflatten_tensor_state_dict, we delete the corresponding tensor attributes (ie qdata, scale) from the original state dict passed in
  3. Whatever is remaining is saved in the state dict for the next iteration

Testing
pytest tests/quantization/test_torchao.py::test_safetensors_model_loading_with_params -s

@liangel-02 liangel-02 force-pushed the torchao-safetensors branch 3 times, most recently from 1189efe to 91a71f1 Compare November 6, 2025 16:22
@liangel-02 liangel-02 marked this pull request as ready for review November 6, 2025 16:32


@pytest.mark.skipif(not TORCHAO_AVAILABLE, reason="torchao is not available")
@pytest.mark.skip(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to skip now that torch2.9 is released?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we still need to skip since this test depends on changes in torchao main cc @jerryzh168

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we need a separate update to upgrade the torchao version used in testing in vllm:

- uv pip install --system torchao==0.13.0

and make sure the tests are passing

@liangel-02 liangel-02 force-pushed the torchao-safetensors branch 2 times, most recently from a27f7af to 428de94 Compare November 7, 2025 19:52
Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@heheda12345 heheda12345 enabled auto-merge (squash) November 11, 2025 05:27
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 11, 2025
auto-merge was automatically disabled November 12, 2025 18:34

Head branch was pushed to by a user without write access

@liangel-02 liangel-02 force-pushed the torchao-safetensors branch 4 times, most recently from 3de2e14 to ffcf29c Compare November 14, 2025 20:36
@liangel-02
Copy link
Contributor Author

@heheda12345 can you pls merge? thanks!

@heheda12345 heheda12345 enabled auto-merge (squash) November 17, 2025 22:25
@heheda12345
Copy link
Collaborator

Of course! I'm retrying failed test.

auto-merge was automatically disabled November 18, 2025 22:56

Head branch was pushed to by a user without write access

@mergify
Copy link

mergify bot commented Nov 19, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @liangel-02.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Nov 19, 2025
Signed-off-by: Angel Li <liangel@meta.com>
Signed-off-by: Angel Li <liangel@meta.com>
@liangel-02
Copy link
Contributor Author

@heheda12345 a rebase seems to have fixed ci, can u help me merge ty!

@heheda12345 heheda12345 merged commit 1d64287 into vllm-project:main Nov 20, 2025
44 checks passed
@heheda12345
Copy link
Collaborator

Merged. Thanks!

Victor49152 pushed a commit to Victor49152/vllm that referenced this pull request Nov 20, 2025
Signed-off-by: Angel Li <liangel@meta.com>
LuminolT pushed a commit to LuminolT/vllm that referenced this pull request Nov 21, 2025
Signed-off-by: Angel Li <liangel@meta.com>
Signed-off-by: LuminolT <lumischen01@gmail.com>
RunkaiTao pushed a commit to RunkaiTao/vllm that referenced this pull request Nov 24, 2025
Signed-off-by: Angel Li <liangel@meta.com>
Signed-off-by: Runkai Tao <rt572@physics.rutgers.edu>
bigPYJ1151 pushed a commit that referenced this pull request Nov 25, 2025
Signed-off-by: Angel Li <liangel@meta.com>
Signed-off-by: jiang1.li <jiang1.li@intel.com>
bringlein pushed a commit to bringlein/vllm that referenced this pull request Nov 26, 2025
Signed-off-by: Angel Li <liangel@meta.com>
devpatelio pushed a commit to SumanthRH/vllm that referenced this pull request Nov 29, 2025
Signed-off-by: Angel Li <liangel@meta.com>
kitaekatt pushed a commit to kitaekatt/vllm that referenced this pull request Dec 1, 2025
Signed-off-by: Angel Li <liangel@meta.com>
charlotte12l pushed a commit to charlotte12l/vllm that referenced this pull request Dec 5, 2025
Signed-off-by: Angel Li <liangel@meta.com>
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants