Skip to content

add gptq benchmark, and speed up by ~3x with compile#4310

Merged
vkuzo merged 15 commits intomainfrom
gh/vkuzo/250/head
Apr 23, 2026
Merged

add gptq benchmark, and speed up by ~3x with compile#4310
vkuzo merged 15 commits intomainfrom
gh/vkuzo/250/head

Conversation

@vkuzo
Copy link
Copy Markdown
Contributor

@vkuzo vkuzo commented Apr 21, 2026

Summary:

  1. add gptq algo benchmark
  2. capture a profiling run - two main issues, (a) the to_nvfp4 kernels and
    (b) the hessian + weight updates
  3. speed up (a) significantly by using torch.compile, we need to
    ensure to enable TORCHINDUCTOR_EMULATE_DIVISION_ROUNDING to keep
    parity with eager mode. Note there are significant accuracy
    regressions without this set (small differences accumulate with each
    incremental hessian + weight update), so we force it on by default.

e2e gptq run on LLaMa 3.2 1B speeds up by ~2.5x (172 seconds -> 69 seconds) with no change in accuracy:

time torchao/prototype/gptq/gptq_nvfp4_llama3_2_1b_nonsequential_wikitext.sh 2>&1 | tee ~/tmp/20260421_gptq_run_compile.txt
// logs: https://gist.github.com/vkuzo/4ebd0bfa71185b711b19c712216eae29

Test Plan:

vkuzo added 10 commits April 20, 2026 20:52
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@vkuzo vkuzo requested a review from jerryzh168 as a code owner April 21, 2026 18:31
@vkuzo
Copy link
Copy Markdown
Contributor Author

vkuzo commented Apr 21, 2026

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 21, 2026

🔗 Helpful Links

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

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:

❌ 1 New Failure

As of commit d302888 with merge base 1b04df3 (image):

NEW FAILURE - The following job has failed:

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 Apr 21, 2026
@vkuzo vkuzo added the module: not user facing Use this tag if you don't want this PR to show up in release notes label Apr 21, 2026
vkuzo added a commit that referenced this pull request Apr 21, 2026
Summary:

1. add gptq algo benchmark
2. capture a profiling run - two main issues, (a) the to_nvfp4 kernels and
   (b) the hessian + weight updates
3. speed up (a) significantly by using `torch.compile`, we need to
   ensure to enable `TORCHINDUCTOR_EMULATE_DIVISION_ROUNDING` to keep
   parity with eager mode. Note there are significant accuracy
   regressions without this set (small differences accumulate with each
   incremental hessian + weight update), so we force it on by default.

e2e gptq run on LLaMa 3.2 1B speeds up by ~2.5x (172 seconds -> 69 seconds) with no change in accuracy:

```
time torchao/prototype/gptq/gptq_nvfp4_llama3_2_1b_nonsequential_wikitext.sh 2>&1 | tee ~/tmp/20260421_gptq_run_compile.txt
// logs: https://gist.github.com/vkuzo/4ebd0bfa71185b711b19c712216eae29
```

Test Plan:
ghstack-source-id: e73e550
ghstack-comment-id: 4290904117
Pull-Request: #4310
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Apr 21, 2026
Summary:

1. add gptq algo benchmark
2. capture a profiling run - two main issues, (a) the to_nvfp4 kernels and
   (b) the hessian + weight updates
3. speed up (a) significantly by using `torch.compile`, we need to
   ensure to enable `TORCHINDUCTOR_EMULATE_DIVISION_ROUNDING` to keep
   parity with eager mode. Note there are significant accuracy
   regressions without this set (small differences accumulate with each
   incremental hessian + weight update), so we force it on by default.

e2e gptq run on LLaMa 3.2 1B speeds up by ~2.5x (172 seconds -> 69 seconds) with no change in accuracy:

```
time torchao/prototype/gptq/gptq_nvfp4_llama3_2_1b_nonsequential_wikitext.sh 2>&1 | tee ~/tmp/20260421_gptq_run_compile.txt
// logs: https://gist.github.com/vkuzo/4ebd0bfa71185b711b19c712216eae29
```

Test Plan:
ghstack-source-id: 8b4b52c
ghstack-comment-id: 4290904117
Pull-Request: #4310
[ghstack-poisoned]
vkuzo added 3 commits April 22, 2026 11:24
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@vkuzo vkuzo changed the base branch from gh/vkuzo/249/head to main April 22, 2026 11:25
@vkuzo vkuzo merged commit b49d8cb into main Apr 23, 2026
50 of 53 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. module: 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