# Repository Briefing: jasontitus/loopedqwen
> Source: https://repoforai.com/repo/jasontitus/loopedqwen (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/jasontitus/loopedqwen
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: A+ (89/100 · Maintenance 35/35 · Adoption 14/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v3.1.2 (2026-11-29) — https://github.com/jasontitus/loopedqwen/releases
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: Local AI, GPU
- **Momentum**: 233 ★ total (+33 24h / +232 7d) · 30 forks
- **When to Use**: Best for: Local coding and math evaluation on Apple Silicon or a single large NVIDIA GPU, where you can tune depth and quantization against task accuracy, latency and memory. Skip if: You need multi-GPU tensor parallelism, a stock-checkpoint serving path, or predictable speedups without validating your own workload.

## Overview
```text
### Architecture & Core Mechanics
Looped Qwen reuses the Qwen3.8-27B checkpoint and applies a gated workspace adapter to rerun layers 24–39, a 16-block span that combines GatedDeltaNet and gated attention. The 62.85M-parameter adapter occupies about 240 MB and lets successive passes refine the 5,120-dimensional hidden state before output. T=1 is the non-looped reference; higher T values repeat the core. LoopCD-Hidden is optional guidance, distinct from the MTP head used for speculative decoding.

The Python MLX path starts at scripts/run_mlx.py; requirements.txt selects mlx>=0.32.0 and mlx-lm>=0.31.0 on Darwin arm64 and includes Hugging Face Hub, SafeTensors, Transformers and NumPy. The mlx-serve integration uses a native Zig plugin under plugins/looped_qwen38/. The CUDA integration under vllm_looped_qwen38/ registers through vllm.general_plugins and uses a custom model architecture. Training entrypoints, train_loop.py and train_drafter.py, sit alongside serving code and standalone invariant tests.

### Key Capabilities & Differentiators
At the same 80k token cap, unguided T=3 scored 78.9% on 175 LiveCodeBench v6 tasks versus 72.6% for T=1, while token use fell from 31,566 to 15,117. That gain is not uniform: on HumanEvalFix, T=3 with LoopCD scored 97.0% versus 98.8% for T=1, though it used 223 versus 2,289 tokens. The separate 85.0% LiveCodeBench result used 60 tasks and a 64k cap, so it should not be read as a direct improvement over the full 175-task run.

The Apple Silicon path covers 8-bit, 4-bit and 1.76-bit ternary Bonsai weights. With plugin v0.3.5, a 24 GB M4 Pro Mac mini ran Bonsai at 32k context with MTP in 12.5 GB peak unified memory; the Bonsai fix delivered 71.8%–79.3% draft acceptance and a 41% decode speedup in the reported configuration. A separate six-stream result used 16k context, 8-bit KV quantization and MTP disabled. Those two measurements are not interchangeable capacity targets.

### Trade-offs & Limitations
Compared with stock Qwen3.8-27B on a standard runtime, this design puts more compute into each generated token in the hope of generating fewer tokens overall. On the M2 Max Hard-18 set at 8-bit, unguided T=2 reduced throughput from 12.73 to 10.96 tok/s but cut time per question from 278.3s to 185.8s. With LoopCD, T=4 scored 12/18 versus 11/18 for T=2, yet took 221.7s versus 148.6s per question. Depth is a quality–latency control, not a universal upgrade; the curated 18-task set is useful for tuning, not for predicting production performance.

The custom plugin and matched artifacts add upgrade and capacity-planning work relative to an unmodified checkpoint. The current vLLM plugin requires TP=1, and CUDA-graph MTP integration is listed as future work, so do not budget for Mac MTP speedups on NVIDIA. The repository code is MIT-licensed; review terms for the base weights, adapters, sidecar and third-party quantizations separately before redistribution.

### Hardware & Deployment Guide
On Apple Silicon, choose the mlx-serve installer or DMG for browser chat and a local API, or use the Python/MLX runner. The Mac installer can reuse cached base weights, and the OpenAI-compatible endpoint is http://127.0.0.1:11234/v1 by default. On Linux/NVIDIA, use the CUDA installer, install the vLLM plugin into an existing environment, or build docker/vllm_looped/Dockerfile. The documented single-GPU targets are 48 GB for FP8 and 80 GB or more for BF16; context and concurrency still determine usable headroom.

The vLLM path fetches the adapter from Hugging Face on first launch unless it is already staged. For an offline deployment, prepare the runtime dependencies and model artifacts in advance; the miniature invariant suites can run without the 27B download. Release v3.1.2 added overlap and stale-symlink safeguards to MLX pack exports, atomic two-phase adapter reload, TP=1 validation and packed thinking-mask isolation for LoopCD-Hidden.
```

## Key Capabilities
```text
- Recurrent core: A roughly 240 MB adapter reruns layers 24–39 without replacing the base checkpoint.
- Inference controls: Recurrence depth, LoopCD-Hidden guidance and MTP drafting address different parts of the quality–latency tradeoff.
- Benchmark evidence: At 80k, unguided T=3 reached 78.9% on 175 LiveCodeBench v6 tasks versus 72.6% for T=1, using 15,117 versus 31,566 tokens.
- Low-memory path: The mlx-serve plugin supports 1.76-bit Bonsai; v0.3.5 restored MTP acceptance to 71.8%–79.3% in the reported Mac runs.
- Serving boundary: MLX and mlx-serve cover Apple Silicon, while the CUDA vLLM plugin currently requires TP=1.
- Reproduction: Miniature MLX and vLLM invariant suites exercise loop behavior without downloading the 27B checkpoint.
```

## Quick Start / Clone
```bash
curl -fsSL https://raw.githubusercontent.com/jasontitus/loopedqwen/main/install_mac.sh | bash
```
