-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add semi-structured sparsity to hf eval #576
Conversation
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/576
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit fc82248 with merge base 5f35645 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
scripts/hf_eval.py
Outdated
with torch.no_grad(): | ||
result = evaluate( | ||
HFLM( | ||
pretrained=model.to(device), | ||
tokenizer=tokenizer, | ||
batch_size=batch_size, | ||
batch_size="auto", | ||
max_batch_size=2048, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how come?
|
@@ -0,0 +1,383 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really not a fan of checking in notebooks, mind turning this into a python file, there should be a button to do this in jupyter, alternatively link to the tutorial hosted on google colab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that fine with me.
torch.sparse.SparseSemiStructuredTensor._FORCE_CUTLASS = True | ||
torch.set_float32_matmul_precision('high') | ||
|
||
def timed(fn): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have timing utilities in torchao/utils.py
Summary:
This PR adds in huggingface eval for semi-structured sparsity with the
nm-testing/SparseLlama-3-8B-pruned_50.2of4
checkpoint published by neuralmagic. We can accelerate this checkpoint withto_sparse_semi_structured
with minimal accuracy loss.Also adds in an example notebook that outlines how to do text generation with huggingface's model and shows a 80 tok/s -> 87 tok/s speedup.
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags: