Skip to content

NVFP4 Emulation #59

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 6 commits into
base: modelopt-nvfp4-emu
Choose a base branch
from
Open

NVFP4 Emulation #59

wants to merge 6 commits into from

Conversation

dsikka
Copy link

@dsikka dsikka commented May 1, 2025

Summary:

  • Add CompressedTensors NVFP4 Emulation Scheme
  • Move emulations functionality into shared utilities

ModelOpt Emulation Changes:

  • Don't run activations quantization to start --> seemed to be getting gibberish even with it turned off
  • Update how the global scale is applied. I think they're storing the inverse? Updating this allows the coherent outputs for the Nvidia 70b checkpoint

Should now support ct models produced and compressed from the following branches:

  1. FP4 Weights: [NVFP4][WIP] Add NVFp4 Support compressed-tensors#287
  2. Compression: [WIP][NVFP4] Add compression/decompression code compressed-tensors#291
  3. LLM Compressor: [NVFP4][WIP]: Add FP4 Support vllm-project/llm-compressor#1309

lm-evals/generations should work with weight only dequant:

lm_eval --model vllm \
    --model_args pretrained=nm-testing/llama2.c-stories110M-FP4,enforce_eager=True \
    --tasks gsm8k \
    --device cuda:0 \
    --batch_size 8
import numpy
import torch

from vllm import LLM, SamplingParams

prompts = ["The Swiss Alps are", "The president of the USA is", "The Boston Bruins are"]

# Create a sampling params object for greedy sampling
sampling_params = SamplingParams(temperature=0.80, top_p=0.95, max_tokens=40, min_tokens=10)
llm  = LLM('nm-testing/llama2.c-stories110M-FP4', enforce_eager=True)


# Print the outputs.
output = llm.generate(prompts, sampling_params)
for o in output:
    print(o.outputs[0].text)
    print("\n")

ToDo:

  • Generally activation quant support - still need to understand how the input scales should be applied
  • Improve compression speed in compressed-tensors. The current speed is a bottleneck atm

Signed-off-by: Dipika Sikka <dipikasikka1@gmail.com>
Copy link

github-actions bot commented May 1, 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.

🚀

@dsikka dsikka changed the title update NVFP4 Emulation May 1, 2025
@dsikka dsikka mentioned this pull request May 1, 2025
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.

1 participant