This research addresses deployment failures and memory inefficiencies encountered when running the Nanbeige4.2-3B agentic model on Apple Silicon (MPS). The model utilizes a Looped Transformer (LT) architecture, which reuses a single stack of layers for a second forward pass to increase effective depth without increasing parameter counts. The author identifies five critical bugs in the original Hugging Face transformers implementation, including a silently-zeroed Rotary Positional Embedding (RoPE) buffer and calls to deprecated transformers cache APIs. Beyond these functional errors, the LT architecture's layer-reuse strategy doubles peak attention memory requirements. To mitigate this, the author implements a chunked-prefill strategy, which increases the allowable context width by 2.7x on systems with 32 GiB of shared memory. After resolving these system prompt and MPS-native memory issues, the model's performance improved significantly: it achieved a 30% success rate on a subset of MCPMark tasks, compared to 0% for the unpatched version, and demonstrated near-perfect accuracy for single tool calls on the Berkeley Function Calling Leaderboard (BFCL), despite continuing to struggle with multi-tool scenarios.
Read original
huggingface/daily-papers