Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jerryzh168
Copy link
Contributor

@jerryzh168 jerryzh168 commented May 6, 2025

Summary:
slice op is supposed to preserve aliasing (output of slice should alias the input), but this is not true for TensorCoreTiledLayout (used by int4wo), and some others like gemlite

Reason is that we do unpacking, pading and prepacking right now, which creates new tensors.

We fixes it in this PR by doing slicing on the packed inner Tensor directly, specifically packed_weight and scale_and_zero in TensorCoreTiledLayout.

Test Plan:
python test/dtypes/test_affine_quantized.py -k test_slice_and_copy_int4wo

Reviewers:

Subscribers:

Tasks:

Tags:

  • simplify code

  • add check for data_ptr

  • format

  • avoid div by zero

  • format

…out (#2174)

Summary:
slice op is supposed to preserve aliasing (output of slice should alias the input),
but this is not true for TensorCoreTiledLayout (used by int4wo), and some others like gemlite

Reason is that we do unpacking, pading and prepacking right now, which creates new tensors.

We fixes it in this PR by doing slicing on the packed inner Tensor directly, specifically packed_weight and scale_and_zero
in TensorCoreTiledLayout.

Test Plan:
python test/dtypes/test_affine_quantized.py -k test_slice_and_copy_int4wo

Reviewers:

Subscribers:

Tasks:

Tags:

* simplify code

* add check for data_ptr

* format

* avoid div by zero

* format
@pytorch-bot pytorch-bot bot added the ci-no-td label May 6, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented May 6, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

⏳ No Failures, 4 Pending

As of commit 1707c6b with merge base a83636d (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 May 6, 2025
@jerryzh168 jerryzh168 changed the title [reland] Fixing aliasing behavior for slice in AQT TensorCoreTiledLay… [reland] Fixing aliasing behavior for slice in AQT int4wo layout May 6, 2025
@jerryzh168 jerryzh168 added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label May 6, 2025
@jerryzh168 jerryzh168 merged commit 07ca637 into main May 6, 2025
18 checks passed
liangel-02 pushed a commit that referenced this pull request Aug 25, 2025
* [reland] Fixing aliasing behavior for slice in AQT TensorCoreTiledLayout (#2174)

Summary:
slice op is supposed to preserve aliasing (output of slice should alias the input),
but this is not true for TensorCoreTiledLayout (used by int4wo), and some others like gemlite

Reason is that we do unpacking, pading and prepacking right now, which creates new tensors.

We fixes it in this PR by doing slicing on the packed inner Tensor directly, specifically packed_weight and scale_and_zero
in TensorCoreTiledLayout.

Test Plan:
python test/dtypes/test_affine_quantized.py -k test_slice_and_copy_int4wo

Reviewers:

Subscribers:

Tasks:

Tags:

* simplify code

* add check for data_ptr

* format

* avoid div by zero

* format

* fix shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing Use this tag if you don't want this PR to show up in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants