-
Notifications
You must be signed in to change notification settings - Fork 174
Fp8 compressed #358
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
Fp8 compressed #358
Conversation
Summary of ChangesHello @danielhanchen, 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 significantly improves the integration and handling of FP8 compressed tensors within the vLLM utility. It introduces robust mechanisms for identifying different FP8 quantization schemes, correctly interpreting their weight scales, and configuring the appropriate FP8 linear layers for efficient model loading and operation. The changes aim to enhance compatibility and performance when working with FP8 quantized models. Highlights
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
|
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 adds support for FP8 compressed tensors by detecting this new quantization method, handling its specific configuration for block size, and refactoring the layer creation logic. My review focuses on improving the robustness and readability of the new code. I've suggested refactoring a type check to be less brittle, simplifying configuration parsing, and using a more specific exception handler.
| is_compressed_linear = "CompressedTensors" in str(type(getattr(proj, 'quant_method', None))) | ||
| if is_compressed_linear: |
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 check for is_compressed_linear relies on the string representation of a type, which can be brittle. This can be refactored to check the class name directly and combine the variable assignment and the conditional check into one if statement for improved robustness and conciseness.
| is_compressed_linear = "CompressedTensors" in str(type(getattr(proj, 'quant_method', None))) | |
| if is_compressed_linear: | |
| quant_method = getattr(proj, 'quant_method', None) | |
| if quant_method is not None and "CompressedTensors" in quant_method.__class__.__name__: |
| config_groups = quantization_config.get('config_groups', None) | ||
| group_0 = config_groups.get(0, None) if config_groups else None | ||
| weights = group_0.get('weight', None) if group_0 else None | ||
| block_size = weights.get('block_size', block_size) if weights else block_size |
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 logic for extracting block_size from the configuration can be simplified for better readability and maintainability. Using chained .get() calls with default values makes the code more concise and less prone to errors from None values, assuming config_groups is a dictionary.
| config_groups = quantization_config.get('config_groups', None) | |
| group_0 = config_groups.get(0, None) if config_groups else None | |
| weights = group_0.get('weight', None) if group_0 else None | |
| block_size = weights.get('block_size', block_size) if weights else block_size | |
| config_groups = quantization_config.get('config_groups', {}) | |
| group_0 = config_groups.get(0, {}) | |
| weights = group_0.get('weight', {}) | |
| block_size = weights.get('block_size', block_size) |
| kwargs['block_size'] = block_size | ||
| try: | ||
| from transformers.integrations.finegrained_fp8 import FP8Linear # This has patched forward pass for LoRA and training support. Patched in unsloth/kernels/fp8.py | ||
| except: |
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.
* Update gpt_oss.py * torch compile * Update attention_sink.py * Update common.py * Update common.py * Patches * Compiled mask creation * Update attention_sink.py * Update gpt_oss.py * Update gpt_oss.py * Revert * Update gpt_oss.py * Update gpt_oss.py * Fix up * Update attention_sink.py * Update attention_sink.py * Update utils.py * Update attention_sink.py * Update attention_sink.py * Retry * Update gpt_oss.py * Update gpt_oss.py * Fix Flex * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Bug fixes * Update patching_utils.py * Update patching_utils.py * Update patching_utils.py * Update rl_replacements.py * Update patching_utils.py * Update patching_utils.py * Update patching_utils.py * flash attn * Update gpt_oss.py * Update __init__.py * Update attention_sink.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * dropout_p * Update gpt_oss.py * Update gpt_oss.py * Update attention_sink.py * Update gpt_oss.py * Update gpt_oss.py * fix * Update attention_sink.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update loss_utils.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update loss_utils.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Update gpt_oss.py * Versioning * Update saving_utils.py * Update saving_utils.py * Update saving_utils.py * Update saving_utils.py * Update saving_utils.py * Update saving_utils.py * Update saving_utils.py * Update saving_utils.py * Fix Gemma 3 * Update misc.py * Update rl_environments.py * Update pyproject.toml * Update rl_environments.py * Update __init__.py * Update empty_model.py * Update empty_model.py * Update empty_model.py * Update empty_model.py * Device type * Update vllm_utils.py * Update compiler.py * Update empty_model.py * Update vllm_utils.py * Update empty_model.py * Fixes * Update empty_model.py * Update empty_model.py * Update __init__.py * Update vllm_utils.py * Update vllm_utils.py * Update rl_environments.py * Update cross_entropy_loss.py * Update vllm_utils.py * Update vllm_utils.py * Update rl_environments.py * Update vllm_utils.py * Qwen3 VL vLLM (#324) * qwen3 vl additional layers * qwen3 fused vision qkv * refactor for handling qwen 3 vl * [WIP] fix backward pass issues * out hidden size change * Qwen 2.5 and qwen 3 conv3d->Linear vLLM changes * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * Update vllm_utils.py * Update vllm_utils.py * Update pyproject.toml * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update __init__.py * Update compiler.py * Update __init__.py * Update vllm_utils.py * Update rl_replacements.py * Update rl_replacements.py * Update rl_replacements.py * Fix CE compile * Update loss_utils.py * Update cross_entropy_loss.py * Fix * Deepseekocr fix: save single model shard (#346) * DeepSeekOCR Fix: check for saftensors_list shard naming convention * turned off shard padding length check bc deepseeks padding is different * if you try to copy the index.json file and the same file alredy exists it wil throw and error. * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update patching_utils.py * Fp8 compressed (#358) * [WIP] compressed tensors support for FP8 * [WIP 2/n] improve loading fake layer * [WIP 3/n] improve loading fake layer * [WIP 4/n] improve loading fake layer * revert seq and token util calculation --------- Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com> * Update vllm_utils.py * Update vllm_utils.py * Update vllm_utils.py * Update gradient_checkpointing.py * Update gpt_oss.py * Update gpt_oss.py * updates for vLLM compativility with lora (#359) * updates for vLLM compativility with lora * LoRA extra vocab cleanup --------- Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com> * Update vllm_utils.py * Versioning --------- Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com> Co-authored-by: DoubleMathew <mmathew23@gmail.com>
No description provided.