Skip to content
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

Add support for nvidia modelopt fp8 kv cache #3223

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

Conversation

Edwardf0t1
Copy link
Contributor

Motivation

Add support for modelopt fp8 kv cache, so SGLang can run modelopt's quantized models with fp8 kv cache enabled.

Modifications

  • Add a ModelOptFp8KVCacheMethod class.
  • Handle kv cache scalers name matching.

Test

nvidia/Llama-3.1-8B-Instruct-FP8 will be updated with FP8 kv cache enabled.

import sglang as sgl

def main():
    prompts = [
        "Hello, my name is",
        "The president of the United States is",
        "The capital of France is",
        "The future of AI is",
    ]
    sampling_params = {"temperature": 0.8, "top_p": 0.95}
    llm = sgl.Engine(model_path="nvidia/Llama-3.1-8B-Instruct-FP8", quantization="modelopt")

    outputs = llm.generate(prompts, sampling_params)
    for prompt, output in zip(prompts, outputs):
        print("===============================")
        print(f"Prompt: {prompt}\nGenerated text: {output['text']}")

if __name__ == "__main__":
    main()

Checklist

@Edwardf0t1 Edwardf0t1 marked this pull request as ready for review January 30, 2025 22:54
@Edwardf0t1 Edwardf0t1 force-pushed the zhiyu/enable-modelopt-fp8-kv-cache branch from eb0d651 to 12f49e1 Compare February 1, 2025 00:09
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