-
Notifications
You must be signed in to change notification settings - Fork 346
[WIP] [Audio] Qwen2 Audio Example #2177
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kyle Sayers <[email protected]>
Summary of ChangesHello @kylesayrs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new example showcasing the application of 4-bit GPTQ quantization to the Qwen2-Audio-7B model, detailing the entire process from data loading and preprocessing to model generation and saving. Concurrently, an existing Llama3 quantization example has been temporarily disabled by commenting out its core functionality and changing its target model, likely to streamline development or testing efforts related to the new audio model integration. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review. Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed. |
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.
Code Review
This pull request introduces a new example script for quantizing the Qwen2 Audio model and modifies an existing Llama3 example. The new script is a valuable addition, but it appears to be a work in progress, with some key functionality commented out and using temporary values for quick testing. My review focuses on suggestions to make the new example script fully functional and improve its code quality. Specifically, I recommend uncommenting the main oneshot call, using a more appropriate number of calibration samples for effective quantization, and adopting a more idiomatic approach for tensor manipulation.
| # oneshot( | ||
| # model=model, | ||
| # dataset=ds, | ||
| # recipe=recipe, | ||
| # max_seq_length=MAX_SEQUENCE_LENGTH, | ||
| # num_calibration_samples=NUM_CALIBRATION_SAMPLES, | ||
| # ) |
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.
The oneshot function call, which performs the actual quantization, is currently commented out. This prevents the script from executing its primary purpose. To make this example functional, this block of code should be uncommented.
| # oneshot( | |
| # model=model, | |
| # dataset=ds, | |
| # recipe=recipe, | |
| # max_seq_length=MAX_SEQUENCE_LENGTH, | |
| # num_calibration_samples=NUM_CALIBRATION_SAMPLES, | |
| # ) | |
| oneshot( | |
| model=model, | |
| dataset=ds, | |
| recipe=recipe, | |
| max_seq_length=MAX_SEQUENCE_LENGTH, | |
| num_calibration_samples=NUM_CALIBRATION_SAMPLES, | |
| ) |
| DATASET_SUBSET = "test" | ||
| DATASET_SPLIT = "test" | ||
|
|
||
| NUM_CALIBRATION_SAMPLES = 4#512 |
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.
The number of calibration samples is set to 4, which is too low for GPTQ to produce a well-quantized model. The commented-out value of 512 is a much more realistic starting point for achieving good results. For this example to be effective, it should use a more representative number of samples.
| NUM_CALIBRATION_SAMPLES = 4#512 | |
| NUM_CALIBRATION_SAMPLES = 512 |
| print("\n========== SAMPLE GENERATION ==============") | ||
| dispatch_for_generation(model) | ||
| sample = next(iter(ds)) | ||
| sample = {key: torch.tensor([value]).to(model.device) for key, value in sample.items()} |
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.
While torch.tensor([value]) correctly adds a batch dimension, using value.unsqueeze(0) is more idiomatic and generally more efficient. unsqueeze creates a view of the tensor without copying data, and it more clearly communicates the intent of adding a dimension.
| sample = {key: torch.tensor([value]).to(model.device) for key, value in sample.items()} | |
| sample = {key: value.unsqueeze(0).to(model.device) for key, value in sample.items()} |
@GOavi101