Skip to content

Conversation

jerryzh168
Copy link
Contributor

Summary:
Added a classmethod from_int4_tensor to convert a plain Int4Tensor to Int4PreshuffledTensor

This is in preparation for supporting Int4PreshuffledTensor in vllm, which requires the tensor to be sliced before inference, see

def _test_slice_and_copy_similar_to_vllm(self, config):
for details

but Int4PreshuffledTensor can't be easiliy sliced while also preserving alias, so we plan to slice the Plain int4 tensor instead and then convert to Int4PreshuffledTensor at a later stage.

Next PR is going to add a top level API in prototype to convert from int4 tensor to int4 preshuffled tensor

Test Plan:
python test/quantization/quantize_/workflows/int4/test_int4_preshuffled_tensor.py -k test_from_int4_tensor

Reviewers:

Subscribers:

Tasks:

Tags:

Summary:
Added a classmethod `from_int4_tensor` to convert a plain `Int4Tensor` to `Int4PreshuffledTensor`

This is in preparation for supporting Int4PreshuffledTensor in vllm, which requires the tensor to be sliced before inference,
see https://github.com/pytorch/ao/blob/186aeb01664687d14108ada420c475cc783e1643/torchao/testing/utils.py#L429 for details

but Int4PreshuffledTensor can't be easiliy sliced while also preserving alias, so we plan to slice the Plain int4 tensor
instead and then convert to Int4PreshuffledTensor at a later stage.

Next PR is going to add a top level API in prototype to convert from int4 tensor to int4 preshuffled tensor

Test Plan:
python test/quantization/quantize_/workflows/int4/test_int4_preshuffled_tensor.py -k test_from_int4_tensor

Reviewers:

Subscribers:

Tasks:

Tags:
Copy link

pytorch-bot bot commented Sep 11, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2978

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 22e0acb with merge base 186aeb0 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 11, 2025
@jerryzh168 jerryzh168 added the topic: new feature Use this tag if this PR adds a new feature label Sep 11, 2025
@jerryzh168 jerryzh168 merged commit cffba61 into pytorch:main Sep 11, 2025
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: new feature Use this tag if this PR adds a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants