FP8 E5M2 KV Cache

The int8/int4 quantization scheme requires additional scale GPU memory storage, which reduces the expected GPU memory benefits. The FP8 data format retains 2~3 mantissa bits and can convert float/fp16/bflaot16 and fp8 to each other.

Here is an example of how to enable this feature:

  1. from vllm import LLM, SamplingParams
  2. # Sample prompts.
  3. prompts = [
  4. "Hello, my name is",
  5. "The president of the United States is",
  6. "The capital of France is",
  7. "The future of AI is",
  8. ]
  9. # Create a sampling params object.
  10. sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
  11. # Create an LLM.
  12. llm = LLM(model="facebook/opt-125m", kv_cache_dtype="fp8")
  13. # Generate texts from the prompts. The output is a list of RequestOutput objects
  14. # that contain the prompt, generated text, and other information.
  15. outputs = llm.generate(prompts, sampling_params)
  16. # Print the outputs.
  17. for output in outputs:
  18. prompt = output.prompt
  19. generated_text = output.outputs[0].text
  20. print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")

Note, current prefix caching doesn’t work with FP8 KV cache enabled, forward_prefix kernel should handle different KV and cache type.