Skip to content

Conversation

@kylesayrs
Copy link
Collaborator

Signed-off-by: Kyle Sayers <[email protected]>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 Qwen2 Audio Example: A new example script, qwen2_audio.py, has been added to demonstrate 4-bit quantization (W4A16 GPTQ) of the Qwen2-Audio-7B model using the llmcompressor library.
  • Audio Data Preprocessing: The new example includes comprehensive steps for loading and preprocessing audio data from the MLCommons/peoples_speech dataset, preparing it for the Qwen2-Audio model's input requirements.
  • Llama3 Example Modifications: The existing llama3_example.py script has been updated to change its target model to bigcode/starcoder2-3b and to comment out the quantization recipe, generation, and saving steps, effectively disabling its core functionality for now.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

👋 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +86 to +92
# oneshot(
# model=model,
# dataset=ds,
# recipe=recipe,
# max_seq_length=MAX_SEQUENCE_LENGTH,
# num_calibration_samples=NUM_CALIBRATION_SAMPLES,
# )
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
# 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
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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()}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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()}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants