-
Notifications
You must be signed in to change notification settings - Fork 60
merge main branch to alg_ext #970
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
364ae3c
merge main branch to alg_ext
wenhuach21 168b4c4
Merge branch 'main' into fix_alg_ext
wenhuach21 21b87ed
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0e8f6e4
Update test/test_cuda/test_alg_ext.py
wenhuach21 cc0c1b2
revert
wenhuach21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import shutil | ||
| import sys | ||
| import unittest | ||
|
|
||
| sys.path.insert(0, "../..") | ||
|
|
||
| import torch | ||
| from transformers import AutoModelForCausalLM, AutoTokenizer | ||
|
|
||
| from auto_round import AutoRound, AutoRoundConfig | ||
| from auto_round.eval.evaluation import simple_evaluate_user_model | ||
|
|
||
|
|
||
| class TestAlgExt(unittest.TestCase): | ||
|
|
||
| @classmethod | ||
| def setUpClass(self): | ||
| self.model_name = "/models/opt-125m" | ||
| self.save_folder = "./saved" | ||
|
|
||
| @classmethod | ||
| def tearDownClass(self): | ||
| shutil.rmtree(self.save_folder, ignore_errors=True) | ||
| shutil.rmtree("runs", ignore_errors=True) | ||
|
|
||
| def test_2bits(self): | ||
| model_name = "/models/opt-125m" | ||
| ar = AutoRound(model=model_name, bits=2, group_size=64, enable_alg_ext=True) | ||
| ar.quantize_and_save(self.save_folder) | ||
| model = AutoModelForCausalLM.from_pretrained( | ||
| self.save_folder, | ||
| device_map="auto", | ||
| ) | ||
|
|
||
| tokenizer = AutoTokenizer.from_pretrained(self.save_folder) | ||
| result = simple_evaluate_user_model(model, tokenizer, batch_size=64, tasks="lambada_openai") | ||
| print(result["results"]["lambada_openai"]["acc,none"]) | ||
| # wo alg ext 0.2084, with 0.2364 | ||
| self.assertGreater(result["results"]["lambada_openai"]["acc,none"], 0.22) | ||
| shutil.rmtree(self.save_folder, ignore_errors=True) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.