Instructions to use axteam/gemma-4-12B-it-FP8-dynamic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use axteam/gemma-4-12B-it-FP8-dynamic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="axteam/gemma-4-12B-it-FP8-dynamic") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("axteam/gemma-4-12B-it-FP8-dynamic") model = AutoModelForMultimodalLM.from_pretrained("axteam/gemma-4-12B-it-FP8-dynamic", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use axteam/gemma-4-12B-it-FP8-dynamic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "axteam/gemma-4-12B-it-FP8-dynamic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "axteam/gemma-4-12B-it-FP8-dynamic", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/axteam/gemma-4-12B-it-FP8-dynamic
- SGLang
How to use axteam/gemma-4-12B-it-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 "axteam/gemma-4-12B-it-FP8-dynamic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "axteam/gemma-4-12B-it-FP8-dynamic", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "axteam/gemma-4-12B-it-FP8-dynamic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "axteam/gemma-4-12B-it-FP8-dynamic", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use axteam/gemma-4-12B-it-FP8-dynamic with Docker Model Runner:
docker model run hf.co/axteam/gemma-4-12B-it-FP8-dynamic
gemma-4-12B-it Β· FP8 (dynamic)
8-bit quantization of google/gemma-4-12B-it, produced for efficient vLLM serving. Quantized by axteam.
| Base model | google/gemma-4-12B-it |
| Method | FP8 (dynamic) |
| Format | compressed-tensors FP8_DYNAMIC |
| Weights / activations | W8A8 β FP8 E4M3 weights (per-output-channel scale), dynamic per-token FP8 activations |
| Architecture | Gemma 4 Β· Dense |
| Size on disk | ~12.1 GB |
| Calibration | None (data-free static weight scales) |
| License | Gemma 4 / Apache-2.0 |
Quantization details
- Scheme β W8A8 β FP8 E4M3 weights (per-output-channel scale), dynamic per-token FP8 activations, stored as compressed-tensors
FP8_DYNAMIC. - Kept in BF16 β vision tower, vision projection, token embeddings (tied with lm_head), MoE router, and all norms. These are left unquantized to preserve quality (a small fraction of total parameters).
- Tokenizer /
chat_template/processor_config/generation_configare byte-identical to the original, including Google's July-2026 correctedchat_template.config.jsonis the original plus aquantization_configblock.
Quantization method β PTQ (AWQ / RTN) vs QAT
This model is a post-training quantization (PTQ): the released BF16 weights are quantized after training, with no retraining, so it stays faithful to the original model's behaviour.
- RTN (round-to-nearest) β weights are simply rounded to the quantization grid with per-group scales; no calibration data. Fastest, but outliers aren't compensated, so 4-bit fidelity is the lowest. Used only as an internal baseline here, not published.
- AWQ (activation-aware weight quantization) β a small calibration set finds the weight channels that multiply the largest activations; those salient channels are protected by per-channel scaling (the scale is folded into adjacent layers, e.g. LayerNorm β q/k/v) before rounding. Still PTQ (no gradient, secondsβminutes), and far better than RTN at 4-bit.
- QAT (quantization-aware training) β the model is fine-tuned with quantization simulated in the forward pass, so the weights adapt to quantization error via gradient descent. Best low-bit fidelity, but needs the full training stack, data and GPU hours. Google ships separate Gemma QAT checkpoints; this repo is not one of them.
Rough low-bit fidelity: QAT β₯ AWQ > RTN. Cost: QAT β« AWQ > RTN. This build: FP8 dynamic β a calibration-free PTQ (static per-channel weight scales + runtime per-token activation scales).
Evaluation (measured)
Measured against the BF16 original on an internal mixed English/Korean set. Quantization variant: FP8 dynamic (W8A8).
| Metric | This model | BF16 original |
|---|---|---|
| Perplexity (lower is better) | 1.1732 | 1.1488 (+2.1%) |
| Top-1 next-token agreement | 96.0% | 99.2% |
These numbers measure fidelity to the base model, not absolute task scores.
Usage (vLLM)
vllm serve axteam/gemma-4-12B-it-FP8-dynamic
from vllm import LLM, SamplingParams
llm = LLM(model="axteam/gemma-4-12B-it-FP8-dynamic")
params = SamplingParams(temperature=1.0, top_p=0.95, top_k=64, max_tokens=1024)
out = llm.chat(
[{"role": "user", "content": "Write a short joke about saving RAM."}],
params,
)
print(out[0].outputs[0].text)
Recommended sampling (per Google):
temperature=1.0,top_p=0.95,top_k=64. Thinking mode: add the<|think|>token at the start of the system prompt to enable step-by-step reasoning.
Reducing KV-cache memory (optional, serve-time)
The KV cache is unquantized (BF16) here β the standard for quantized checkpoints (RedHatAI, NVIDIA, etc. ship the same way). KV-cache precision is a runtime choice, independent of the weight quantization above. For long context or large batches you can roughly halve KV-cache memory with FP8:
vllm serve axteam/gemma-4-12B-it-FP8-dynamic --kv-cache-dtype fp8
--kv-cache-dtypeacceptsauto(default, BF16),fp8/fp8_e4m3,fp8_e5m2. For a GGUF build the llama.cpp equivalent is--cache-type-k q8_0 --cache-type-v q8_0.
License
This is a quantized derivative of Google's Gemma 4. Use is governed by the Gemma 4 license. All original weights, tokenizer, and chat template belong to Google DeepMind.
νκ΅μ΄ μμ½
google/gemma-4-12B-it λ₯Ό FP8 (dynamic) λ‘ μμνν μλΉμ©(8-bit) λͺ¨λΈμ
λλ€. μμ±: axteam.
- λ°©μ β FP8 E4M3. κ°μ€μΉλ μΆλ ₯ μ±λλ§λ€ μ€μΌμΌ νλ(μ μ ·보μ λΆνμ), νμ±νλ μΆλ‘ μ ν ν°λ§λ€ λμ FP8. νμμ compressed-tensors
FP8_DYNAMIC. - BF16 μ μ§ β λΉμ νμΒ·λΉμ ν¬μΒ·ν ν° μλ² λ©(lm_headμ λ¬Άμ)Β·MoE λΌμ°ν°Β·λ Έλ¦ (μ 체μ κ·Ήν μΌλΆ).
- ν ν¬λμ΄μ Β·chat_templateΒ·processorΒ·generation_config λ μλ³Έκ³Ό λ°μ΄νΈκΉμ§ λμΌ (ꡬκΈμ΄ 2026-07μ κ³ μΉ chat_template κ·Έλλ‘).
config.jsonμ μλ³Έ +quantization_config. - μμν λ°©μ(PTQ vs QAT) β νμ΅ ν(PTQ) λ°©μμ΄λΌ μ¬νμ΅ μμ΄ μλ³Έ κ°μ€μΉλ₯Ό μ λΉνΈλ‘ λ°κΏλλ€. RTN=보μ μμ΄ λ°μ¬λ¦Όλ§(κ°μ₯ λΉ λ₯΄λ μ΄μμΉ λ³΄μμ΄ μ λΌ 4λΉνΈ νμ§ μ΅μ , λ΄λΆ κΈ°μ€μ©Β·λΉκ³΅κ°) Β· AWQ=μλ 보μ μΌλ‘ ν° νμ±νμ κ³±ν΄μ§λ μ€μ μ±λμ μ±λ μ€μΌμΌλ‘ 보νΈν λ€ λ°μ¬λ¦Ό(κ²½μ¬ μμ, 4λΉνΈμ RTNλ³΄λ€ ν¨μ¬ μ’μ) Β· QAT=μμνλ₯Ό νλ΄ λ΄λ©° μ¬νμ΅ν΄ κ°μ€μΉκ° μ€μ°¨μ μ μ(μ λΉνΈ μ΅μμ΄λ νμ΅ μ€νΒ·λ°μ΄ν°Β·GPU νμ, κ΅¬κΈ Gemma QAT 체ν¬ν¬μΈνΈλ λ³λ β λ³Έ λ ν¬λ QAT μλ). μ λΉνΈ νμ§ β QAT β₯ AWQ > RTN. λ³Έ λΉλ: FP8 λμ β 보μ λΆνμ PTQ(κ°μ€μΉλ μ μ μ±λ μ€μΌμΌ, νμ±νλ λ°νμ ν ν°λ³).
- νμ§(μ€μΈ‘) β BF16 μλ³Έ λλΉ perplexity 1.1732(μλ³Έ 1.1488, +2.1%), top-1 μΌμΉλ 96.0%(μλ³Έ 99.2%). λ΄λΆ μ/ν νκ°μ μμ μΈ‘μ . λ³ν: FP8 dynamic (W8A8).
- μ¬μ© β
vllm serve axteam/gemma-4-12B-it-FP8-dynamic. κΆμ₯ μνλ§temperature=1.0, top_p=0.95, top_k=64. - KV μΊμ μ κ°(μ ν, μλΉ μ) β κΈ°λ³Έμ BF16 KV(μμν 체ν¬ν¬μΈνΈ νμ€, RedHatΒ·NVIDIA λμΌ). κ°μ€μΉ μμνμ 무κ΄ν λ°νμ μ ν. κΈ΄ λ¬Έλ§₯Β·λλ°°μΉμμ
vllm serve β¦ --kv-cache-dtype fp8λ‘ KV λ©λͺ¨λ¦¬ μ λ°. (GGUFλΌλ©΄ llama.cpp--cache-type-k q8_0 --cache-type-v q8_0) - λΌμ΄μ μ€ β κ΅¬κΈ Gemma 4 νμλ¬Ό. Gemma 4 λΌμ΄μ μ€ μ μ©. μλ³Έ κ°μ€μΉΒ·ν ν¬λμ΄μ Β·chat_template κΆλ¦¬λ Google DeepMind.
- Downloads last month
- 55