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

Skip to content

Conversation

@jerryzh168
Copy link
Contributor

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:

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:
@pytorch-bot
Copy link

pytorch-bot bot commented May 5, 2025

🔗 Helpful Links

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

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, 6 Pending

As of commit 2fb26de with merge base 94e2e05 (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 5, 2025
@jerryzh168 jerryzh168 requested review from bdhirsh, drisspg and mobicham May 5, 2025 22:49
@jerryzh168 jerryzh168 added the topic: bug fix Use this tag for PRs that fix bugs label May 5, 2025
@jerryzh168 jerryzh168 merged commit 95119bb into main May 6, 2025
14 of 18 checks passed
jerryzh168 added a commit that referenced this pull request May 6, 2025
jerryzh168 added a commit that referenced this pull request May 6, 2025
…ut" (#2175)

Revert "Fixing aliasing behavior for slice in AQT TensorCoreTiledLayout (#2174)"

This reverts commit 95119bb.
jerryzh168 added a commit that referenced this pull request May 6, 2025
…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
jerryzh168 added a commit that referenced this pull request May 6, 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
liangel-02 pushed a commit that referenced this pull request Aug 25, 2025
* Fixing aliasing behavior for slice in AQT TensorCoreTiledLayout

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
liangel-02 pushed a commit that referenced this pull request Aug 25, 2025
…ut" (#2175)

Revert "Fixing aliasing behavior for slice in AQT TensorCoreTiledLayout (#2174)"

This reverts commit 95119bb.
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

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: bug fix Use this tag for PRs that fix bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants