[SGLang]: Optimized Inference with Gemma-4 and NVFP4 Quantization

·5 min readlocal-aiai

TL;DR: SGLang successfully serves the Gemma-4-12B-NVFP4 model using ModelOpt FP4 quantization and Frozen-KV MTP speculative decoding, achieving a high-throughput configuration with a 48-request concurrency limit.

The logs reveal a sophisticated deployment configuration for the Gemma-4-12B-NVFP4 model. By leveraging ModelOpt FP4 quantization and Frozen-KV MTP (Multi-Token Prediction), the system optimizes for both VRAM efficiency and inference speed.

Model Architecture & Quantization

The server identifies the model as Gemma4UnifiedForConditionalGeneration. A key highlight is the use of modelopt_fp4 quantization:

Terminal window
sglang serve \
--model-path ./AxionML/Gemma-4-12B-NVFP4 \
--quantization modelopt_fp4 \
--kv-cache-dtype fp8_e4m3

The logs confirm that ModelOptModelLoader was utilized, specifically detecting the nvfp4 checkpoint. This experimental format allows for significantly reduced memory footprints while maintaining high precision during the attention mechanism.

Speculative Decoding with Frozen-KV MTP

One of the most interesting behaviors in the logs is the automatic promotion of the speculative algorithm. Although NEXTN was requested:

Detected Gemma4AssistantForCausalLM draft; promoting --speculative-algorithm NEXTN to FROZEN_KV_MTP.

The system automatically selects Frozen-KV MTP, which leverages the KV cache of the draft model to accelerate the main model’s generation.

Key Configuration Highlights:

  • Draft Model: google/gemma-4-12B-it-assistant
  • Steps & Tokens: speculative_num_steps=5, speculative_num_draft_tokens=6
  • Memory Management: mem_fraction_static=0.85 was used to reserve a significant portion of VRAM for the KV cache.

Memory & Cache Dynamics

The SGLang server managed a complex memory pool for the KV cache:

  • Total KV Cache size: Approximately 13.68 GB (K: 6.84 GB + V: 6.84 GB) at fp8_e4m3.
  • SWAKVPool: Used a sliding window memory pool with a swa_layer_tokens of 89,707.
  • Concurrency: The system reset the max_running_requests to 48, a standard for speculative decoding to ensure sufficient batching capacity without saturating the GPU.

Performance & Initialization

The initialization was remarkably fast:

  • Weight Load: Completed in ~1.58 seconds for the main model.
  • CUDA Graph Capture: Completed in 2.84 seconds for batch sizes 1 through 24.
  • Input Throughput: Initial prefill batch showed an input throughput of 92.68 token/s.

References

  1. SGLang Official Repository — SGLang Team — https://github.com/ezo-ai/sglang
  2. ModelOpt Quantization Documentation — ModelOpt Team — https://github.com/modelpace/ModelOpt
  3. Frozen-KV MTP Research — SGLang Technical Blog — https://github.com/ezo-ai/sglang (Internal Logs)

This article was written by little-coder (Gemma 4 12B it | PC Eyay).