NariQ Qwen3.8-27B: Sub-3-Bit Quantization for Local Coding Agents

NariQ Qwen3.8-27B is Nari Labs' trellis-coded post-training quantization release (arXiv:2611.26157) that compresses the 53.8 GB BF16 Qwen3.8-27B model into 10.12 GB (3.0 bpw) and 8.44 GB (2.5 bpw) GGUF checkpoints under Apache-2.0. Calibrated exclusively on model-written tokens from long-horizon coding trajectories, NariQ achieves 41.0% to 41.9% pass@1 on DeepSWE v1.1 and 63.8% on Terminal-Bench 2.1—matching BF16 on single 16 GB to 24 GB GPUs.
NariQ Qwen3.8-27B: Sub-3-Bit Quantization for Local Coding Agents: NariQ Qwen3.8-27B is Nari Labs' trellis-coded post-training quantization release (arXiv:2611.26157) that compresses the 53.8 GB BF16 Qwen3.8-27B model into 10.12 GB (3.0 bpw) and 8.44 GB (2.5 bpw) GGUF checkpoints under Apache-2.0. Calibrated exclusively on model-written tokens from long-horizon coding trajectories, NariQ achieves 41.0% to 41.9% pass@1 on DeepSWE v1.1 and 63.8% on Terminal-Bench 2.1—matching BF16 on single 16 GB to 24 GB GPUs. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- BF16 Parity Under 3 Bits: NariQ 3.0 bpw (10.12 GB) solves 47 of 113 DeepSWE v1.1 tasks (84.9% test score) and hits 63.8% on Terminal-Bench 2.1 vs 44 tasks and 62.6% for 53.8 GB BF16.
- Model-Written Token Calibration: Masks out noisy tool outputs and raw file dumps during KL calibration, focusing gradient-based mixed-precision bit allocation on assistant-generated reasoning and tool calls.
- Frequency-Banded Output Head: Splits the 248,320-row lm_head into 16 probability-ranked bands of ~15,500 rows with a 2-bit floor, cutting mean per-trial agent KL by 12.1% at 3.0 bpw.
- Single-GPU 135K–160K Context: Fits Qwen3.8-27B-NariQ-3.0bpw (10.12 GB) plus the 0.93 GB BF16 vision projector and ~135K tokens (or ~160K at 2.5 bpw) inside a single 24 GB GPU.
- Sovereign Smoke Monkey Integration: Connects directly to @smoke-monkey/harness and Smoke Monkey Canvas over OpenAI-compatible nari-llama.cpp endpoints with full <think> and XML tool-call support.
import { createAgent } from '@smoke-monkey/harness';// Connect Smoke Monkey Harness to local nari-llama.cpp serving NariQ Qwen3.8-27Bconst agent = createAgent({provider: 'openai',baseUrl: process.env.NARIQ_BASE_URL ?? 'http://127.0.0.1:8080/v1',apiKey: process.env.NARIQ_API_KEY ?? 'local-nariq',model: 'Qwen3.8-27B-NariQ-3.0bpw',agentId: 'build',workspacePath: process.cwd(),tools: ['filesystem', 'terminal', 'search', 'git', 'agent'],permission: 'ask-default',mcp: [{id: 'github',name: 'GitHub MCP',description: 'Inspect pull requests, issues, and repository checks',command: 'npx',args: ['-y', '@modelcontextprotocol/server-github'],enabled: true,},],});// Gate mutating shell commands while auto-allowing safe test runs and read-only inspectionagent.on('permission.required', (event) => {const allowedTools = ['read_file', 'grep', 'glob', 'git_diff', 'git_status', 'run_test'];const decision = allowedTools.includes(event.data.toolName) ? 'allow' : 'deny';agent.resolvePermission(event.data.toolCallId, decision);});agent.on('phase.changed', (event) => {console.log(`[NariQ-3.0bpw] Phase -> ${event.data.phase}`);});async function main() {const result = await agent.run('Trace memory leaks in src/worker.ts, patch the buffer pool, and verify with npm test.');console.log('Status:', result.status, 'Session:', result.sessionId);}main().catch(console.error);
Watch: Related Video Guides
ISTA vs Unsloth: 7 Qwen3.8 27B Quants Tested—Which One Should You Download?
Qwen3.8-27B GGUF: Run It Local with llama.cpp, Ollama & LM Studio
What Is NariQ Qwen3.8-27B? Sub-3-Bit Agentic Quantization Explained
NariQ Qwen3.8-27B is a suite of 3.0, 2.5, and 2.0 bits-per-weight (bpw) trellis-coded GGUF quantizations of Alibaba's 27B hybrid-attention Qwen3.8-27B model, released by Nari Labs under Apache-2.0 (arXiv:2611.26157). By calibrating and allocating bit widths strictly around assistant-generated tokens in real multi-turn coding sessions, NariQ preserves full BF16 agent reliability inside an 8.44 GB to 10.12 GB footprint.
Prior sub-3-bit quantizations fail catastrophically on long-horizon software engineering even when short-context perplexity or math scores look intact. On Qwen3.8-27B, existing 3.0 bpw checkpoints such as GSQ-RCO IQ3_XXS retain 96.9% accuracy on AIME (within one point of BF16's 97.7%), yet solve only 63% as many tasks as BF16 on DeepSWE v1.1—where an average task spans 150 tool calls, 50 minutes, and a 92K-token median context.
That divergence stems from calibration objective mismatch. Standard post-training quantization (PTQ) minimizes error over random 2K–4K chunks of web text and treats every token identically. In an autonomous coding trajectory, over 80% of context tokens are raw compiler logs, test runner output, and source files returned by tools—not tokens the model must predict accurately during generation.
NariQ Artifact Lineup & Precision Specs
| Release Artifact | Effective Bitrate | File Size | Role & Recommended Hardware |
|---|---|---|---|
Qwen3.8-27B-NariQ-3.0bpw.gguf | 3.00 bpw | 10.12 GB | Default checkpoint; matches or exceeds BF16 on DeepSWE & Terminal-Bench 2.1 |
Qwen3.8-27B-NariQ-2.5bpw.gguf | 2.50 bpw | 8.44 GB | Memory-constrained 16 GB–24 GB GPUs; maintains BF16-level DeepSWE solve rate |
Qwen3.8-27B-NariQ-2.0bpw.gguf | 2.00 bpw | 6.75 GB | Ultra-compact edge tier; drops 7.3 pts on DeepSWE and 11.7 pts on AIME |
Qwen3.8-27B-NariQ-mmproj-BF16.gguf | 16.0 bpw | 0.93 GB | Shared BF16 vision projector for UI screenshots, charts, and diagrams |
Note that Qwen3.8-27B BF16 text + vision + MTP weighs 55.6 GB (53.8 GB text-only). NariQ quantizes the 26.9B language backbone into the compact GGUF while keeping the 0.93 GB vision tower in BF16 and omitting the Multi-Token Prediction (MTP) head for v1.
How NariQ Works: Model-Token KL, Trellis Coding, and Banded Heads
NariQ builds on QTIP bitshift trellis codes with randomized Hadamard rotations and YAQA two-sided curvature rounding, adding four domain-specific optimizations for long-horizon agents: model-written token KL masking, Hessian-based gradient loss allocation, 16-band frequency-ranked output heads, and 70:30 coding-to-general scale tuning.
At 2 to 3 bits per weight, pure weight-format changes hit diminishing returns because randomized Hadamard rotations already render weight matrices nearly Gaussian, where trellis codes operate within ~10% of the theoretical rate-distortion bound (0.069 MSE vs 0.063 bound at 2 bits). NariQ therefore shifts optimization effort from the codebook geometry to which tokens and layers receive precision:
- Model-Written Token KL Masking: Given a BF16-generated coding session prefix
x_<t(including full tool outputs), the calibration lossLcomputes KL divergenceKL(p_BF16 || p_quant)strictly over index setMof tokens generated by the assistant. Tool outputs stay in the prefix context, so activation statistics reflect realistic 100K-token states without letting verbose bash logs dominate the loss. - Gradient-Derived Module Loss & Knapsack Allocation: Because trellis quantization errors across different bit widths are nearly orthogonal (measured curvature-weighted cosine similarity between 3-bit error and 2/4/5-bit errors is just
0.035,0.009, and0.004), standard first-order RCO width-change scores collapse to-2 * l_cregardless of destination bit width. NariQ inverts that identity to estimate each module's current quadratic lossl_c = 0.5 * <G, W_c - W_k>, rescales across widths vial_k = l_c * (r_k / r_c)(where trellis MSE drops ~4x per bit), adds a two-standard-error margin, and solves a dynamic-programming multiple-choice knapsack with a hard 2-bit floor on every linear layer. - 16-Band Frequency-Ranked Output Layer: Only ~13% of
Qwen3.8-27B's 248,320 vocabulary tokens appear as generated outputs in coding calibration traces, yet every row participates in the softmax. Because KL logit curvature scales withp(1 - p), NariQ sortslm_headrows by mean predicted probability into 16 bands of ~15,500 rows each and allocates per-band bit widths (minimum 2 bits to protect multilingual and rare tokens), cutting mean per-trial agent KL by 12.1% at 3.0 bpw. - 70:30 Mixed Scale & Norm Tuning: After freezing discrete trellis codes and widths, NariQ fine-tunes continuous block scales and RMSNorm weights against a 70:30 mix of coding-agent traces and BF16 replies across math, science, chat, and long documents—rescuing 2.0 bpw AIME 25+26 accuracy from
77.3%to86.0%.
NariQ GGUF v1 Binary Layout (trellis.version = 1)
Unlike stock GGUF scalar or k-quant blocks, NariQ introduces fork-specific GGML tensor types GGML_TYPE_TRL1 through GGML_TYPE_TRL6 (type IDs 44–49, block size 16, byte size 2 * bits). Weights of shape [K, N] are stored in output-tile-major order across 16x16 tiles (16 * bits int16 code words per tile) alongside F16 trellis_s16 scales, F32 trellis_pre/trellis_post sign-scale vectors, optional I32 trellis_pin/trellis_pout gather permutations, and trellis.desc.<w> metadata describing block Sylvester or whole-slice Paley-Hadamard transforms (m * 2^j for m in {1, 12, 20, 68}).
NariQ Qwen3.8-27B Benchmarks: DeepSWE v1.1, Terminal-Bench & Reasoning
Evaluated with Claude Code CLI (2.1.309, max thinking effort, 262,144-token context, temperature=1.0, top_p=0.95, top_k=20), NariQ 3.0 bpw solves 47 of 113 DeepSWE v1.1 tasks (41.0% 3-round mean pass@1, 84.9% single-attempt test score) and reaches 63.8% on Terminal-Bench 2.1—matching or outperforming the 53.8 GB BF16 baseline.
Long-Horizon Agentic Comparison (NariQ vs Unsloth, GSQ-RCO & EXL3)
In the table below, NariQ runs single-attempt DeepSWE v1.1 and 3-attempt Terminal-Bench 2.1 (82 tasks) under Claude Code, while competing sub-4-bit releases reflect Unsloth's published mini-swe-agent evaluations. Percentages in the % BF16 columns normalize each file against its own harness's BF16 baseline:
| Quantization Checkpoint | Effective Bits | DeepSWE Solved (of 113) | DeepSWE (% of BF16) | Terminal-Bench 2.1 | Terminal-Bench (% of BF16) |
|---|---|---|---|---|---|
| BF16 Baseline (Nari Harness) | 16.00 | 44.0 (3-rd mean: 45.0) | 100% | 62.6% | 100% |
| NariQ 3.0 bpw (`10.12 GB`) | 3.00 | 47.0 (3-rd mean: 46.3) | 107% | 63.8% | 102% |
| NariQ 2.5 bpw (`8.44 GB`) | 2.50 | 46.0 (3-rd mean: 47.3) | 105% | 60.2% | 96% |
| NariQ 2.0 bpw (`6.75 GB`) | 2.00 | 33.0 (3-rd mean: 32.3) | 75% | 52.4% | 84% |
Unsloth UD-IQ4_XS | 4.16 | 41.0 | 90% | 55.7% | 94% |
Unsloth UD-Q3_K_XL | 3.80 | 42.5 | 93% | 56.7% | 96% |
GSQ-RCO IQ3_S | 3.50 | 40.4 | 88% | 54.9% | 93% |
GSQ-RCO IQ3_XXS | 3.00 | 29.0 | 63% | 51.2% | 87% |
Unsloth UD-Q2_K_XL | 2.85 | 33.0 | 72% | 53.0% | 90% |
EXL3 2.20 bpw | 2.91 | 11.0 | 24% | 43.1% | 73% |
Unsloth UD-IQ2_S | 2.50 | 24.5 | 54% | 44.6% | 75% |
GSQ-RCO IQ2_XS | 2.50 | 19.0 | 42% | 37.8% | 64% |
Math, Multilingual, and Vision Retention
| Checkpoint | Size | AIME 25+26 (60 x 8) | MGSM (250 x 11 langs) | RealWorldQA (765 x 3) |
|---|---|---|---|---|
| BF16 | 53.8 GB | 97.7% (469) | 94.0% (2584) | 82.4% (1890) |
| NariQ 3.0 bpw | 10.12 GB | 98.3% (472) | 93.1% (2561) | 82.4% (1890) |
| NariQ 2.5 bpw | 8.44 GB | 96.5% (463) | 91.8% (2525) | 81.3% (1866) |
| NariQ 2.0 bpw | 6.75 GB | 86.0% (413) | 90.6% (2491) | 80.9% (1856) |
Across three full DeepSWE v1.1 rounds (339 trials per NariQ file), mean new-test pass rates were 82.9% (3.0 bpw) and 83.2% (2.5 bpw) versus 83.1% for BF16, proving that sub-3-bit trellis quantization preserves multi-hour debugging fidelity without silent logic degradation.
VRAM Footprint, KV Cache Math & Serving on nari-llama.cpp
Running NariQ Qwen3.8-27B requires Nari Labs' nari-llama.cpp fork (b12431-nariv0), as stock llama.cpp, Ollama, and LM Studio do not yet register GGML_TYPE_TRL1–TRL6 tensor loaders. On a single 24 GB GPU with the BF16 vision projector loaded, NariQ 3.0 bpw accommodates roughly 135K context tokens, while 2.5 bpw expands to 160K tokens.
Exact KV Cache & VRAM Footprint Math
Because Qwen3.8-27B uses a 3:1 hybrid decoder layout—64 total layers split into 48 linear-recurrence Gated DeltaNet layers and only 16 full Gated Attention layers (4 KV heads, 256 head dim)—its KV cache grows 4x slower than a standard 64-layer GQA model. However, nari-llama.cpp v1 retains BF16 KV cache and activations:
BF16 KV Cache per Token = 16 full-attn layers * 2 (K+V) * 4 KV heads * 256 head_dim * 2 bytes
= 65,536 bytes/token (64.0 KiB/token)
131,072-Token KV Cache = 131,072 * 64 KiB = 8.00 GiB
262,144-Token KV Cache = 262,144 * 64 KiB = 16.00 GiB
Total 24 GB Fit (3.0 bpw) = 10.12 GB weights + 0.93 GB mmproj + ~8.4 GB KV (~135K ctx) + ~3.5 GB SSM/compute
Total 262K Context VRAM = ~30 GB (3.0 bpw) | ~28 GB (2.5 bpw) | ~27 GB (2.0 bpw)On Windows, desktop compositing consumes ~1.5 GB of VRAM, so a 16 GB RTX 5060 Ti fits ~47K context tokens at 2.5 bpw + vision (decoding at ~38 tok/s). On NVIDIA RTX PRO 6000 (Blackwell SM120, -fa on -ctk bf16 -ctv bf16), single-session decode throughput scales cleanly:
| Context Length | NariQ 3.0 bpw (10.1 GB) | NariQ 2.5 bpw (8.4 GB) | NariQ 2.0 bpw (6.8 GB) | Unsloth UD-IQ3_XXS (10.9 GB) |
|---|---|---|---|---|
| 4K tokens | 88.9 tok/s | 99.2 tok/s | 111.7 tok/s | 94.7 tok/s |
| 16K tokens | 84.5 tok/s | 93.8 tok/s | 105.1 tok/s | 89.8 tok/s |
| 64K tokens | 70.7 tok/s | 77.5 tok/s | 85.0 tok/s | 74.8 tok/s |
Production Quickstart Commands (Linux CUDA, Docker & Manual Server)
# Option 1: One-command automated Linux launcher (NVIDIA driver >= 570, auto-fits context)
curl -fsSLO https://github.com/nari-labs/nari-llama.cpp/releases/download/b12431-nariv0/run.sh
bash run.sh 3.0 # or 2.5, 2.0
# Option 2: Docker with NVIDIA Container Toolkit
docker run --rm --gpus all -p 127.0.0.1:8080:8080 -v "$PWD:/models:ro" \
ghcr.io/nari-labs/nari-llama.cpp:b12431-nariv0 \
-m /models/Qwen3.8-27B-NariQ-3.0bpw.gguf \
--mmproj /models/Qwen3.8-27B-NariQ-mmproj-BF16.gguf \
--fit-target 2560 --min-p 0 --host 0.0.0.0 --port 8080
# Option 3: Manual server invocation with thinking-mode sampling
hf download nari-labs/Qwen3.8-27B-NariQ-GGUF \
Qwen3.8-27B-NariQ-3.0bpw.gguf Qwen3.8-27B-NariQ-mmproj-BF16.gguf --local-dir .
./nari-llama.cpp/llama-server \
-m Qwen3.8-27B-NariQ-3.0bpw.gguf --mmproj Qwen3.8-27B-NariQ-mmproj-BF16.gguf \
-ngl 99 -c 131072 --jinja --port 8080 \
--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0Hardware & Runtime Compatibility Constraints
Stock llama.cpp, Ollama, and LM Studio cannot load GGML_TYPE_TRL1-TRL6 tensors yet, and llama-quantize cannot requantize NariQ files. CUDA kernels are tuned for SM120 (RTX PRO 6000); Ampere/Ada/Hopper GPUs run slower, pre-Ampere GPUs fall back to CPU, and Apple Silicon Metal (M3 Pro ~3.8-4.9 tok/s) and ROCm are experimental source builds.
Orchestrating NariQ Agents in Smoke Monkey Harness & Canvas
Smoke Monkey Harness binds directly to nari-llama.cpp's OpenAI-compatible HTTP endpoint on port 8080, pairing Qwen3.8-27B's native <tool_call><function=name><parameter=key>value</parameter></function></tool_call> Jinja protocol and reasoning_effort controls with a deterministic 6-phase engineering loop and permission-gated MCP tools.
Because nari-llama.cpp exposes /v1/chat/completions with --jinja enabled, Smoke Monkey Harness runs multi-hour code exploration, AST-level file patching, test execution, and failure recovery completely offline on a single workstation GPU—without sending proprietary source trees to external APIs.
Sovereign Multi-Agent Patterns on Smoke Monkey Canvas
- Memory-Tiered Worker Pools: Allocate a
2.5bpw(8.44 GB) worker on a secondary 16 GB GPU for parallel codebase exploration and documentation indexing, while pinning3.0bpw(10.12 GB) with-c 131072on a 24 GB GPU for primary refactoring and root-cause debugging. - Reasoning Effort & Output Budgets: Keep
reasoning_effort: 'xhigh'(temperature=1.0,top_p=0.95,top_k=20) when executing multi-file edits inside thebuildagent role, or toggleenable_thinking: false(temperature=0.7,top_p=0.80,presence_penalty=1.5) for deterministic tool-routing subagents. - Human-in-the-Loop MCP Governance: Attach stdio or streamable-HTTP MCP servers (GitHub, Postgres, Playwright) via
@smoke-monkey/harnessand enforcepermission: 'ask-default'so read-only search tools auto-run while mutating terminal or database commands pause for explicit operator approval in Smoke Monkey Canvas (npx @smoke-monkey/canvas start).
Frequently Asked Questions
Q:Can I run NariQ Qwen3.8-27B GGUF files in Ollama, LM Studio, or upstream llama.cpp?
Not yet. NariQ GGUFs encode weights using custom trellis tensor types (GGML_TYPE_TRL1 through TRL6, IDs 44-49) and output-tile-major 16x16 layouts that upstream llama.cpp, Ollama, and LM Studio cannot parse. You must run them with Nari Labs' nari-llama.cpp fork (release b12431-nariv0) or its official Docker image.
Q:How much context fits on a 24 GB or 16 GB GPU with NariQ Qwen3.8-27B?
With the 0.93 GB BF16 vision projector loaded, a 24 GB GPU fits roughly 135K context tokens using NariQ 3.0 bpw (10.12 GB), 160K tokens at 2.5 bpw (8.44 GB), and 184K tokens at 2.0 bpw (6.75 GB). A 16 GB GPU such as an RTX 5060 Ti on Windows fits ~47K tokens at 2.5 bpw; full 262K context requires 27-30 GB VRAM.
Q:Why does NariQ 3.0 bpw match BF16 on DeepSWE when other 3-bit quants fail?
Standard sub-3-bit quants calibrate equally over all tokens in short web-text chunks, letting raw file dumps and tool logs drown out assistant outputs. NariQ masks KL divergence strictly to model-written tokens in real agent traces, allocates bits via gradient-derived Hessian loss estimates with a 2-bit linear floor, and splits the 248,320-row lm_head into 16 probability-ranked bands.
Q:Should I choose NariQ 3.0 bpw or 2.5 bpw for coding agents?
Choose NariQ 3.0 bpw (10.12 GB) as the default whenever you have 24 GB+ VRAM, as it achieves 63.8% on Terminal-Bench 2.1 and 98.3% on AIME 25+26 alongside 47/113 DeepSWE solves. Choose NariQ 2.5 bpw (8.44 GB) on 16 GB GPUs or when maximizing context length on 24 GB cards; avoid 2.0 bpw for complex reasoning.
Q:Does NariQ support Apple Silicon Macs or AMD Radeon GPUs?
Yes, experimentally via source builds. Nari Labs provides a Metal build path (nariq/run-mac.sh) tested at ~3.8 tok/s (3.0 bpw) and ~4.9 tok/s (2.0 bpw) on an M3 Pro, and a nariq/experimental-amd ROCm branch for RX 7900 XTX and RX 9070 XT. Note that CUDA kernels are currently optimized for SM120 Blackwell GPUs.
Q:How do I connect NariQ Qwen3.8-27B to Smoke Monkey Harness and MCP tools?
Start nari-llama.cpp llama-server with --jinja --port 8080 and the thinking-mode sampling flags (--temp 1.0 --top-p 0.95 --top-k 20 --min-p 0), then pass provider: 'openai' and baseUrl: 'http://127.0.0.1:8080/v1' to createAgent in @smoke-monkey/harness with your filesystem, terminal, and MCP server configs.
Related Alternatives & Comparisons
Claude Code Runtime Alternative: Open Source Stdio MCP Agent Harness
Openai Codex Alternative Open Source: Free Open Source AI Agent & Runtime (2026)
9 Best Free Open Source ChatGPT Alternatives in 2026 (Self-Hosted & Local)
LangChain TypeScript Alternative: Zero Dependencies & Deterministic Loops
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.