MAPLE 剪枝让 Gemma 4 26B 在 6GB 显卡跑出 45 TPS

原标题:Show HN: Maple – Sub-2-BPW Moe Pruning to Run Gemma 4 26B at 45 TPS on a 6GB GPU
62AI 研判分

独立研究者发布 MAPLE,一种面向混合专家大模型的结构化剪枝方法,通过剔除休眠专家把 Gemma 4 26B-A4B 从 9.92 GB 压到 4.75 GB(约 1.48 比特/参数),使模型可完全驻留 6 GB 笔记本显存并以 45.4 tokens/s 推理。该方案针对 Python 编程与 STEM 推理做领域特化,作者称流程可迁移到其他垂直领域。

报道正文

本文目录8 个章节

MAPLE: Manifold-Activated Pruning of Latent Experts

Sub-2-BPW Structural Compression for Mixture-of-Experts (MoE) LLMs
Compressing Gemma 4 26B-A4B from 9.92 GB to 4.75 GB (1.48 effective bits/param), enabling 100% In-VRAM GPU Execution on 6 GB laptop GPUs with 45.4 Tokens/Second throughput.

Author: Aman Sachan (Google Scholar | [email protected])
Organization: Independent Systems Research


Domain Specialization: Technical Reasoning and Code Synthesis

Model Focus:
This 4.75 GB checkpoint is profiled and pruned specifically for Python programming, algorithm synthesis, data structures, and formal STEM reasoning.
By excising 80 dormant multilingual and general conversational experts, the active 48-expert manifold preserves deductive reasoning and syntax generation while fitting entirely within consumer 6 GB VRAM.

Custom Domain MoE Pruning Pipeline

The MAPLE pruning pipeline is domain-agnostic and can be applied to any specialized field (such as medicine, finance, legal analysis, or creative writing) using the scripts in this repository:

  1. Calibration: Run engine/maple_profile.py with your custom text corpus (e.g., engine/calibration_corpus.txt or a proprietary dataset) to profile routing frequency and activation energy via llama-imatrix.
  2. Selection: MAPLE scores experts according to the composite energy metric and outputs engine/expert_selection_map.json.
  3. Container Assembly: Run engine/maple_build.py to slice the unpruned base model and assemble an optimized sub-2-BPW GGUF container for 100% in-VRAM edge execution.

Model Distribution and Direct Execution

The pre-built, verified 4.75 GB GGUF container is hosted on Hugging Face:

Direct Execution via llama.cpp:

BASH
llama-cli \
  -hf AmSach/Gemma-4-26B-A4B-MAPLE-Sub5GB-GGUF \
  -ngl 99 \
  -c 2048 \
  -n 512 \
  --temp 0.4 \
  --top-p 0.9 \
  --repeat-penalty 1.1 \
  -r "<turn|>" \
  -p "<|turn>user\nExplain why the sky is blue using Rayleigh scattering.\n<turn|>\n<|turn>model\n"

(llama-cli downloads the 4.75 GB GGUF container directly from Hugging Face and allocates all 30 layers into GPU VRAM at 45.4 TPS).


Overview

While global multilingual pre-training necessitates 128–256 experts to serve hundreds of human languages and encyclopedic domains, localized edge deployments (such as English technical reasoning and code generation) activate only a narrow subset of experts.

MAPLE discovers this latent manifold by profiling live forward-pass expert activations via llama-imatrix, scoring experts via a composite frequency-energy metric:

se,l=Ce,l⋅σˉe,l+ϵs_{e,l} = C_{e,l} \cdot \sqrt{\bar{\sigma}_{e,l} + \epsilon}

where:

  • s_{e,l}: Composite importance score for expert e in layer l
  • C_{e,l}: Empirical token activation frequency (routing count)
  • σ̄_{e,l}: Mean input channel activation energy
  • ε: Numerical stability floor (10⁻⁶)

Applied to Gemma 4 26B-A4B (128 routed experts, 30 layers), MAPLE excises 80 dormant experts per layer to assemble an optimized 48-expert GGUF container capturing 79.88% of active forward-pass activation mass.


Performance Benchmark (RTX 4050 6GB Laptop GPU)

ConfigurationModel SizeVRAM AllocationOffloaded LayersGeneration SpeedLatency
Original 128-Expert Base (Gemma 4 26B-A4B)9.92 GB6,141 MiB (paged)16 / 306.9 Tokens/Sec144.9 ms / token
MAPLE 48-Expert Container (Gemma 4 26B-A4B)4.75 GB4,180 MiB (100% VRAM)30 / 3045.4 Tokens/Sec22.0 ms / token
Improvement2.09x smaller-32% VRAM100% In-VRAM6.57x speedup6.58x faster

Task-Level Semantic Fidelity Benchmark

TaskDomainTested CapabilitiesFidelity
T1: FibonacciCode Synthesisdef fibonacci, return, append, [0,1]100%
T2: Binary Search TreeData Structuresclass Node, class BST, insert, search75% (100% with context >= 500)
T3: Rayleigh ScatteringPhysics ReasoningRayleigh, wavelength, scattering, blue100%
T4: Syllogistic LogicFormal Deductiontransitive, syllogism, set containment100%
Overall Mean93.8%

Three Documented Failure Modes Overcome

  1. The Ghost Router (Proxy-Embedding Failure): Estimating routing by projecting Layer-0 token embeddings through deep router gates failed because non-linear attention shifts rotate deep hidden representations (l≥10l \ge 10) into orthogonal spaces. MAPLE enforces true forward profiling via llama-imatrix.
  2. Cascaded Normalization Suppression: Multiplying expert scales by $0.795tocounteractsoftmaxdenominatorshrinkagecompoundedacross30layers( to counteract softmax denominator shrinkage compounded across 30 layers (0.795^{30} \approx 0.001),blindingtheresidualstream.Scalesmustbepreservedat), blinding the residual stream. Scales must be preserved at 1.0\times$.
  3. DRY Sampler Interference: The --dry-allowed-length 2 penalty broke Python syntax by penalizing mandatory 2-character keywords (def, if, in, +=). Standard nucleus sampling restored syntax fidelity.

(注:更多技术实现细节与完整 API 文档请查阅原项目 README)