Downloads · 30 days
19
1% of all-time downloads
amd/Llama-3.1-8B-Instruct-da8w8-torchao-v0.16.0
Llama-3.1-8B-Instruct-da8w8-torchao-v0.16.0 is a text generation model from amd. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as llama3.1.
- Model Architecture: LlamaForCausalLM - Input: Text - Output: Text - Source Model: Llama-3.1-8B-Instruct - Supported Hardware: AMD EPYC (CPU inference) - Preferred Operating System: Linux - Inference Engine: vLLM v0.…
Downloads · 30 days
19
1% of all-time downloads
All-time downloads
3.3K
Public
Repo size
9.1 GB
Likes
1
Public
Click a slice to open those files.
.bin9.1 GB · 100%
From the Hugging Face model README
[!NOTE] zentorch v5.2.1 for PyTorch v2.10.0 has to be built from source.
This model was Built with Llama. This is a quantized version of Llama-3.1-8B-Instruct created by AMD using TorchAO for ZenDNN-optimized CPU inference.
The model was produced using torchao as shown in the example below. Both activations and weights are quantized to INT8 with symmetric mapping. Activation scales are computed dynamically at runtime per token.
import torch
from transformers import TorchAoConfig, AutoModelForCausalLM, AutoTokenizer
from torchao.quantization import Int8DynamicActivationInt8WeightConfig
from torchao.quantization.quant_primitives import MappingType
MODEL_ID = "meta-llama/Llama-3.1-8B-Instruct"
OUTPUT_DIR = "amd/Llama-3.1-8B-Instruct-da8w8-torchao-v0.16.0"
modules_to_skip = ["lm_head"]
quantization_config = TorchAoConfig(
Int8DynamicActivationInt8WeightConfig(
version=2,
act_mapping_type=MappingType.SYMMETRIC,
),
modules_to_not_convert=modules_to_skip,
)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
dtype=torch.bfloat16,
device_map="cpu",
quantization_config=quantization_config,
trust_remote_code=True,
)
model.save_pretrained(OUTPUT_DIR, safe_serialization=False)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
tokenizer.save_pretrained(OUTPUT_DIR)
# Smoke test
inputs = tokenizer("What are we having for dinner?", return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=30, cache_implementation="static")
print(tokenizer.decode(out[0], skip_special_tokens=True))
[!NOTE]
safe_serialization=Falseis required because torchao's quantized tensor subclasses cannot currently be serialized in thesafetensorsformat.
pip install --extra-index-url https://download.pytorch.org/whl/cpu \
--extra-index-url https://wheels.vllm.ai/cpu/ \
torch==2.10.0+cpu \
vllm==0.18.0 \
torchao==0.16.0 \
transformers \
huggingface_hub
CPU runtime libraries (only needed if not already present):
conda install -c conda-forge gperftools=2.17.2 llvm-openmp=18.1.8 --no-deps -y
# vLLM CPU runtime tuning
export VLLM_CPU_KVCACHE_SPACE=40 # GB of host memory for KV cache
export VLLM_CPU_OMP_THREADS_BIND="0-63" # NUMA-local cores
# TorchInductor
export TORCHINDUCTOR_FREEZING=1
export TORCHINDUCTOR_AUTOGRAD_CACHE=1
# Required CPU runtime libraries
export LD_PRELOAD="<path to lib>/libtcmalloc_minimal.so.4:<path to lib>/libiomp5.so${LD_PRELOAD:+:$LD_PRELOAD}"
Locate the libraries with find / -name 'libtcmalloc_minimal.so.4' and find / -name 'libiomp5.so', then substitute the resulting directory for <path to lib>.
The model was evaluated against the BF16 (unquantized) baseline using lm-evaluation-harness with the vLLM engine.
| Benchmark | BF16 Baseline | DA8W8 (this model) | Dynamic Quant Difference (baseline: BF16) |
|---|---|---|---|
| GSM8K (5-shot, exact-match strict) | 0.8453 | 0.8279 | -2.06% |
lm_eval \
--model vllm \
--model_args pretrained=amd/Llama-3.1-8B-Instruct-da8w8-torchao-v0.16.0,tokenizer=meta-llama/Llama-3.1-8B-Instruct,dtype=bfloat16 \
--tasks gsm8k \
--batch_size auto \
--trust_remote_code \
--num_fewshot 5 \
--log_samples \
--gen_kwargs "max_gen_toks=2048" \
--apply_chat_template \
--output_path .
This model is distributed under the same license as the source model. See the LICENSE file for details.
Modifications copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.