Instructions to use bg-digitalservices/Gemma-4-E2B-NVFP4A16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bg-digitalservices/Gemma-4-E2B-NVFP4A16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bg-digitalservices/Gemma-4-E2B-NVFP4A16")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("bg-digitalservices/Gemma-4-E2B-NVFP4A16") model = AutoModelForMultimodalLM.from_pretrained("bg-digitalservices/Gemma-4-E2B-NVFP4A16", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bg-digitalservices/Gemma-4-E2B-NVFP4A16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bg-digitalservices/Gemma-4-E2B-NVFP4A16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bg-digitalservices/Gemma-4-E2B-NVFP4A16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bg-digitalservices/Gemma-4-E2B-NVFP4A16
- SGLang
How to use bg-digitalservices/Gemma-4-E2B-NVFP4A16 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 "bg-digitalservices/Gemma-4-E2B-NVFP4A16" \ --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": "bg-digitalservices/Gemma-4-E2B-NVFP4A16", "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 "bg-digitalservices/Gemma-4-E2B-NVFP4A16" \ --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": "bg-digitalservices/Gemma-4-E2B-NVFP4A16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bg-digitalservices/Gemma-4-E2B-NVFP4A16 with Docker Model Runner:
docker model run hf.co/bg-digitalservices/Gemma-4-E2B-NVFP4A16
Gemma-4-E2B-NVFP4A16
NVFP4 quantization of google/gemma-4-E2B β Google's Gemma 4 E2B base (pre-trained) with Per-Layer Embeddings (PLE). 2B effective parameters, multimodal (text + image + audio), 128K context.
W4A16 β language model weights in FP4, activations in FP16. Vision and audio towers stay BF16.
See also Gemma-4-E2B-NVFP4 for the full W4A4 variant.
Key Specs
| Original (BF16) | NVFP4 (this) | |
|---|---|---|
| Size on disk | ~10 GB | ~7.5 GB |
| Compression | β | ~1.3x (text layers 3x, vision/audio stay BF16) |
| Effective parameters | 2B | 2B |
| Architecture | Dense + PLE (Per-Layer Embeddings) | same |
| Context window | 128K tokens | 128K tokens |
| Modalities | Text, Image, Audio | Text, Image, Audio |
What is PLE?
Unlike the Gemma 4 26B which uses Mixture-of-Experts (MoE), the E2B uses Per-Layer Embeddings β a learned per-layer specialization mechanism. Each of the 35 decoder layers gets its own 256-dimensional signal derived from both the token identity (via a second embedding table) and the evolving hidden representation. This is a continuous alternative to discrete MoE routing β no expert selection, no sparsity, just dense computation with layer-specific conditioning.
Speed
Tested on DGX Spark (GB10 Blackwell, SM 12.1):
| Metric | NVFP4 |
|---|---|
| Tokens/sec | ~90 tok/s |
| Model load | ~7.5 GB VRAM |
Serving with vLLM
Requires vLLM with transformers >= 5.4 (for Gemma 4 architecture support). No patches needed β vanilla vLLM handles E2B NVFP4 directly.
vllm serve bg-digitalservices/Gemma-4-E2B-NVFP4A16 \
--quantization modelopt \
--dtype auto \
--kv-cache-dtype fp8 \
--gpu-memory-utilization 0.30 \
--max-model-len 131072 \
--trust-remote-code
DGX Spark
VLLM_NVFP4_GEMM_BACKEND=marlin vllm serve bg-digitalservices/Gemma-4-E2B-NVFP4A16 \
--quantization modelopt \
--dtype auto \
--kv-cache-dtype fp8 \
--gpu-memory-utilization 0.10 \
--max-model-len 131072 \
--trust-remote-code
Testing
This is a base model. Use completions or chat endpoints:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"bg-digitalservices/Gemma-4-E2B-NVFP4A16","messages":[{"role":"user","content":"Hello!"}],"max_tokens":200}'
Quantization Details
- Method: NVIDIA Model Optimizer (modelopt) v0.43
- Format: NVFP4 β E2M1 weights with per-group FP8 scales (group size 16)
- Calibration: 512 samples from CNN/DailyMail, batch size 4, seq_len 1024
- Excluded from quantization: Vision tower, audio tower, vision/audio projection layers, lm_head (all stay BF16)
- Hardware: NVIDIA DGX Spark (GB10 Blackwell)
- Quantization script: included as
quantize.py
Limitations
- Requires vLLM with
transformers >= 5.4 - Vision/audio towers stay BF16 (β5 GB of the 7.5 GB total) β excluded to preserve multimodal quality
- Community quantization, not an official NVIDIA or Google release
License
Apache 2.0 β inherited from the base model.
Credits
Quantized by Mario Iseli on an NVIDIA DGX Spark. Built and validated with AI-engineering assistance from Anthropic.
Shout-out to eugr/spark-vllm-docker for the DGX Spark-optimized vLLM build.
π¬ mario@marioiseli.com β Buy me a coffee if this makes your Spark go brrrrrr! π
- Downloads last month
- 22
Model tree for bg-digitalservices/Gemma-4-E2B-NVFP4A16
Base model
google/gemma-4-E2B