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

Skip to content

[CPU] fix _weight_int8pack_mm with large output shape #158341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Xia-Weiwen
Copy link
Collaborator

@Xia-Weiwen Xia-Weiwen commented Jul 15, 2025

Summary
_weight_int8pack_mm on CPU may cause segmentation fault if output shape is large (i.e., M * N is large). It's because the kernel compute output buffer address by

auto* C_ptr = C_data + mb_start * N + nb_start;

where both mb_start and N are int and when they are large their product may overflow.
The solution is simple: declare these variables as int64_t so that the product won't overflow.

Test plan

pytest -sv test/test_linalg.py -k test__int8_mm_large_shape

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @jerryzh168

Copy link

pytorch-bot bot commented Jul 15, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit eeb0d08 with merge base a5e6881 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

@pytorch-bot pytorch-bot bot added module: cpu CPU specific problem (e.g., perf, algorithm) release notes: linalg_frontend release notes category labels Jul 15, 2025
@Xia-Weiwen Xia-Weiwen added the intel This tag is for PR from Intel label Jul 15, 2025
@Xia-Weiwen Xia-Weiwen requested a review from mingfeima July 16, 2025 01:16
@Xia-Weiwen Xia-Weiwen requested a review from mingfeima July 16, 2025 01:33
@Xia-Weiwen Xia-Weiwen marked this pull request as ready for review July 16, 2025 01:53
@Xia-Weiwen
Copy link
Collaborator Author

Hi @lezcano @nikitaved @IvanYashchuk Could you please review this PR since you are code owners? Thanks

@Xia-Weiwen
Copy link
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 18, 2025
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • superuser (pytorch/metamates)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10, ...)
  • Core Maintainers (soumith, gchanan, ezyang, dzhulgakov, malfet, ...)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request intel This tag is for PR from Intel module: cpu CPU specific problem (e.g., perf, algorithm) open source release notes: linalg_frontend release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants