Instructions to use undeadindustries/gemma-4-31b-it-nvfp4-hybrid with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use undeadindustries/gemma-4-31b-it-nvfp4-hybrid with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="undeadindustries/gemma-4-31b-it-nvfp4-hybrid") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoProcessor, AutoModelForCausalLM processor = AutoProcessor.from_pretrained("undeadindustries/gemma-4-31b-it-nvfp4-hybrid") model = AutoModelForCausalLM.from_pretrained("undeadindustries/gemma-4-31b-it-nvfp4-hybrid", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use undeadindustries/gemma-4-31b-it-nvfp4-hybrid with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "undeadindustries/gemma-4-31b-it-nvfp4-hybrid" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "undeadindustries/gemma-4-31b-it-nvfp4-hybrid", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/undeadindustries/gemma-4-31b-it-nvfp4-hybrid
- SGLang
How to use undeadindustries/gemma-4-31b-it-nvfp4-hybrid 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 "undeadindustries/gemma-4-31b-it-nvfp4-hybrid" \ --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": "undeadindustries/gemma-4-31b-it-nvfp4-hybrid", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "undeadindustries/gemma-4-31b-it-nvfp4-hybrid" \ --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": "undeadindustries/gemma-4-31b-it-nvfp4-hybrid", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use undeadindustries/gemma-4-31b-it-nvfp4-hybrid with Docker Model Runner:
docker model run hf.co/undeadindustries/gemma-4-31b-it-nvfp4-hybrid
Gemma 4 31B IT β NVFP4 hybrid verifier (primary model)
This is the main model. Pair it with
undeadindustries/gemma-4-31b-it-dflash-drafter-nvfp4
for optional speculative-decoding speedup on vLLM.
The pair β what to load together
| Role | Repo | Size | Required? |
|---|---|---|---|
| Verifier (this repo) | gemma-4-31b-it-nvfp4-hybrid |
~30 GB | Yes β this is the 31B brain |
| DFlash drafter | gemma-4-31b-it-dflash-drafter-nvfp4 |
~8 GB | Optional β guesses tokens; verifier always has final say |
Use together: load the verifier as your main vllm serve model and point --speculative-config at the drafter. The drafter was trained on hidden states from this exact quant β a generic drafter trained on BF16 Gemma will not work well (acceptance collapses).
Verifier-only is fine if you only want quality + smaller footprint (~30 GB vs ~62 GB BF16). You do not need the drafter for correct answers.
Why this quant exists
Hand-tuned hybrid NVFP4 of google/gemma-4-31b-it for instruction following and long-document work on memory-constrained Blackwell boxes (e.g. 128 GB unified memory):
- BF16 attention (
q/k/v/o) β protects dynamic range for 256K-class reasoning and needle-in-haystack retrieval - NVFP4 W4A4 MLP (
gate/up/down) β ~2Γ weight compression on the bulk of parameters - Text-only β vision stripped;
Gemma4ForCausalLMarchitecture
Design goal: smallest practical footprint that keeps -it instruction behavior, not maximum compression at any quality cost.
Quantization scheme
| Component | Precision |
|---|---|
| Attention projections | BF16 (all 60 layers; v_proj on 50 sliding layers only β Gemma 4 global layers use shared K/V) |
MLP (gate/up/down) |
NVFP4 W4A4, group_size=16 |
| KV cache (recommended) | BF16 β avoid FP8 KV default on Gemma 4 hybrid SWA |
Built with AutoRound scheme=NVFP4, exported as llm-compressor / nvfp4-pack-quantized for vLLM.
Verified quality (vLLM 0.20.2, GB10)
Greedy /v1/chat/completions (required for -it models):
- 8/8 prompt battery: factual, arithmetic, reasoning, code, instruction-following, knowledge, translation
- 13.7K-token needle-in-haystack: pass
- Native NVFP4 GEMM on Blackwell (
FlashInferCutlassNvFp4LinearKernel)
Serve verifier only
vllm serve undeadindustries/gemma-4-31b-it-nvfp4-hybrid \
--port 8000 --max-model-len 4096 \
--gpu-memory-utilization 0.55 --enforce-eager --trust-remote-code \
--generation-config vllm
Serve verifier + drafter together (recommended pair)
vllm serve undeadindustries/gemma-4-31b-it-nvfp4-hybrid \
--port 8000 --max-model-len 4096 \
--gpu-memory-utilization 0.55 --enforce-eager --trust-remote-code \
--generation-config vllm \
--max-num-batched-tokens 8192 --max-num-seqs 64 \
--speculative-config '{"model":"undeadindustries/gemma-4-31b-it-dflash-drafter-nvfp4","method":"dflash","num_speculative_tokens":15}'
Requires vLLM β₯ 0.20.2 (e.g. vllm-node:latest). Combined weights: ~36 GB VRAM.
Observed speculative acceptance_length ~1.19 with the paired drafter β modest speedup, no quality regression when using chat API.
Memory note
~30 GB = weights. vLLM may reserve ~55β67 GB total for KV cache and batch slots at default utilization β that is headroom, not model size.
License
Derived from google/gemma-4-31b-it (Apache 2.0).
Subject to Gemma Terms of Use.
- Downloads last month
- 18