Skip to content
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

Fix dimension issues for int4 weight only quant path #330

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

jerryzh168
Copy link
Contributor

@jerryzh168 jerryzh168 commented Jun 6, 2024

Summary:
Currently the accepted dimension of _quantized_linear is not clear, this PR fixes the issue.

Currently the "tensor_core_tiled" layout tensor does not do repacking in view operation, which is incorrect, this PR removes the view support (which is not needed right now), and restrict the use case to transpose op, and records the transpose status of the tensor instead of doing repacking for performance.

Test Plan:
python test/quantization/test_quant_api.py
python test/integration/test_integration.py

TORCH_LOGS='output_code' python tutorials/quantize_vit/run_vit_b_quant.py

Reviewers:

Subscribers:

Tasks:

Tags:

@jerryzh168 jerryzh168 requested a review from HDCharles June 6, 2024 18:20
Copy link

pytorch-bot bot commented Jun 6, 2024

🔗 Helpful Links

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

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

As of commit 0732101 with merge base e2196fd (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 Jun 6, 2024
@jerryzh168 jerryzh168 requested review from cpuhrsch and msaroufim June 6, 2024 18:21
@HDCharles
Copy link
Contributor

HDCharles commented Jun 6, 2024

why did you change teh name to transpose change shape? it doesn't have anything to do with the transpose handling, it just changes teh external shape.

@jerryzh168
Copy link
Contributor Author

why did you change teh name to transpose change shape? it doesn't have anything to do with the transpose handling, it just changes teh external shape.

it's not a general _change_shape, since it only makes sense with transpose dimension I think? otherwise we need to unpack and repack the packed weight

Copy link
Contributor

@cpuhrsch cpuhrsch left a comment

Choose a reason for hiding this comment

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

I'd also like to suggest some unit tests for aqt eventually. They're actually quite easy to write for shape operations, because a dtype has no influence on the change in shape.

That means you can do self.assertEqual(fn(t).shape, fn(to_aqt(t)).shape).

We also have OpInfos and such that could be used here. For example, some tests might easily translate, just with different tolerances due to decreased bit width.

@jerryzh168
Copy link
Contributor Author

I'd also like to suggest some unit tests for aqt eventually. They're actually quite easy to write for shape operations, because a dtype has no influence on the change in shape.

That means you can do self.assertEqual(fn(t).shape, fn(to_aqt(t)).shape).

We also have OpInfos and such that could be used here. For example, some tests might easily translate, just with different tolerances due to decreased bit width.

yeah sure, I was thinking of adding some tests for aqt afterwards, but I can start with transpose

@jerryzh168 jerryzh168 force-pushed the fix-int4-dim branch 4 times, most recently from 6e07180 to c0600c2 Compare June 7, 2024 03:03
Summary:
Currently the accepted dimension of _quantized_linear is not clear, this PR fixes the issue.

Currently the "tensor_core_tiled" layout tensor does not do repacking in view operation, which is incorrect, this PR removes the view support (which is not needed right now), and restrict the use case to transpose op, and records the transpose status of the tensor instead of doing repacking for performance.

Test Plan:
python test/quantization/test_quant_api.py
python test/integration/test_integration.py

Reviewers:

Subscribers:

Tasks:

Tags:
@jerryzh168
Copy link
Contributor Author

why did you change teh name to transpose change shape? it doesn't have anything to do with the transpose handling, it just changes teh external shape.

OK removed the function since it's a bit confusing, we can add back later if needed. I understand it's just changing the external shape without touching the internal data representation now.

@msaroufim msaroufim removed their request for review June 9, 2024 17:21
@msaroufim
Copy link
Member

@HDCharles mind reviewing this, one more time?

@jerryzh168 jerryzh168 requested review from msaroufim and removed request for msaroufim June 10, 2024 17:05
@jerryzh168 jerryzh168 merged commit 79f2c7f into pytorch:main Jun 10, 2024
13 checks passed
dbyoung18 pushed a commit to dbyoung18/ao that referenced this pull request Jul 31, 2024
Summary:
Currently the accepted dimension of _quantized_linear is not clear, this PR fixes the issue.

Currently the "tensor_core_tiled" layout tensor does not do repacking in view operation, which is incorrect, this PR removes the view support (which is not needed right now), and restrict the use case to transpose op, and records the transpose status of the tensor instead of doing repacking for performance.

Test Plan:
python test/quantization/test_quant_api.py
python test/integration/test_integration.py

Reviewers:

Subscribers:

Tasks:

Tags:
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants