Show HN: Maple – 低于2 BPW的MoE剪枝,使Gemma 4 26B在6GB GPU上达45 TPS
Show HN: Maple – Sub-2-BPW Moe Pruning to Run Gemma 4 26B at 45 TPS on a 6GB GPU

原始链接: https://github.com/AmSach/maple

MAPLE 通过剪除每层 80 个休眠的 MoE 专家,将 Gemma 4 26B-A4B 从 9.92 GB 压缩至 4.75 GB(1.48 bits/param),保留 48 个面向 Python/STEM 推理的专家。生成的 GGUF 可在 6 GB 笔记本 GPU 的 VRAM 中完全运行,速度为 45.4 tokens/sec,而原始 128 专家模型为 6.9 tokens/sec。MAPLE 通过 llama-imatrix 对真实前向传播的专家激活进行分析,按频率-能量指标评分专家,并组装领域特定容器。它捕获 79.88% 的激活质量,并在编码、数据结构、物理和逻辑任务上达到 93.8% 的语义保真度。该流程与领域无关,包含分析、选择和构建脚本。预构建模型可在 Hugging Face 获取,用于 llama.cpp 执行。该工作还记录了代理嵌入路由错误、归一化抑制和 DRY 采样器干扰的修复。

Hacker News 新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN:Maple – 低于 2 BPW 的 MoE 剪枝,在 6GB GPU 上以 45 TPS 运行 Gemma 4 26B ( github.com/amsach ) 3 分 由 AmSach 1 小时前 | 隐藏 | 过去 | 收藏 | 1 条评论 帮助 peter_d_sherman 5 分钟前 [–] 看起来非常棒! 这是本地 AI / 在(非常!)资源受限的消费级 GPU 硬件上进行本地 LLM 推理的又一步前进! 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

License DOI Google Scholar Hugging Face Direct Download Format Hardware

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:

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).


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:

$$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)

Configuration Model Size VRAM Allocation Offloaded Layers Generation Speed Latency
Original 128-Expert Base (Gemma 4 26B-A4B) 9.92 GB 6,141 MiB (paged) 16 / 30 6.9 Tokens/Sec 144.9 ms / token
MAPLE 48-Expert Container (Gemma 4 26B-A4B) 4.75 GB 4,180 MiB (100% VRAM) 30 / 30 45.4 Tokens/Sec 22.0 ms / token
Improvement 2.09x smaller -32% VRAM 100% In-VRAM 6.57x speedup 6.58x faster

Task-Level Semantic Fidelity Benchmark

Task Domain Tested Capabilities Fidelity
T1: Fibonacci Code Synthesis def fibonacci, return, append, [0,1] 100%
T2: Binary Search Tree Data Structures class Node, class BST, insert, search 75% (100% with context >= 500)
T3: Rayleigh Scattering Physics Reasoning Rayleigh, wavelength, scattering, blue 100%
T4: Syllogistic Logic Formal Deduction transitive, syllogism, set containment 100%
Overall Mean 93.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 \ge 10$) into orthogonal spaces. MAPLE enforces true forward profiling via llama-imatrix.
  2. Cascaded Normalization Suppression: Multiplying expert scales by $0.795$ to counteract softmax denominator shrinkage compounded across 30 layers ($0.795^{30} \approx 0.001$), 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.

maple/
├── README.md                           # Documentation & benchmarks
├── LICENSE                             # Apache 2.0 License
├── requirements.txt                    # Python dependencies
├── run_maple.bat                       # Interactive Windows launcher
├── upload_to_hf.py                     # Hugging Face Hub upload utility
└── engine/
    ├── maple_profile.py                # Scores & extracts top-48 experts from imatrix
    ├── maple_build.py                  # Slices & builds 4.75 GB GGUF container
    ├── benchmark.py                    # Automated 4-domain semantic fidelity suite
    ├── chat.py                         # Streaming console with live telemetry
    ├── calibration_corpus.txt          # Multi-domain calibration corpus (1,979 tokens)
    └── expert_selection_map.json       # Extracted 30-layer empirical expert indices

Local Setup & Interactive Console

pip install -r requirements.txt

2. Run the Interactive Chat Console

On Windows:

Or via Python:


Model Download Links (Hugging Face Hub)

The compressed 4.75 GB GGUF model container is publicly hosted on Hugging Face:


@article{sachan2026maple,
  title={MAPLE: Manifold-Activated Pruning of Latent Experts},
  author={Sachan, Aman},
  journal={Zenodo},
  year={2026},
  doi={10.5281/zenodo.24042480},
  url={https://doi.org/10.5281/zenodo.24042480}
}
联系我们 contact @ memedata.com