Skip to content

Quantization: support FP4 quantized models on AMD CDNA2/CDNA3 GPUs #22527

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fengli1702
Copy link

@fengli1702 fengli1702 commented Aug 8, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

Add support for running FP4 quantized models on AMD CDNA2 / CDNA3 GPUs via a new quantization backend petit_nvfp4. This enables vLLM to serve models such as Llama-3.1 / Llama-3.3

Test Plan

Verified that ROCm backend without --quantization still runs normally, and automatically selects the petit-kernel FP4 path when loading FP4 quantized models.

Installed optional dependencies via:

pip install -e .[fp4]

Ran test with:

from vllm import LLM, SamplingParams
llm = LLM(model="/path/to/llama-fp4", enforce_eager=True)  # no quantization arg
prompt = "San Francisco is a"
output = llm.generate(prompt, SamplingParams(temperature=0, max_tokens=15))
print(output[0].outputs[0].text)

Confirmed that the FP4 path (petit-kernel) is selected automatically and outputs are generated successfully.

Test Result

Functional test passed: FP4 quantized models load and run inference successfully on ROCm (MI250/MI300 test nodes) without specifying --quantization.

Non-quantized ROCm inference path unaffected.

Verified via log output that petit-kernel module is loaded when using FP4 models.

(Optional) Documentation Update

Added fp4 extras in setup.py for optional dependency installation.

Copy link

github-actions bot commented Aug 8, 2025

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added ci/build rocm Related to AMD ROCm labels Aug 8, 2025
@fengli1702 fengli1702 changed the title feat(quantization): support FP4 quantized models on AMD CDNA2/CDNA3 GPUs Quantization: support FP4 quantized models on AMD CDNA2/CDNA3 GPUs Aug 8, 2025
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 adds support for FP4 quantized models on AMD GPUs using the petit-kernel. The changes look mostly good, with new quantization configurations and utility functions. However, I found a critical issue in the PetitNvFp4Config.from_config method where it uses direct dictionary access for optional keys, which can lead to a KeyError and crash the application if the keys are not present in the configuration file. I've suggested a more robust implementation for this method to handle missing keys gracefully.

@fengli1702 fengli1702 force-pushed the main branch 2 times, most recently from 2855577 to 4725634 Compare August 8, 2025 15:58
Copy link

mergify bot commented Aug 9, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @fengli1702.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Aug 9, 2025
@fengli1702 fengli1702 force-pushed the main branch 2 times, most recently from bbbab70 to 2f217ff Compare August 9, 2025 01:17
@mergify mergify bot removed the needs-rebase label Aug 9, 2025
@fengli1702 fengli1702 force-pushed the main branch 7 times, most recently from 55b4398 to 8e11c88 Compare August 12, 2025 01:09
Copy link

mergify bot commented Aug 12, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @fengli1702.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/build rocm Related to AMD ROCm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant