cd /news/ai-infrastructure/show-hn-airmind-zig-and-metal-qwen4-… · home › topics › ai-infrastructure › article
[ARTICLE · art-182742] src=github.com ↗ pub= topic=ai-infrastructure verified=true sentiment=↑ positive

Show HN: AirMind – Zig and Metal Qwen4-35B engine and local agent for 16GB Macs

A developer released AirMind, a zero-dependency inference engine written from scratch in Zig 0.17.1 with custom Apple Metal GPU shaders, built to run the Qwen4-35B-A3B model and a built-in local coding agent on 16 GiB MacBooks without swap. In its default IQ2 Resident Mode, AirMind holds a 10.6 GiB UD-IQ2_XXS model fully in unified memory and reports 250–300 tok/s prefill and 25–36 tok/s decode, while a 4-bit streaming mode (--iq4) reaches 14–18 tok/s decode and 70–120 tok/s prefill on 16 GiB of RAM. The engine ships a disk-persisted KV+GDN prefix cache that restores 1,100+ system and tool tokens in about 54 ms on repeat launches, zero-RAM stochastic N-gram speculative decoding that accepts up to roughly 40% free tokens, 9 built-in agent tools, and an OpenAI-compatible HTTP server via `airmind serve`.

key takeaway

AirMind runs Qwen4-35B-A3B on a 16 GiB Mac by keeping a 10.6 GiB UD-IQ2_XXS model fully resident in unified memory (25–36 tok/s decode) or streaming 4-bit weights through a 2-slab GPU hot-expert LRU cache (14–18 tok/s decode), with a disk-persisted KV+GDN prefix cache restoring 1,100+ tokens in ~54

read5 min views2 publishedDec 6, 2026
Show HN: AirMind – Zig and Metal Qwen4-35B engine and local agent for 16GB Macs
Image: Michielbdejong (auto-discovered)

Zero-dependency Zig + Apple Metal GPU inference engine and built-in local coding agent for Qwen4-35B-A3B — engineered to run fast on a 16 GiB MacBook.

AirMind compiles to a single native binary with zero external runtime dependencies (no Python runtime required for inference, no llama.cpp, no PyTorch, no HTTP hop between the agent and the model). Just run ./zig-out/bin/airmind to launch a resident in-process coding & web agent powered by custom Metal shaders.

  • From-Scratch Zig 0.17.1 + Native Apple Metal GPU - Custom simdgroup_matrix hardware GEMM prefill, 0-barrier warp QSA attention, 128-TG in-register GDN recurrence, and adaptive expert-grouped MoE.

    • Full 13-format GGML quantization support (F32 ,F16 ,BF16 ,Q8_0 ,Q4_K ,Q5_K ,Q6_K ,IQ4_NL ,IQ4_XS ,IQ3_XXS ,IQ2_S ,IQ2_XS ,IQ2_XXS ), bit-exact againstlibggml .
  • Custom

  • Built-In In-Process Coding & Web Agent (Default Mode) - Bare ./zig-out/bin/airmind launches directly into an interactive coding agent withzero HTTP overhead between the agent loop and the GPU engine.

    • 9 built-in tools :
      • Auto-run read-only: list_files ,read_file ,grep_files ,web_search (no API key),web_fetch ,plot_chart (Unicode sparkline + bar chart).
      • Interactive approval ([y]es / [n]o / [a]lways or--yolo ):write_file ,edit_file ,run_shell .
    • Auto-run read-only:
    • UTF-8 / CJK-aware terminal line editor : full Left/Right/Home/End cursor navigation, mid-line insert/delete across wrapped Chinese + English text, Up/Down history, live prefill/tool-generation progress bars, and automatic two-stage context compaction.
  • Bare

  • Instant Startup & Speculative Acceleration - Disk-persisted KV+GDN prefix cache (/tmp/airmind_prefix_*.zqs ): restores 1,100+ system + tool tokens in**~54 ms** on repeat launches (~1s cold boot to ready).

    • Zero-RAM Stochastic N-gram Speculative Decoding : exact Leviathan rejection sampling compatible withtemperature ,min_p , andrepeat_penalty — accepts up to**~40% free tokens** when generating code & unit tests with0 MiB extra weights.
  • Fits 16 GiB Apple Silicon Without Swap - IQ2 Resident Mode (default on ≤18 GiB Macs) : 10.6 GiBUD-IQ2_XXS fully resident in unified memory (250–300 tok/s prefill,25–36 tok/s decode).

    • 4-Bit Streaming Mode (--iq4) : explicit 2-slab GPU Hot-Expert LRU Cache + 8-thread F_NOCACHE NVMe streaming (14–18 tok/s decode,70–120 tok/s prefill on 16 GiB RAM, zero desktop lag).
    • Optional Loop4-HC v3.0 Recurrent Depth (--smart / --deep) : zero-LoRA 34.8 MB BF16 Depth-AttnRes sidecar looping L12..27 (T=2/3 , Prompt-Split keeps full prefill speed) + bounded--think-budget .
  • OpenAI-Compatible HTTP Server (airmind serve) - Full SSE streaming, OpenAI tools /delta.tool_calls /role: "tool" , and multi-conversation KV+GDN state snapshotting.

  • Full SSE streaming, OpenAI

  • macOS on Apple Silicon (M1/M2/M3/M4, 16 GiB+ Unified Memory recommended; pure-Zig CPU fallback included)

  • Zig 0.17.1 ( brew install zig )

zig build setup

./zig-out/bin/airmind

Other build & setup options:

zig build setup -Dmodel=iq2      # Force 2-bit full-resident model + Loop4-HC sidecar
zig build setup -Dmodel=iq4      # Force 4-bit UD-IQ4_XS (hardlinks Shard 2 if IQ2 exists)
zig build setup -Dmodel=all      # Download both IQ2 and IQ4 + Loop4-HC sidecar
zig build                        # Offline build only (defaults to ReleaseFast)
zig build test                   # Run full unit test suite (Debug safety checks)
./zig-out/bin/airmind

./zig-out/bin/airmind --smart            # Loop4-HC v3.0 T=2 Prompt-Split (higher IQ, full prefill speed)
./zig-out/bin/airmind --deep             # Loop4-HC T=2 + 320-token bounded <think> chain
./zig-out/bin/airmind --iq4              # True 4-bit UD-IQ4_XS with GPU Hot-Expert LRU Cache + NVMe streaming
./zig-out/bin/airmind --yolo             # Auto-approve write_file / edit_file / run_shell
./zig-out/bin/airmind --no-agent         # Plain interactive chat REPL without tools

./zig-out/bin/airmind serve --port 8080 -c 16384

./zig-out/bin/airmind chat -p "Explain Fermat's Little Theorem briefly"
./zig-out/bin/airmind --help
Command Action
/agent Toggle built-in agent tools ON / OFF
/yolo Toggle auto-approval for write_file ,edit_file ,run_shell
/think Toggle Qwen4 <think> reasoning mode
/compact Compact older tool outputs / conversation history
/clear Clear conversation & instantly restore disk-cached system prompt
/stats Show context usage and last-turn speed
/quit Exit
Mode Memory Strategy Prefill Decode Notes
UD-IQ2_XXS (default) 10.6 GiB RAM resident 210–300 tok/s 28–36 tok/s Zero SSD I/O; ~40% free tokens on code via 0-MiB N-gram spec
UD-IQ2_XXS --smart 10.7 GiB RAM resident 200–290 tok/s 15–22 tok/s Loop4-HC T=2 Prompt-Split (+33% on 10-problem math/logic bench)
UD-IQ4_XS --iq4 1.94 GiB dense + 8.7 GiB GPU LRU 74–120 tok/s 15–18 tok/s Soft-threshold 4-bit streaming, zero swap on 16 GiB
Repeat agent startup Disk KV+GDN snapshot (85 MiB) 54 ms restore — Cold boot to interactive Agent> in ~1s
src/
├── main.zig           # CLI entry, Apple Silicon hardware probe, auto-config presets
├── root.zig           # Library module exports & test root
├── gguf.zig           # Zero-dependency multi-shard GGUF v3 parser + mmap
├── quant.zig          # Pure-Zig CPU dequant & SIMD dot products (13 GGML formats)
├── quant_tables.zig   # IQ2 / IQ3 / IQ4_NL / IQ4_XS lookup tables
├── tokenizer.zig      # Native BPE tokenizer + Qwen4 special tokens
├── sampler.zig        # 8-wide SIMD sampler (min_p, top_p, repeat_penalty, Leviathan spec verify)
├── qwen4.zig          # Qwen4-35B-A3B architecture (GDN, QSA, Engram PLE, HC, MoE) CPU reference
├── metal.zig          # Apple Metal GPU engine, batched prefill, state snapshots, MTP/N-gram spec
├── qwen4.metal        # Custom Metal compute shaders (simdgroup_matrix, fused GDN/QSA/MoE/Loop)
├── metal_bridge.h/.m  # Minimal Objective-C ARC Metal C-ABI bridge
├── expert_cache.zig   # O(1) 2-slab GPU Hot-Expert LRU Cache + 8-thread F_NOCACHE NVMe streamer
├── loop4hc.zig        # Zero-dependency safetensors parser & Loop4-HC v3.0 Depth-AttnRes 
├── agent.zig          # Built-in 9-tool local coding, web search/fetch & terminal chart agent
└── server.zig         # In-process Agent REPL (UTF-8/CJK line editor, auto-compact) + OpenAI HTTP server
── more in #ai-infrastructure 4 stories · sorted by recency
── more on @airmind 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-airmind-zig-…] indexed:0 read:5min 2026-12-06 · —