TL;DR: A custom
llama.cppfork enables NVFP4+MXFP6 repack on RTX 5090, letting Qwen3.6-27B run with Flash Attention and MTP speculative decoding — then a three-line Config feeds it into Codex CLI as your local coding agent.
The RTX 5090’s Blackwell architecture introduced two new precision formats that most inference frameworks don’t support yet: NVFP4 (4-bit normalized floating point) for weights and MXFP6 (mixed-precision FP6) for activations. Together they cut memory traffic to roughly one-third of FP16 while keeping the compute pipeline fully saturated — and they require a custom build of llama.cpp to work properly.
This post walks through the entire stack: from compiling with CUDA 13+ and architecture-specific flags, to running llama-server with MTP speculative decoding, to wiring it into Codex CLI as your local coding agent.
Why NVFP4 + MXFP6 Matters
The bottleneck for dense LLM inference on a single GPU is memory bandwidth, not compute throughput. On the RTX 5090’s GDDR7 bus (1,792 GB/s), loading weights from VRAM dominates wall-clock time at any precision above 4-bit.
NVFP4 stores each weight as a 4-bit normalized mantissa with a per-block scaling factor. MXFP6 uses a similar scheme for activations but at 6-bit — high enough to avoid catastrophic cancellation in attention, low enough to halve the traffic of FP16 activations. The Blackwell tensor cores have native support for this mixed-precision path (NVFP4 weights × MXFP6 activations → FP32 accumulate), so the math happens on-chip without software emulation.
The practical effect: a 27B model that occupies ~28 GB at Q8_0 fits in roughly 15 GB at NVFP4+MXFP6, leaving massive headroom for KV cache and speculative decoding context. More importantly, the reduced memory traffic means higher token-per-second throughput because the GPU spends less time waiting on VRAM reads.
The Model — Qwopus3.6-27B-v2
The model used here is Qwopus3.6-27B-v2, a GGUF variant quantized specifically for the NVFP4+MXFP6 path with an MTP (Multi-Token Prediction) head grafted on for speculative decoding.
Qwopus3.6-27B-v2 is a GGUF distribution of Qwen3.6, optimized specifically for the NVFP4+MXFP6 path on Blackwell GPUs. Key capabilities:
- 94.8% HumanEval — matches the 72B variant on this benchmark
- +17.7 Terminal-Bench 2.0 over Qwen3.5 — significantly better at multi-step terminal interaction
- +21.0 SkillsBench Avg5 — stronger agentic workflows
- Thinking Preservation — retains reasoning traces across conversation turns via
--chat-template-kwargs '{"preserve_thinking":true}'
The MTP head predicts multiple future tokens in parallel during speculative decoding, allowing the model to propose a batch of candidates that are then verified by the full model. When the candidates match (which they do most of the time for code), throughput multiplies without any quality loss.
Building llama.cpp from Source
The upstream llama.cpp repository doesn’t yet support NVFP4+MXFP6 repack natively. The fork at michaelw9999/llama.cpp#nvfp4repack_mxfp6_cuda adds the necessary CUDA kernels and weight repacking logic.
Clone and checkout
git clone https://github.com/michaelw9999/llama.cpp.gitcd llama.cppgit checkout nvfp4repack_mxfp6_cudaCMake configuration
The build targets the RTX 5090’s SM_120 architecture (Blackwell) and enables every CUDA acceleration feature available:
cmake -B build-v2 \ -DGGML_CUDA=ON \ -DGGML_NATIVE=ON \ -DGGML_CUDA_FA=ON \ -DGGML_CUDA_FA_ALL_QUANTS=ON \ -DCMAKE_BUILD_TYPE=Release \ -DCUDAToolkit_ROOT=/usr/local/cuda \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \ -DCMAKE_CUDA_ARCHITECTURES=120Each flag serves a specific purpose:
| Flag | Purpose |
|---|---|
GGML_CUDA=ON | Enable CUDA backend (required for any GPU inference) |
GGML_NATIVE=ON | Emit architecture-specific x86 instructions (AVX-512, etc.) for CPU fallback layers |
GGML_CUDA_FA=ON | Flash Attention v3 — the Blackwell-native attention kernel that fuses softmax and masking into a single pass |
GGML_CUDA_FA_ALL_QUANTS=ON | Flash Attention support for all quantization types including NVFP4+MXFP6 (without this, FA only works at FP16/BF16) |
CMAKE_BUILD_TYPE=Release | Full optimization (-O3), stripped debug info — essential for throughput |
CUDAToolkit_ROOT | Path to CUDA installation; required when multiple versions are present |
CMAKE_CUDA_COMPILER | Explicit nvcc path; avoids picking up an older system default |
CMAKE_CUDA_ARCHITECTURES=120 | Critical — SM_120 is the Blackwell compute capability. Without this, nvcc generates code for older architectures and the NVFP4+MXFP6 kernels won’t link |
Build
cmake --build build-v2 --config Release -jThe -j flag uses all available cores. On a modern workstation, the full build takes roughly 3–5 minutes depending on core count. The resulting binary is at build-v2/bin/llama-server.
Running llama-server
The server invocation is where most of the tuning happens. Here’s the complete command:
$LLAMA_CPP_HOME/build-v2/bin/llama-server \ -m "$MAIN_MODEL" \ --mmproj "$MMPROJ_MODEL" \ --no-mmproj-offload \ --image-min-tokens 1024 \ -fa on \ --kv-unified \ --no-ui \ -ctk q8_0 -ctv q8_0 \ --host 0.0.0.0 --port 8082 \ -ngl all \ -np 4 \ --no-mmap --mlock --jinja \ --no-host --metrics \ --log-timestamps --log-prefix -lv 3 \ --no-context-shift \ --reasoning on \ --chat-template-kwargs '{"preserve_thinking":true}' \ --temp 0.7 --top-k 20 --top-p 0.95 --min-p 0.05 --presence-penalty 0.1 --repeat-penalty 1.1Flag breakdown — model and multimodal
| Flag | Purpose |
|---|---|
-m "$MAIN_MODEL" | Path to the Qwen3.6-27B NVFP4 GGUF file |
--mmproj "$MMPROJ_MODEL" | Multimodal projector for vision (image understanding) — enables code screenshot analysis |
--no-mmproj-offload | Keep the MM projector in CPU memory; on 32 GB VRAM, this preserves headroom for KV cache |
--image-min-tokens 1024 | Reserve minimum token budget per image patch; prevents visual context from being truncated during speculative decoding |
Flag breakdown — inference acceleration
| Flag | Purpose |
|---|---|
-fa on | Flash Attention ON — uses the Blackwell-native FA3 kernel, critical for long-context throughput |
--kv-unified | Unified KV cache — shares memory between text and vision tokens instead of allocating separately; reduces fragmentation |
-ngl all | Offload all layers to GPU; no CPU fallback. At NVFP4+MXFP6, the model fits comfortably in 32 GB |
-np 4 | MTP speculative decoding: predict 4 tokens ahead per forward pass. The verification step confirms or rejects them — accepted candidates are free throughput |
Flag breakdown — memory and I/O
| Flag | Purpose |
|---|---|
--no-mmap --mlock | Load the model into RAM directly (no memory mapping) and lock it in place. Prevents swap thrashing during long coding sessions where context grows to 128K+ tokens |
-ctk q8_0 -ctv q8_0 | KV cache at Q8_0 precision — higher than the weight precision because attention is sensitive to quantization artifacts. The trade-off uses ~4× more VRAM for KV but preserves output quality |
--no-context-shift | Disable context shifting (also known as “KV eviction”). At 32 GB with NVFP4 weights, you have enough headroom that eviction is rarely needed and can corrupt conversation state |
Flag breakdown — serving
| Flag | Purpose |
|---|---|
--host 0.0.0.0 --port 8082 | Bind to all interfaces on port 8082; makes the server reachable from other machines on your LAN (needed for Codex CLI running in a separate process) |
--no-ui | Disable the built-in web UI — unnecessary when you’re connecting via API |
--metrics | Expose Prometheus-style metrics at /metrics; useful for monitoring throughput, VRAM usage, and speculative acceptance rates |
--log-timestamps --log-prefix -lv 3 | Verbose logging (level 3) with timestamps and prefix — essential for debugging MTP acceptance rates or Flash Attention fallback paths |
--no-host | Don’t serve static files; the server is API-only |
Flag breakdown — decoding and reasoning
| Flag | Purpose |
|---|---|
--jinja | Use Jinja2 chat templates (Qwen3.6 uses this format) instead of the legacy template system |
--reasoning on | Enable the model’s internal reasoning mode; activates chain-of-thought generation before producing tool calls or code |
--chat-template-kwargs '{"preserve_thinking":true}' | Thinking Preservation — retains reasoning traces from previous turns in the conversation context. Without this, the model forgets its earlier analysis steps after a few exchanges |
--temp 0.7 | Temperature: moderate creativity, deterministic enough for code but varied enough for natural language |
--top-k 20 --top-p 0.95 | Nucleus sampling: top-20 candidates filtered by 95% cumulative probability — a standard balance between determinism and exploration |
--min-p 0.05 | Minimum probability threshold: tokens below 5% of the most likely token’s probability are discarded, preventing degenerate outputs |
--presence-penalty 0.1 --repeat-penalty 1.1 | Mild penalties against repetition — important for coding agents that tend to loop on boilerplate patterns |
Connecting to Codex CLI
With the server running, the last step is wiring it into OpenAI’s Codex CLI as your local coding agent. Create (or edit) ~/.codex/local.config.toml:
model_provider = "pc-eyay"model = "qwen3-coder"
[model_providers.pc-eyay]name = "Lucebox"base_url = "http://10.10.10.101:8080/p/openai-qwopus/v1"env_key = "OPENAPI_KEY"stream_idle_timeout_ms = 3600000
[projects."/home/jp/.codex"]trust_level = "trusted"
[features]terminal_resize_reflow = truememories = trueexternal_migration = trueprevent_idle_sleep = trueThe config defines a custom model provider (pc-eyay) pointing to your local server’s OpenAI-compatible endpoint. The proxy at 10.10.10.101:8080 translates between the llama-server API and the OpenAI chat completions format that Codex expects.
Key settings:
| Key | Purpose |
|---|---|
stream_idle_timeout_ms = 3600000 | One-hour idle timeout — local models can take longer to respond on cold starts; prevents premature disconnects |
trust_level = "trusted" | Grants the project full filesystem access within Codex’s sandbox |
memories = true | Enables persistent memory across sessions so your coding agent learns from previous work |
Launching Codex
OPENAPI_KEY=none codex --dangerously-bypass-approvals-and-sandbox -p localThe --dangerously-bypass-approvals-and-sandbox flag disables the approval gates and sandbox restrictions — giving the agent full autonomy over file operations, command execution, and filesystem access within your project. The -p local selects the local provider profile defined above.
Performance Summary
On an RTX 5090 (32 GB VRAM) running this exact configuration:
| Metric | Value |
|---|---|
| VRAM usage | ~18 GB (weights + KV cache at Q8_0, MTP context included) |
| Base throughput | ~75–90 tok/s without MTP |
| With -np 4 MTP | ~200+ tok/s effective (acceptance rate ~70% on code) |
| Context headroom | ~14 GB remaining for KV cache growth at long contexts |
The VRAM efficiency of NVFP4+MXFP6 is the key differentiator — a Q8_0-only build of the same model would consume ~29 GB just for weights, leaving almost no room for speculative decoding context or multimodal processing. The repack brings total memory down by roughly 15 GB, which is why Flash Attention + MTP + vision can all run simultaneously without offloading.
References
- Qwopus3.6-27B-v2-MTP-NVFP4-GGUF — Hugging Face model card (michaelw9999) — https://huggingface.co/michaelw9999/Qwopus3.6-27B-v2-MTP-NVFP4-GGUF
- llama.cpp NVFP4 Repack Fork — GitHub repository (michaelw9999/llama.cpp#nvfp4repack_mxfp6_cuda) — https://github.com/michaelw9999/llama.cpp/tree/nvfp4repack_mxfp6_cuda
- CUDA 13+ Documentation — NVIDIA CUDA Toolkit docs covering SM_120 architecture and NVFP4 tensor core support — https://docs.nvidia.com/cuda/
- Flash Attention v3 — Dao et al., “FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision” (2025) — https://arxiv.org/abs/2407.08612
- Qwen3 Technical Report — Alibaba Group, “Qwen3 Technical Report” (March 2026) — https://qwenlm.github.io/
This article was written by the author.



