A structural compression, mixed-precision optimization, and full-stack serving engineering release of dealignai/GLM-5.3-Flash-UNCENSORED-NVFP4 (320B MoE, 181.30 GiB, 288 routed experts/layer) engineered to run live on a single 122.8 GiB NVIDIA Jetson/Thor (sm_110, unified LPDDR5X) at 12–15.3 tok/s decode and ~535 tok/s flat prefill with 200K context (221,184 live FP8 KV tokens), 94.5%–97.3% multi-turn OpenCode prefix cache hits (up to 81.7K+ tokens verified live), NVMe HiCache, and native multimodal vision.
Everything needed to reproduce or serve this model is bundled directly in this repository:
DSpark (gamma=8) Speculator: ./dspark-onpolicy-lora-mxfp8/ (4.05 GiB, -731.4 MB vs BF16)../extras/scripts/.sglang SM110 / DSpark / HiCache Patches & Fused Triton FP8 MQA Indexer: ./extras/patches/.sglang Source Snapshot (with .git History): ./extras/packages/sglang-sm110-git.tar.gz (unpack with tar xzf sglang-sm110-git.tar.gz; the only modified inference package in the runtime venv — flashinfer-python 0.7.5.post1, torch 2.11.0+cu130, transformers 5.10.2, tilelang 0.1.15, and triton 3.6.0 are stock wheels)../extras/results/glm53_unique_reap_report.json & ./extras/PLAN.md.16 GB RTX 5060 Ti)This project is the direct scale-up of our earlier small-rig experiment:
On Qwen3.6-35B-A3B (256 → 128 experts, 67 GB → 13.08 GiB VRAM, 96.74 tok/s live on a single 16 GB RTX 5060 Ti sm_120), we discovered three core principles that turned out to scale dramatically better than expected to a 320B-class MoE:
<tool_call> delimiters and code-syntax triggers) while keeping redundant copies of generic prose experts. Unique-REAP (exact per-domain normalized output Gram matrix + Greedy Backward Schur-Complement Elimination + Peak-Token Hero Shield) preserves an orthogonal capability basis instead.NVFP4 prevents the long-context repetition loops that plague uniform 2-bit/4-bit quants.1.0 → 0.6 restores crisp BF16-like reasoning and tool-calling stability.GLM-5.3-Flash) on 122.8 GiB Unified Memory (amano)GLM-5.3-Flash (Glm5NextForConditionalGeneration) has 45 layers (3 dense + 42 MoE layers with 288 routed experts, top_k=8, 1 shared expert, 34 KDA linear-attention layers, 11 DeepSeek Sparse Attention MLA layers, hc_mult=4 multi-stream residuals, and a 347-tensor ViT vision encoder). Even already quantized in NVFP4, the base checkpoint is 181.30 GiB — far too big for 122.8 GiB unified RAM.
To profile a 181 GiB model on a 122 GiB machine without multi-node sharding, we wrote a single-node layerwise streaming profiler (01_profile_glm_layerwise.py) that streams 1 layer at a time onto Thor's GPU (~15–20 GiB peak) across 512 stratified calibration sequences (224,376 tokens: English prose, English→Code + XML tools, Japanese learning, Everyday Vision) and 128 held-out eval sequences (62,512 tokens).
Key Profiling Findings (glm53_unique_reap_report.json):
shared_expert alone contributes 31.48% of the mean MoE block output norm (mean_shared_ratio = 0.3148).128 / 288 routed experts (44.4%) retains 83.44% of raw REAP salience (82.32% Unique-REAP salience), while Unique-REAP's Schur-complement + Peak-Token Hero Shield performs an average of 14.38 expert swaps per layer (604 swaps across 42 MoE layers) compared to naive REAP—trading redundant clones for orthogonal specialists!Unique-REAP selects whole experts without weight averaging, 02_slice_glm_unique_reap.py slices the existing NVFP4 tensors and scales (weight, weight_scale, weight_scale_2, input_scale) directly with zero re-quantization error.NVFP4 + MXFP8 + BF16) -> 82.97 GiBAfter slicing to 128 routed experts (~92.7 GiB), we applied Unsloth-inspired dynamic protection rules in 04_quantize_glm_unsloth_mxfp8.py (--drop-mtp since we serve with DSpark):
BF16 (100% protected): embed_tokens, lm_head, model.visual.* (all 347 vision tensors), mlp.gate routers, mHC residual projections/norms, early dense layers (L00..L02), first MoE layer (L03), and final MoE layer (L44).MXFP8 (modelopt_mixed): Middle layers L04..L43 self_attn (KDA linear attention + DSA MLA projections) and shared_experts.NVFP4 (native Blackwell E2M1, group_size=16): All 128 surviving routed experts per MoE layer.Result: 82.97 GiB on disk — freeing ~40 GiB on Thor for the DSpark drafter, 221,184 FP8 KV tokens (200K context), Mamba/KDA state checkpoints, CUDA graphs, and OS headroom!
MXFP8 DSpark Speculator (gamma=8)The stock RedHatAI/GLM-5.3-Flash-speculator.dspark drafter was trained on the original 288-expert BF16 model, so its acceptance drops on an abliterated + trimmed + NVFP4/MXFP8 target.
sglang_dspark_capture.patch) and collected 160 100% on-policy rollouts (56,821 tokens) plus exact [T, 24576] contracted hidden states from our live trimmed target (05b_collect_onpolicy_dspark.sh).DSpark using zero-dep LoRALinear (r=32, alpha=64, lr=1e-4, fc_lr_mult=0.3, freeze_markov, 3 epochs, 3.3 min) via 06_finetune_dspark.py:2.1578 → 1.99993.38 → 3.56MXFP8 via 07_quantize_dspark_mxfp8.py (keeping fc, markov_head, confidence_head, and norms in BF16), shrinking the drafter by -731.4 MB (4.05 GiB total) -> bundled in ./dspark-onpolicy-lora-mxfp8/.sglang Fixes for Thor (sm_110)Getting GLM-5.3-Flash + DSpark + 200K context + Vision + Multi-Turn Prefix Caching running smoothly on Thor required five targeted fixes (all bundled in ./extras/patches/):
sglang_sm110_dsa.patch + triton_fp8_mqa_logits.py):sm_110 lacks SM90/SM100 DeepGEMM FP8 MQA cubins, forcing sglang's PyTorch fallback (torch.matmul(q_f, k_f.t())), which allocated 34–68 GB and OOM-froze at 32K prefill, and took 133.4 ms per decode step at 40K context.08_bench_sm110_mqa_logits.py):q=2048, k=32768): 958.5 ms → 95.6 ms (10.03× faster, max_diff=0.00000, 100.00% Top-2048 overlap).seq=40960, next_n=9, 11 DSA layers): 133.4 ms → 4.1 ms (32.68× faster, 99.83% Top-2048 overlap).63.5K context: 4.88 steps/s (205 ms/step) and ~535 tok/s flat prefill!modelopt_mixed on DSparkDraftModel (sglang_dspark_quant.patch):DFlashDraftModel.supports_quantization = False silently stripped quant_config and layer prefixes, causing our MXFP8 drafter to collapse to accept len = 1.07.supports_quantization = True and prefix preservation on DSparkDraftModel.sglang_hicache_reserve.patch):pool_host/base.py hardcoded a 10 GiB host reserve, blocking NVMe HiCache (--hicache-size 1) when --mem-fraction-static 0.935 left ~10.01 GiB free on unified memory.SGLANG_HICACHE_HOST_MEMORY_RESERVE_GB (default 10, set to 4 on Thor).--hybrid-cache-checkpoints-level 2 only saves 1 Mamba state at request end, so any re-serialization of an OpenCode assistant turn rolled back to 0 cached tokens. Switching to --hybrid-cache-checkpoints-level 3 --mamba-track-interval 4096 unlocked 94.5%–97.3% prefix cache hits even at 81.7K context!transformers 5.10.2 (processor_config.json):processor_config.json originally requested Glm5NextProcessor (absent in transformers 5.10.2), causing AutoProcessor.from_pretrained() to silently fall back to text-only TokenizersBackend (image_processor=None, image_tokens: 0).processor_config.json to transformers 5.10.2's built-in Glm46VProcessor / Glm46VImageProcessor / Glm46VVideoProcessor (identical <|image|> ID 154854, 14×14×2 patchify layout, merge_size=2, [16..8000] image token bounds; original preserved in processor_config.json.orig). Verified live with 910 image tokens!unglitch + launcher wrappers unglitched_sglang, unglitched_vllm, unglitched_llama, unglitched_vllm_omni): Uses Linux kernel cgroup v2 memory.reclaim on system.slice/user.slice + drop_caches + compact_memory to reclaim 120+ GiB contiguous unified memory (cuda_free) in <1s with zero OOM-killer risk (no brute-force mlock / force_swap allocation spikes). Because it relies purely on standard Linux cgroup v2 & VM sysctls, these scripts are directly reusable on other NVIDIA unified-memory systems (Jetson Thor, DGX Spark / GB10, Grace-Hopper/Blackwell) and AMD unified-memory workstations (Strix Halo / Ryzen AI Max ROCm boxes)!/usr/bin/ninja (1.11.1, .ninja_log v5) with venv ninja (1.13.0, .ninja_log v6) on ~/.cache/flashinfer/ — version mismatches trigger full CUTLASS MoE recompilation into swap!--disable-flashinfer-autotune on sm_110 to avoid dummy-forward hangs.sm_110, 122.8 GiB)| Metric | Value |
|---|---|
Target Checkpoint Size (UniqueREAP-128 GrandHybrid) |
82.97 GiB (128/288 routed experts) |
On-Policy MXFP8 DSpark Drafter (gamma=8) |
4.05 GiB (-731.4 MB vs BF16) |
| Live Context & FP8 KV Pool | 200,000 context / 221,184 live FP8 KV tokens (--mem-fraction-static 0.935) |
| OS Memory Headroom (Steady State) | 6.0–6.5 GiB available, ~180 MiB swap |
Prefill Speed (Flat, 32K–64K ctx) |
~535 tok/s (with SM110 Triton FP8 DSA Indexer) |
Decode Speed (temperature=0.6, DSpark gamma=8) |
12–15.3 tok/s |
| Multi-Turn OpenCode Prefix Cache Hit Rate | 94.5%–97.3% (77,056 / 81,734 cached tokens verified live!) |
| Multimodal Vision (Live Verification) | 910 image tokens on JPEG test photo, accurate item-level description |
55.6% Expert Trim Stay So Stable? (And vs. Low-Bit GGUF)34 KDA + 11 DSA), all 45 shared_experts (31.5% of MoE output norm), dense layers L00..L02, vision (model.visual.*), embed_tokens, and lm_head are preserved unpruned.288 experts into ~83 GiB via GGUF requires crushing weights to ~2.1–2.3 bpw (IQ2_XS), degrading every active token and dropping decode to ~3.5–5 tok/s without DSpark or native FP4 Tensor Cores. Keeping 128 orthogonal Unique-REAP specialists at sharp NVFP4 + MXFP8 spine + BF16 anchors preserves 82.3%–83.4% of routed salience and runs ~3× faster on Thor.80K+ long-context reasoning remain rock-solid; the trimmed capacity comes primarily from long-tail closed-book trivia and uncalibrated low-resource languages.sglang on NVIDIA Thor sm_110)./extras/patches/PATCHES.md to sglang../extras/scripts/unglitch 120)../extras/scripts/inference_glm53_flash_sglang.sh (key flags below):SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=1 \
SGLANG_ENABLE_JIT_DEEPGEMM=0 \
SGLANG_OPT_USE_TILELANG_MHC_PRE=0 \
SGLANG_OPT_USE_TILELANG_MHC_POST=0 \
SGLANG_HICACHE_HOST_MEMORY_RESERVE_GB=4 \
SGLANG_HICACHE_FILE_BACKEND_STORAGE_DIR=/path/to/nvme/hicache_glm53 \
python3 -m sglang.launch_server \
--model-path /path/to/GLM-5.3-Flash-UniqueREAP-128-GrandHybrid-NVFP4-MXFP8 \
--served-model-name Nikola \
--host 0.0.0.0 --port 9000 \
--mem-fraction-static 0.935 \
--context-length 200000 \
--chunked-prefill-size 2048 \
--max-prefill-tokens 4096 \
--cuda-graph-max-bs-decode 4 \
--cuda-graph-backend-prefill disabled \
--trust-remote-code \
--tool-call-parser glm47 \
--reasoning-parser glm45 \
--chat-template /path/to/GLM-5.3-Flash-UniqueREAP-128-GrandHybrid-NVFP4-MXFP8/chat_template.jinja \
--disable-flashinfer-autotune \
--disable-shared-experts-fusion \
--dsa-prefill-backend tilelang \
--dsa-decode-backend tilelang \
--kv-cache-dtype fp8_e4m3 \
--moe-runner-backend flashinfer_cutlass \
--max-mamba-cache-size 20 \
--hybrid-cache-checkpoints-level 3 \
--mamba-track-interval 4096 \
--mamba-ssm-dtype bfloat16 \
--enable-hierarchical-cache \
--hicache-storage-backend file \
--hicache-size 1 \
--hicache-storage-prefetch-policy wait_complete \
--hicache-storage-backend-extra-config '{"hicache_storage_pass_prefix_keys": true}' \
--enable-cache-report \
--speculative-algorithm DSPARK \
--speculative-draft-model-path /path/to/GLM-5.3-Flash-UniqueREAP-128-GrandHybrid-NVFP4-MXFP8/dspark-onpolicy-lora-mxfp8 \
--speculative-num-draft-tokens 9
Set in generation_config.json:
temperature: 0.6 (calibrated for quantized + trimmed logit entropy; avoids tail noise in long reasoning chains)top_p: 0.95repetition_penalty: 1.1(If running on transformers >= 5.11 with native Glm5NextProcessor support, you may optionally restore processor_config.json.orig over processor_config.json.)
zai-org/GLM-5.3-Flash (MIT License, Copyright (c) 2026 Z.AI Co., Ltd — preserved in LICENSE).dealignai/GLM-5.3-Flash-UNCENSORED-NVFP4.RedHatAI/GLM-5.3-Flash-speculator.dspark.catplusplus/Qwen3.6-19B-A3B-UniqueREAP-QAD-v2-Grand-Hybrid-NVFP4.model-00007-of-00020.safetensors 4.5 GBmodel-00014-of-00020.safetensors 4.5 GBmodel-00005-of-00020.safetensors 4.5 GBmodel-00010-of-00020.safetensors 4.5 GBmodel-00016-of-00020.safetensors 4.5 GBmodel-00015-of-00020.safetensors 4.5 GBmodel-00009-of-00020.safetensors 4.5 GBmodel-00002-of-00020.safetensors 4.5 GBmodel-00017-of-00020.safetensors 4.5 GBmodel-00019-of-00020.safetensors 4.5 GBmodel-00018-of-00020.safetensors 4.5 GBmodel-00001-of-00020.safetensors 4.5 GBmodel-00006-of-00020.safetensors 4.5 GBmodel-00004-of-00020.safetensors 4.5 GBmodel-00011-of-00020.safetensors 4.5 GBmodel-00013-of-00020.safetensors 4.5 GBmodel-00008-of-00020.safetensors 4.5 GBmodel-00003-of-00020.safetensors 4.5 GBmodel-00012-of-00020.safetensors 4.5 GBmodel-00020-of-00020.safetensors 3.6 GB