Nanbeige4.2-3B on Apple Silicon: Fixing Deployment Bugs and Decreasing Looped Transformer Memory Overhead
Abstract
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 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.
Figures & tables
| Bug | Line | Trigger | Error / symptom |
|---|---|---|---|
| 1. RoPE buffer (major) | 947 | from_pretrained() + first forward() | no exception raised; inv_freq buffer reads all zeros ( persistent=False , never restored after a meta-device load) |
| 2. RoPE-config dispatch | 1077 | from_pretrained(..., trust_remote_code=True) | KeyError: ’type’ |
| 3. Cache API sentinel | 2125 | calling forward() directly with past_key_values=None , bypassing generate() | AttributeError: type object ’DynamicCache’ has no attribute ’from_legacy_cache’ ; still present in the deployed checkpoint |
| 4. Position-IDs re-trim | 2630 | generate() on MPS, once prepare_inputs_for_generation receives an already-populated position_ids kwarg | ’mps.matmul’ op contracting dimensions differ 361 & 181 (Metal assertion, uncatchable SIGABRT ); not reproduced on CPU |
| 5. Tied-weights key format | 2417 | model.save_pretrained(...) | AttributeError: ’list’ object has no attribute ’keys’ |
| prompt_len | NP max batch | NP tok/s | CP max batch | CP tok/s |
|---|---|---|---|---|
| 1024 | 16 | 32 | ||
| 2048 | 4 | 16 | ||
| 4096 | 2 | 4 | ||
| 8192 | – | – | 1 | |
| 9205 | – | – | 1 | |
| 10218 | – | – | 1 |
| Task | Turns | Outcome |
|---|---|---|
| largest_rename | 5 | pass |
| txt_merging | 5 | pass |
| file_reorganize | 7 | pass |
| pattern_matching | 2 | fail, timed out |
| file_splitting | 4 | fail, tool response OOM |
| uppercase | 7 | fail, tool response OOM |
| Category | Score | Dominant failure mode |
|---|---|---|
| simple_python | 19/30 (63.3%) | wrong call count (11/30) |
| multiple | 13/30 (43.3%) | wrong call count (17/30) |
| irrelevance | 30/30 (100%) | — |
| parallel | 1/30 (3.3%) | wrong # of functions (29/30) |
| parallel_multiple | 9/30 (30.0%) | wrong # of functions (21/30) |
Efficient Transformer Inference
Efficient Transformer Inference studies methods and systems that reduce the latency, memory, and energy needed to run Transformer models.
See all 121 papers