An Empirical Post-Mortem on 1.58-Bit Ternary Post-Training Quantization for Sparse Mixture-of-Experts Models
Audio Overview (4:24): Listen to or download the engineering post-mortem (
TritForge_Audio_Overview.m4a), which walks through the 70.5% ternary ceiling versus 91.7% 4-bit round-to-nearest (RTN) retention onQwen3.5-MoE, closed-form least-squares outlier scaling (ls_optimal), the Base-3.tritcontainer format, and the discovery of 24% lossless dead-neuron sparsity in the pretrained weights.
In ultra-sparse Mixture-of-Experts (MoE) models such as Qwen3.8-2.4T-A95B-FP8 (92 layers, 512 routed experts per layer) and its 40-layer architectural twin Qwen3.6-35B-A3B-FP8 (256 routed experts per layer), routed feed-forward networks hold more than 95% of all parameters. Uniform sub-2-bit quantization across an entire MoE layer is known to fail because quantization noise in the router gating matrices perturbs token dispatch and causes routing collapse.
TritForge tested whether strict structural asymmetry could make calibration-free 1.58-bit Base-3 ternary post-training quantization (PTQ) viable on modern sparse MoEs. Our design kept every Gatekeeper tensor (Grouped-Query Attention, Gated-DeltaNet linear attention, MoE routers, shared experts, RMSNorms, token embeddings, and the language-modeling head) in high precision while quantizing only the routed expert projections (gate_proj, up_proj, down_proj) into balanced trits ({-1, 0, +1} with one FP16 scale per 128 weights, or 1.725 bits/weight). That compression reduces physical storage per 512-expert layer by 72.3% (25.3 GB in FP8 shards to 7.01 GB on disk). Our acceptance bar was at least 90% top-1 token agreement with the unquantized FP8 baseline.
Evaluated end-to-end across all 40 layers of Qwen/Qwen3.6-35B-A3B-FP8 on held-out text (4 x 512 tokens, 2,044 target predictions, reproduced bit-for-bit on CPU and GPU in experiments/twin_eval/), calibration-free 1.58-bit ternary PTQ falls nearly 20 percentage points short of the 90% retention bar.
Even after replacing standard threshold heuristics with exact closed-form per-block least-squares scaling (ls_optimal, arm2), ternary PTQ retained only 70.5% top-1 token agreement and worsened perplexity by 1.3243x (15.77 vs. 11.91 control). Phase 12 block-1024 signed Walsh-Hadamard rotation (arm3_hadamard, 70.7% top-1, 0.4257 nats KL) and disjoint frozen-trit continuous FP16 scale tuning (arm4_ingot_scales, 73.7% top-1, 0.3287 nats KL, 1.2067x PPL) cut teacher KL divergence by 28.4% at pure 1.725 bits/weight (outperforming 10% mixed-4-bit on KL), yet still fall more than 16 percentage points short of the 90% bar. Promoting the worst 10% of expert matrices in every layer to 4-bit (mix_err and mix_kurt, 1.965 bits/weight) raised agreement only to 74.2%–74.4%. By contrast, plain symmetric 4-bit round-to-nearest (int4, group size 128, 4.125 bits/weight) through the same asymmetric pipeline retained 91.7% top-1 agreement and a 1.0136x perplexity ratio (12.07 vs. 11.91 control).
We are publishing the negative result, the failure diagnosis, an unexpected finding of 24% lossless dead-neuron sparsity in the source weights, and the clean-room toolkit so other researchers have verifiable numbers and reusable infrastructure.
To eliminate implementation drift before drawing architectural conclusions, we built a layer-streaming evaluation harness (experiments/twin_eval/) on Qwen/Qwen3.6-35B-A3B-FP8, which shares the exact Qwen3.5-MoE block structure of the 2.4T model: a 3:1 ratio of Gated-DeltaNet linear attention layers to Grouped-Query Attention layers, zero-centered RMSNorms, gated shared experts, and SwiGLU routed experts.
- Bit-Exact CPU and GPU Execution: All forward passes run in exact IEEE
float32(TF32disabled on CUDA), streaming one decoder layer at a time through the reference Hugging FaceQwen3_5MoeDecoderLayermodule.gpu_quant_check.pyconfirms 0 mismatches across 859,832,320 quantized weights between the NumPy CPU and PyTorch CUDA quantizers, andgpu_vs_cpu.pyconfirms0.00e+00relative difference across all evaluation metrics. - Unseen Evaluation Corpus: Four sequences of 512 tokens (
2,048tokens total,2,044evaluated next-token targets) drawn from technical prose and code written after the model's training cutoff and locked viaSHA256SUMS.txt. - Asymmetric Isolation: Across all arms, every non-routed tensor is bit-identical to the
FP8Control (dequantized exactly per128 x 128block); only the routed expert projections (gate_proj,up_proj,down_proj) vary.
| Quantization Arm | Routed Expert Bits/Weight | Perplexity (PPL) ↓ | PPL Ratio vs. Control ↓ | Top-1 Token Agreement ↑ | Mean KL Divergence (nats) ↓ | Meets >= 90% Target? |
|---|---|---|---|---|---|---|
Control (FP8 exact dequant) |
8.000 |
11.9111 | 1.0000x |
100.0% | 0.0000 |
Reference |
arm1 (Heuristic ternary optimal) |
1.725 |
16.7450 | 1.4058x |
68.8% | 0.5351 |
FAIL |
arm2 (Closed-form LS ternary ls_optimal, CPU) |
1.725 |
15.7743 | 1.3243x |
70.5% | 0.4592 |
FAIL |
arm2 (Closed-form LS ternary ls_optimal, GPU) |
1.725 |
15.7742 | 1.3243x |
70.5% | 0.4592 |
FAIL |
arm3_hadamard (Block-1024 signed WHT + ls_optimal, GPU) |
1.725 |
15.5019 | 1.3014x |
70.7% | 0.4257 |
FAIL |
arm4_ingot_scales (Frozen arm3 trits + disjoint scale tuning, GPU) |
1.725 |
14.3739 | 1.2067x |
73.7% | 0.3287 |
FAIL |
mix_kurt (arm2 + top 10% int4 by kurtosis) |
1.965 |
14.4784 | 1.2155x |
74.4% | 0.3514 |
FAIL |
mix_err (arm2 + top 10% int4 by squared error) |
1.965 |
14.2451 | 1.1959x |
74.2% | 0.3363 |
FAIL |
int4 (Plain symmetric 4-bit RTN g128, CPU) |
4.125 |
12.0733 | 1.0136x |
91.7% | 0.0352 |
PASS |
int4 (Plain symmetric 4-bit RTN g128, GPU) |
4.125 |
12.0737 | 1.0136x |
91.7% | 0.0352 |
PASS |
Raw JSON outputs and per-layer cosine similarity, relative error, and router overlap traces are stored in experiments/twin_eval/results/.
When we audited 368 randomly sampled routed experts across all 92 layers of the Qwen3.8-2.4T-A95B-FP8 master shards, most expert matrices showed benign weight distributions, with a median relative Frobenius reconstruction error of 0.443 under heuristic scaling versus 0.434 at the exact mathematical optimum. However, roughly 10% of routed experts at every depth (and 15% with kurtosis > 20, concentrated in Layers 0–9 and 70–91) contain extreme heavy-tailed outliers in down_proj.
On these high-kurtosis down_proj matrices, standard threshold heuristics place the clipping boundary near the outlier peak, collapsing 99.9% of the weights to zero and producing 0.89–0.98 relative reconstruction error. That effectively zeroes out one in ten experts.
To eliminate this failure mode without calibration data, we replaced heuristic scaling with an exact 1D closed-form least-squares optimizer (ls_optimal in tritforge/quantize.py). For each 128-weight block, sorting absolute weight magnitudes in descending order and evaluating the cumulative prefix sums yields the exact number of non-zero trits $k^$ and scale factor $\alpha^(k^*)$ that minimize squared reconstruction error
Across high-kurtosis (> 20) experts, ls_optimal cuts median reconstruction error from 0.93 to 0.38 and brings every sampled expert across all 92 layers below 0.60. In the 40-layer end-to-end benchmark, ls_optimal (arm2) reduces the perplexity ratio from 1.4058x (arm1) to 1.3243x, confirming the outlier fix while showing that the remaining degradation (70.5% top-1 agreement, 0.4592 nats KL) is inherent to 3-state weight quantization across deep MoE stacks.
Finding 2: Protecting the Worst 10% of Expert Matrices in 4-Bit (mix_err / mix_kurt) Does Not Rescue Ternary PTQ
To test whether a small mixed-precision budget could close the remaining gap, mix_kurt and mix_err keep the worst 10% of routed expert matrices in each layer (ranked by kurtosis or by ternary squared error) in 4-bit (int4 g128) while leaving the other 90% in ls_optimal ternary (1.965 bits/weight overall). Although this lowers the perplexity ratio to 1.1959x–1.2155x and lifts top-1 agreement to 74.2%–74.4%, it still misses the 90% threshold by more than 15 percentage points. Ternary PTQ degradation is not confined to a small tail of outlier matrices; it accumulates across the bulk of the routed expert ensemble.
Finding 3: Block-1024 Walsh-Hadamard Rotation and Disjoint Frozen-Trit Scale Tuning Cut KL by 28.4% at 1.725 bpw, Yet Remain Below 90%
To test whether orthogonal incoherence rotation and continuous scale tuning could close the remaining ternary gap without extra bit width (1.725 bits/weight), we evaluated two Phase 12 arms across all 40 layers of Qwen/Qwen3.6-35B-A3B-FP8:
- Calibration-Free Block-1024 Signed Walsh-Hadamard Rotation (
arm3_hadamard): ApplyingR = H_B * diag(s) / sqrt(B)(seed = 0x54524954) beforels_optimalquantization collapses heavy-taileddown_projkurtosis (kurt > 20,n = 2,916blocks) from25.79mean (96.27max) down to2.84mean (4.90max, near Gaussian), with5.96e-08round-trip max abs error and0 of 859,832,320CPU/GPU weight mismatches. End-to-end unseen perplexity improves from15.7742(arm2) to15.5019(1.3014x), top-1 agreement reaches70.7%, and Mean KL drops7.3%to0.4257nats. - Frozen-Trit Continuous
FP16Scale Tuning (arm4_ingot_scales): Keeping 100% ofarm3_hadamarddiscrete codes{-1, 0, +1}frozen (0trits modified across all 40 layers) and regressing continuous per-128-blockFP16scales against clean local teacher activations via Hierarchical Bayes ridge (8,192strictly disjoint calibration tokens,zero_unseen_overlap = True) cuts unseen perplexity further to14.3739(1.2067x), raises top-1 agreement to73.7%, and lowers Mean KL by28.4%versusarm2to0.3287nats (outperforming 10% mixed-4-bitmix_kurton both PPL and KL at strictly1.725 bits/weight). Notably, regressing norms and residual gains onto cumulative drifted student streams introduced cross-layer Wiener shrinkage on semantic channels (17.6119PPL,0.5385KL), confirming that clean local-teacher targets are essential for layer-wise scale tuning. Even after both improvements,1.725-bpw ternary remains ~18 percentage points belowint4(91.7%top-1,0.0352KL).
While auditing .trit block-scale tables from the converted 2.4T layers against the raw FP8 master shards, we noticed that 38% to 56% of 128-element block scales in early layers were exact zeros. Inspecting the unquantized FP8 source tensors revealed structured dead intermediate channels in the pretrained checkpoint: entire SwiGLU intermediate neurons where row i of gate_proj, row i of up_proj, and column i of down_proj are simultaneously zero (or <= 1.3e-6).
- Full-Model Census (92 Layers): On average, 24% of all routed-expert intermediate channels are dead, ranging from 5% in Layer 74 to 84% in Layer 1.
- Early-Layer Concentration (Layers 0–9): Dead intermediate channels average 54% per layer, with individual experts reaching 75% to 90% dead capacity.
- Ordering Rule for Lossless Pruning: Dead channels must be pruned after block quantization, never before. Removing zero rows or columns prior to quantization shifts 128-element block boundaries and alters block statistics on surviving weights. Pruning them post-quantization via a compact channel index mask yields a mathematically lossless 24% average reduction in expert storage and matrix-multiply compute.
-
Zero-Centered RMSNorm (
1 + w): Unlike standard LLaMA or Qwen2 RMSNorm ($y = \hat{x} \cdot w$ ),Qwen3.5-MoEdecoder norms use a zero-centered offset,$y = \hat{x} \cdot (1 + w)$ . Because learned norm weights$w$ center near-0.6in Layer 0, applying a standard$\hat{x} \cdot w$ kernel flips the sign of 99.9% of the channels feeding the MoE router. - 3:1 Hybrid Gated-DeltaNet Topology: Only one in four decoder layers uses standard Grouped-Query Attention (GQA); the other three in four layers use Gated-DeltaNet linear recurrent attention.
-
Flat Pre-Top-K Router Distributions: On real Layer-0 token activations, the top-10 routed experts capture only 32% of the full 512-way softmax probability mass prior to top-
Krenormalization. Reaching 90% cumulative softmax mass requires a median ofK = 265experts (10th–90thpercentile:138–314). Dynamic-Krouting schemes that threshold raw 512-way probability mass at 90% therefore clamp tomax_krather than saving compute, whereas reducingKbelow 10 alters routed outputs by more than 60%.
Although calibration-free 1.58-bit ternary PTQ did not meet the accuracy bar on Qwen3.5-MoE, the quantization, binary packaging, and verification infrastructure in this repository is clean-room, dependency-light (the core package requires only Python >= 3.10 and numpy), and verified by 116 offline unit tests:
- Bit-Exact CPU and GPU Twin Evaluation Harness (
experiments/twin_eval/):- Layer-by-layer streaming evaluation over
Qwen3.5-MoEcheckpoints on a single GPU or CPU (ternary_arms.py). - Bit-exact NumPy and PyTorch/CUDA implementations of closed-form
ls_optimal,hadamard_ternary_quantize/hadamard_ls_optimal_torch, and symmetricint4quantizers (gpu_quant.py,gpu_quant_check.py,gpu_vs_cpu.py).
- Layer-by-layer streaming evaluation over
- Zero-Copy
.safetensorsBinary Slicer and Shard Auditor (tritforge/slice.py,tritforge/verifier.py):- Parses 8-byte header prefixes across 200+ multi-terabyte
.safetensorsshards in under two seconds without loading tensor payloads into RAM. - Automatically resolves cross-shard
128 x 128weight_scale_invFP8block scales and decodesF8_E4M3andBF16in pure NumPy. - Enforces a 64 MB header allocation ceiling against malformed files and filters active
.aria2partial downloads.
- Parses 8-byte header prefixes across 200+ multi-terabyte
- Native Base-3
.tritContainer and Batch Converter (tritforge/container.py,tritforge/converter.py,tritforge/quantize.py):- Packs 5 balanced trits into each byte (
3^5 = 243 <= 256,1.6 bits/tritplus0.125 bits/weightforFP16block scales, or1.725 bits/weighttotal), compressing a 512-expert layer from25.3 GBinFP8shards to7.01 GBon disk (72.3%reduction). - Provides atomic file finalization (
.atomic_tmp+os.fsync), SHA-256 manifest verification (tritforge verify-trit), and seek-based single-expert loading.
- Packs 5 balanced trits into each byte (
git clone https://github.com/adamm285-dev/TritForge.git
cd TritForge
pip install .# 1. Audit multi-shard .safetensors headers and byte-offset boundaries
tritforge verify-shards -i /path/to/safetensors_shards
# 2. Convert specific layers into Base-3 .trit containers (using ls_optimal scaling)
tritforge convert -i /path/to/shards -o /path/to/trit_output -l 0
# 3. Verify converted .trit containers and SHA-256 digests against the manifest
tritforge verify-trit -m /path/to/trit_output
# 4. Run analytical storage and memory footprint audit
tritforge audit
# 5. Run synthetic toy-model mechanics demonstration
tritforge demo --prompt "Hello" --max-new-tokens 16Scope Note on Standalone Inference (
tritforge run/tritforge serve):
BecauseQwen3.5-MoErelies on hybrid Gated-DeltaNet linear attention in 3 of every 4 layers, which is not implemented in the standalone NumPy runtime,tritforge runexits with a non-zero status code and/v1/chat/completionsontritforge servereturnsHTTP 501 Not Implementedrather than serving synthetic responses. For end-to-endQwen3.5-MoEforward evaluation, use the layer-streaming harness inexperiments/twin_eval/.
The offline test suite runs in roughly 20 seconds without requiring external model weights (local multi-terabyte shard vault tests marked @pytest.mark.vault are deselected by default in pyproject.toml):
pytest tests -vTo reproduce the Qwen3.6-35B-A3B-FP8 twin evaluation on GPU or CPU, see experiments/twin_eval/README.md.
Establishing a bit-exact negative boundary is just as actionable as reporting a positive benchmark. For practitioners compressing Qwen3.5-MoE models today, symmetric 4-bit RTN (int4, group size 128) paired with post-quantization dead-neuron pruning (24% average channel savings) provides a high-fidelity, calibration-free path (91.7% top-1 agreement, 1.0136x perplexity), whereas pushing routed experts below 2 bits will require activation-calibrated second-order compensation (such as column-wise Cholesky GPTQ over real routed token covariances) or quantization-aware training.
Licensed under the Apache License, Version 2.0. See LICENSE for details.







