Instructions to use RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic") model = AutoModelForCausalLM.from_pretrained("RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic
- SGLang
How to use RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic with Docker Model Runner:
docker model run hf.co/RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic
Llama-3.1-8B-tldr-FP8-quantized
Model Overview
- Model Architecture: LlamaForCausalLM
- Input: Text
- Output: Text
- Model Optimizations:
- Weight quantization: FP8
- Activation quantization: FP8
- Release Date: 06/06/2025
- Version: 1.0
- Intended Use Cases: This model is finetuned to summarize text in the style of Reddit posts.
- Out-of-scope: Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in any other way that is prohibited by the Acceptable Use Policy and Llama 3.1 Community License.
- Model Developers: Red Hat (Neural Magic)
This model is a quantized version of RedHatAI/Llama-3.1-8B-tldr, which is fine-tuned on the trl-lib/tldr dataset. This model recovers 100% of the BERTScore (0.366) obtained by RedHatAI/Llama-3.1-8B-tldr while providing up to 1.3x speedup.
Deployment
This model can be deployed efficiently using vLLM, as shown in the example below.
Run the following command to start the vLLM server:
vllm serve RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic
Once your server is started, you can query the model using the OpenAI API:
from openai import OpenAI
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8000/v1"
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
post="""
SUBREDDIT: r/AI
TITLE: Training sparse LLMs
POST: Now you can use the llm-compressor integration to axolotl to train sparse LLMs!
It's super easy to use. See the example in https://huggingface.co/RedHatAI/Sparse-Llama-3.1-8B-tldr-2of4.
And there's more. You can run 2:4 sparse models on vLLM and get significant speedupts on Hopper GPUs!
"""
prompt = f"Give a TL;DR of the following Reddit post.\n<|user|>{post}\nTL;DR:\n<|assistant|>\n"
completion = client.completions.create(
model="RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic",
prompt=prompt,
max_tokens=256,
)
print("Completion result:", completion)
Quantization
Quantization details
This model was created by applying llm-compressor, as presented in the code snipet below.
from transformers import AutoTokenizer, AutoModelForCausalLM
from llmcompressor.transformers import oneshot
from llmcompressor.modifiers.quantization import QuantizationModifier
recipe = QuantizationModifier(targets="Linear", scheme="FP8_DYNAMIC", ignore=["lm_head"])
model_stub = "RedHatAI/Llama-3.1-8B-tldr"
model_name = model_stub.split("/")[-1]
model = AutoModelForCausalLM.from_pretrained(
model_stub, torch_dtype="auto", device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_stub)
output_dir = f"./{model_name}-FP8-dynamic"
oneshot(
model=model,
recipe=recipe,
)
model.save_pretrained(output_dir, save_compressed=True)
tokenizer.save_pretrained(output_dir)
Evaluation
The model was evaluated on the test split of trl-lib/tldr using the Neural Magic fork of lm-evaluation-harness (tldr branch). One can reproduce these results by using the following command:
lm_eval --model vllm --model_args "pretrained=RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic,dtype=auto,add_bos_token=True" --batch-size auto --tasks tldr
| Metric | Llama-3.1-8B-Instruct | Llama-3.1-8B-tldr | Llama-3.1-8B-tldr-FP8-dynamic (this model) |
|---|---|---|---|
| BERTScore | -0.230 | 0.366 | 0.366 |
| ROUGE-1 | 0.059 | 0.362 | 0.360 |
| ROUGE-2 | 0.018 | 0.144 | 0.143 |
| ROUGE-Lsum | 0.051 | 0.306 | 0.306 |
Inference Performance
We evaluated the inference performance of this model using the first 1,000 samples from the training set of the trl-lib/tldr dataset.
Benchmarking was conducted with vLLM version 0.9.0.1 and GuideLLM version 0.2.1.
The figure below presents the mean end-to-end latency per request across varying request rates. Results are shown for this model, as well as two variants:
- Dense: Llama-3.1-8B-tldr
- Sparse-quantized: Sparse-Llama-3.1-8B-tldr-2of4-FP8-dynamic
Reproduction instructions
To replicate the benchmark:
- Generate a JSON file containing the first 1,000 training samples:
from datasets import load_dataset
ds = load_dataset("trl-lib/tldr", split="train").take(1000)
ds.to_json("tldr_1000.json")
- Start a vLLM server using your target model:
vllm serve RedHatAI/Llama-3.1-8B-tldr-FP8-dynamic
- Run the benchmark with GuideLLM:
GUIDELLM__OPENAI__MAX_OUTPUT_TOKENS=128 guidellm benchmark --target "http://localhost:8000" --rate-type sweep --data tldr_1000.json
The average output length is approximately 30 tokens per sample. We capped the generation at 128 tokens to reduce performance skew from rare, unusually verbose completions.
- Downloads last month
- 23
