Nanbeige4.2-3B在Apple Silicon上:修复部署错误并降低循环Transformer内存开销
研究论文 · 2026/08/18
本文报告了在Apple Silicon(MPS)上部署Nanbeige4.2-3B模型时发现的五个独立bug,这些bug导致模型无法通过Hugging Face transformers直接运行。修复这些bug后,模型仍因循环Transformer的层重用策略导致峰值注意力内存翻倍,无法有效处理智能体任务。为此,我们提出了一种分块预填充策略,将允许的上下文长度在32 GiB共享内存上扩展了2.7倍。此外,我们还修复了系统提示和MPS原生内存bug,使模型能够在标准MCP和工具调用基准上可靠评估。在MCPMark子集上,调试后的模型完成了高达30%的真实智能体任务(原始为0%),在BFCL上,单工具调用接近完美,但多工具测试大多失败。我们发布了补丁检查点、系统提示优化器和评估工具。
本文不仅解决了具体模型部署中的实际问题,还提出了通用的内存优化策略,对在资源受限设备上运行大型语言模型具有参考价值。同时,详细的bug分析和修复过程为社区提供了可复现的解决方案,并公开了工具,值得关注。
Nanbeige4.2-3B is a 3B-parameter agentic model built around a Looped Transformer (LT) that reuses one stack of layers for a second forward pass, adding effective depth without additional parameters. Evaluated on Apple Silicon (MPS), we identify five independent bugs which prevent the released checkpoint from running via Hugging Face transformers out of the box (including a silently-zeroed RoPE buffer and calls to removed transformers cache APIs). Furthermore, we show that fixing these bugs is still not sufficient for agentic tasks, due to the LT's layer-reuse strategy (which effectively doubles peak attention memory) used to achieve parameter efficiency. We thus introduce a chunked-prefill strategy which alleviates the incurred memory-capacity penalty, extending allowable context width by 2.7 times on 32~GiB shared memory. However, even with the reduced memory overhead, we show that patches are required to render Nanbeige4.2-3B usable; resolving both system prompt and MPS-native memory bugs finally allows reliable evaluation on standard MCP and tool-calling benchmarks. On a subset of MCPMark, the debugged model completes up to 30\% of real agentic tasks (up from the original's 0\%), while, on BFCL, it is near-perfect at single tool calls (yet fails the majority of multi-tool tests). We release the patched checkpoint, system prompt optimizer, and evaluation harnesses at https://github.com/johnhalloran321/Nanbeige4.2-3B-mps-fix.