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

Extract eval code from GPTQ for more general usage #275

Merged
merged 1 commit into from
May 28, 2024
Merged

Extract eval code from GPTQ for more general usage #275

merged 1 commit into from
May 28, 2024

Conversation

andrewor14
Copy link
Contributor

Summary: This commit extracts all the eval code from GPTQ.py. This is the first step towards having a general eval framework in torchao. The eventual goal is to use lm_eval to produce reproducible benchmarks for the quantization APIs in torchao that we can showcase on the main README. This will have the added benefit of allowing us to add (possibly nightly) regression test suites for important models.

Test Plan:

2024-05-24:14:50:32,647 INFO     [task.py:395] Building contexts for wikitext on rank 0...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1132.98it/s]
2024-05-24:14:50:32,648 INFO     [evaluator.py:362] Running loglikelihood_rolling requests
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:51<00:00, 51.39s/it]
wikitext: {'word_perplexity,none': 7.877762491958485, 'word_perplexity_stderr,none': 'N/A', 'byte_perplexity,none': 1.488984329919892, 'byte_perplexity_stderr,none': 'N/A', 'bits_per_byte,none': 0.5743285710685551, 'bits_per_byte_stderr,none': 'N/A', 'alias': 'wikitext'}
.
----------------------------------------------------------------------
Ran 1 test in 858.105s

OK

python test/quantization/test_quant_api.py -k test_8da4w_gptq_quantizer

Copy link

pytorch-bot bot commented May 24, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 3410422 with merge base 7511b1d (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 24, 2024
@@ -186,9 +186,14 @@ def test_8da4w_quantizer(self):
assert isinstance(m.linear2, Int8DynActInt4WeightLinear)
m(*example_inputs)

# TODO: save model weights as artifacts and re-enable in CI
Copy link
Member

Choose a reason for hiding this comment

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

Until this is running in CI mind if we have an eval.py we can run in a new scripts/ folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will do in the next PR. Currently the models still live under test/ so we'll probably have to move those out as well

@@ -0,0 +1,228 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
Copy link
Member

Choose a reason for hiding this comment

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

Can we put this in a higher level namespace? Something like torchao._eval? or torchao.model._eval or torchao.util

"Int4WeightOnlyGPTQQuantizer",
"Int4WeightOnlyQuantizer",
] + add_ons

if lm_eval_available:
Copy link
Member

Choose a reason for hiding this comment

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

awesome <3 thank you for making this change

Summary: This commit extracts all the eval code from GPTQ.py.
This is the first step towards having a general eval framework
in torchao. The eventual goal is to use lm_eval to produce
reproducible benchmarks for the quantization APIs in torchao
that we can showcase on the main README. This will have the
added benefit of allowing us to add (possibly nightly)
regression test suites for important models.

Test Plan:

```
2024-05-24:14:50:32,647 INFO     [task.py:395] Building contexts for wikitext on rank 0...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1132.98it/s]
2024-05-24:14:50:32,648 INFO     [evaluator.py:362] Running loglikelihood_rolling requests
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:51<00:00, 51.39s/it]
wikitext: {'word_perplexity,none': 7.877762491958485, 'word_perplexity_stderr,none': 'N/A', 'byte_perplexity,none': 1.488984329919892, 'byte_perplexity_stderr,none': 'N/A', 'bits_per_byte,none': 0.5743285710685551, 'bits_per_byte_stderr,none': 'N/A', 'alias': 'wikitext'}
.
----------------------------------------------------------------------
Ran 1 test in 858.105s

OK
```

python test/quantization/test_quant_api.py -k test_8da4w_gptq_quantizer
@andrewor14 andrewor14 merged commit 5b04ff0 into main May 28, 2024
13 checks passed
@andrewor14 andrewor14 deleted the eval branch May 28, 2024 16:06
jerryzh168 pushed a commit to jerryzh168/executorch-1 that referenced this pull request May 29, 2024
Summary: Fix broken import after pytorch/ao#275

Reviewed By: jerryzh168

Differential Revision: D57888168
jerryzh168 pushed a commit to jerryzh168/executorch-1 that referenced this pull request May 29, 2024
Summary:

Fix broken import after pytorch/ao#275

Differential Revision: D57888168

import torch

from .utils import _lm_eval_available, _MultiInput
Copy link

@sanchitintel sanchitintel May 29, 2024

Choose a reason for hiding this comment

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

These two are in a different directory. i.e. the package name should be .quantization.utils.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for catching that, will submit a fix

andrewor14 added a commit that referenced this pull request May 29, 2024
jerryzh168 pushed a commit to jerryzh168/executorch-1 that referenced this pull request May 29, 2024
Summary:

Fix broken import after pytorch/ao#275

Reviewed By: jerryzh168

Differential Revision: D57888168
andrewor14 added a commit that referenced this pull request May 29, 2024
jerryzh168 pushed a commit to jerryzh168/executorch-1 that referenced this pull request May 29, 2024
Summary:

Fix broken import after pytorch/ao#275

Reviewed By: jerryzh168

Differential Revision: D57888168
facebook-github-bot pushed a commit to pytorch/executorch that referenced this pull request May 30, 2024
Summary:
Pull Request resolved: #3760

Fix broken import after pytorch/ao#275

Reviewed By: jerryzh168

Differential Revision: D57888168

fbshipit-source-id: 51a63131ae14e362991ef962df325ec24f958e2d
dbyoung18 pushed a commit to dbyoung18/ao that referenced this pull request Jul 31, 2024
Summary: This commit extracts all the eval code from GPTQ.py.
This is the first step towards having a general eval framework
in torchao. The eventual goal is to use lm_eval to produce
reproducible benchmarks for the quantization APIs in torchao
that we can showcase on the main README. This will have the
added benefit of allowing us to add (possibly nightly)
regression test suites for important models.

Test Plan:

```
2024-05-24:14:50:32,647 INFO     [task.py:395] Building contexts for wikitext on rank 0...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1132.98it/s]
2024-05-24:14:50:32,648 INFO     [evaluator.py:362] Running loglikelihood_rolling requests
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:51<00:00, 51.39s/it]
wikitext: {'word_perplexity,none': 7.877762491958485, 'word_perplexity_stderr,none': 'N/A', 'byte_perplexity,none': 1.488984329919892, 'byte_perplexity_stderr,none': 'N/A', 'bits_per_byte,none': 0.5743285710685551, 'bits_per_byte_stderr,none': 'N/A', 'alias': 'wikitext'}
.
----------------------------------------------------------------------
Ran 1 test in 858.105s

OK
```

python test/quantization/test_quant_api.py -k test_8da4w_gptq_quantizer
dbyoung18 pushed a commit to dbyoung18/ao that referenced this pull request Jul 31, 2024
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.

4 participants