--- license: mit base_model: - Qwen/Qwen3.8-Flash-Next - Qwen/Qwen3.8-Flash-Next-FP8 tags: - mlx - vllm - apple-silicon - cuda - looped-transformer - recurrent-depth - speculative-decoding - dflash - moe - qwen3.8 - qwen4_exp - coding - math library_name: mlx --- # Looped Qwen3.8-Flash-Next (Unified Merged Adapter + Pre-Folded `MLX` Sidecars) **A smarter `Qwen3.8-Flash-Next` at the exact same base memory footprint — combining Alexey's ([`@superalesha`](https://x.com/superalesha)) GSPO RLVR `` recurrence scaffold with our readout-protected `Direct` continual tuning into a single `268 MB` (`132 MB` BF16 on Mac `MLX`) drop-in adapter.** - **Code, `vLLM` Plugin, PyTorch Engine, & `MLX` Helper:** [`jasontitus/loopedqwen-next`](https://github.com/jasontitus/loopedqwen-next) (MIT) - **Built Upon & Cross-Compatible With:** [`alesha-pro/Looped-Qwen3.8-Flash-Next`](https://huggingface.co/alesha-pro/Looped-Qwen3.8-Flash-Next) & [`alesha-pro/Strata`](https://github.com/alesha-pro/Strata) (MIT) ![Better Together: Merging Open-Source Recurrent-Depth Adapters on Qwen3.8-Flash-Next](assets/01_merged_collaboration_hero.png) --- ## Key Results (`336`-Problem Paired Greedy Scorecard) Looping only the middle 16 layers (`L16..31`) **twice** (`T = 2` default) while keeping Prelude `L0..15` (including the `51.2B` 3-gram PLE table) and Coda `L32..47` single-pass delivers major `` reasoning gains in a third fewer tokens **and** preserves clean non-thinking (`Direct`) code generation: - **`AIME 2025` (`n = 30`, ` @ 24k`):** `63.33%` (`Stock T=1`) $\rightarrow$ `80.00%` (`@superalesha v3`) $\rightarrow$ **`86.67%` (`26/30`, `+23.33 pp` vs. `Stock T=1`, `p = 0.016`; `+6.67 pp` over `v3`)** with **`-31.5%` fewer tokens** (`9,438` vs. `13,771`). - **`GPQA-Diamond` (`n = 50`, ` @ 24k`):** `80.00%` (`Stock T=1`) $\rightarrow$ `90.00%` (`@superalesha v3`) $\rightarrow$ **`92.00%` (`46/50`, `+12.00 pp` vs. `Stock T=1`, `p = 0.031`; `+2.00 pp` over `v3`)** with **`-36.0%` fewer tokens** (`5,798` vs. `9,057`). - **`LiveCodeBench v6` (`n = 40`, ` @ 24k`):** `57.50%` (`Stock T=1`) $\rightarrow$ **`80.00%` (`32/40`, `+22.50 pp` vs. `Stock T=1`, `p = 0.012`)** with **`-38.3%` fewer tokens** (`9,212` vs. `14,927`). - **Fixes Non-Thinking (`Direct`) Code Regressions:** - **`HumanEval+ Direct` (`n = 164`, `direct @ 2k`):** Recovers `91.46%` (`150/164`) $\rightarrow$ **`93.90%` (`154/164`, `+4` wins / `0` losses over `v3`)**, verified identically on `vLLM 0.34.0` Cutlass FP8 (`470.6 tok/s`) and PyTorch FP8. - **`LCB Medium Direct52` (`n = 52`, `direct @ 4k`):** Erases 100% of `v3`'s `Direct52` drop at `T=3` (`51.92%` $\rightarrow$ **`55.77%`, `-67.4%` fewer tokens**), while our included **`sft_v21_direct/ckpt_0024.safetensors`** specialist reaches **`61.54%` (`32/52`, `+5.77 pp` over `Stock T=1`)**. - **`556.6 tok/s` Batched `vLLM 0.34.0` Throughput on `1× NVIDIA H200`** (`Qwen/Qwen3.8-Flash-Next-FP8` with `51.2B` PLE in pinned host RAM + CUDA Graphs). | Benchmark Suite (`temperature=0.0` Greedy) | Stock `Qwen3.8-Flash-Next` (`T=1`) | Our `SFT` Adapter (`sft_v21_direct`, `T=3`) | `@superalesha`'s RLVR Adapter (`v3`, `T=2`) | **Merged Adapter (`ckpt_final`, `T=2`)** | Merged Token $\Delta$ vs `T=1` | |---|---:|---:|---:|---:|---:| | **`AIME 2025`** (`n=30`, ` @ 24k`) | `63.33%` (`19/30`) | — | `80.00%` (`24/30`) | **`86.67%` (`26/30`, `p=0.016`)** | **`-31.5%`** (`9,438` vs `13,771`) | | **`GPQA-Diamond`** (`n=50`, ` @ 24k`) | `80.00%` (`40/50`) | `86.67%`* (`26/30`) | `90.00%` (`45/50`) | **`92.00%` (`46/50`, `p=0.031`)** | **`-36.0%`** (`5,798` vs `9,057`) | | **`LiveCodeBench v6`** (`n=40`, ` @ 24k`) | `57.50%` (`23/40`) | — | **`80.0%` / `82.5%`** (`32`–`33/40`) | **`80.00%` (`32/40`, `p=0.012`)** | **`-38.3%`** (`9,212` vs `14,927`) | | **`HumanEval+ Direct`** (`n=164`, `direct @ 2k`) | **`95.12%`** (`156/164`) | — | `91.46%` (`150/164`) | **`93.90%` (`154/164`, `+4/-0` vs `v3`)** | **`-11.3%`** (`224` vs `252`) | | **`LCB Medium Direct52`** (`n=52`, `direct @ 4k`) | `55.77%` (`29/52`) | **`61.54%` (`32/52`)** | `51.92%` (`27/52`) | **`55.77%` (`29/52`, `T=3`)** / `53.85%` (`T=2`) | **`-67.4%`** (`531` vs `1,630`) | | **Pooled `` Suites (`120` problems)** | `68.33%` (`82/120`) | — | `84.17%`–`85.00%` (`101`–`102`) | **`86.67%` (`104/120`, `+23/-1` vs `T=1`)** | **`-35.8%`** (`556.6 tok/s` H200) | | **Pooled All `336` Problems** | `79.46%` (`267/336`) | — | `82.74%`–`83.04%` (`278`–`279`) | **`85.12%` (`T=2`) / `85.42%` (`T=3/2`)** | — | *\*Our `sft_v21_direct` GPQA guard was evaluated on the 30-item `xhigh @ 20,480` subset (`Stock T=1 = 27/30 = 90.0%`).* --- ## Quickstart (One Command) ### 1. Apple Silicon Mac (`64 GB+` Unified Memory — Browser Chat UI + OpenAI API) Auto-detects your Mac's RAM (`64–95 GB` $\rightarrow$ `3.3-bpw` `~54 GB` RAM; `96–191 GB` $\rightarrow$ `4.7-bpw` `~75 GB` RAM; `192 GB+` $\rightarrow$ `8-bit` `~138 GB` RAM — with the `32 GB` PLE table SSD-mmapped so it uses **0 GB of RAM**), reuses any existing `Qwen3.8-Flash-Next` MLX pack in `~/.mlx-serve/models` or `~/.cache/huggingface/hub` with **0 GB re-downloaded**, sets up an isolated `MLX` runtime (`0` PyTorch needed), downloads this `268 MB` Merged Adapter (`T=2`), and launches a local Browser Chat UI + OpenAI `/v1` server at `http://127.0.0.1:11235`: ```bash curl -fsSL https://raw.githubusercontent.com/jasontitus/loopedqwen-next/main/install_mac.sh | bash ``` * Or run a one-shot terminal test prompt (`` + `tok/s`) or interactive terminal chat: ```bash curl -fsSL https://raw.githubusercontent.com/jasontitus/loopedqwen-next/main/install_mac.sh | bash -s -- --test ``` ### 2. NVIDIA GPU (`CUDA` + `vLLM 0.34+` — `557 tok/s` on `1× H200` or `2× GPU`) Auto-detects NVIDIA GPU count & VRAM, installs `vLLM 0.34.0` (`cu130` wheel) + [`jasontitus/loopedqwen-next`](https://github.com/jasontitus/loopedqwen-next), pre-caches `ckpt_final.safetensors` (`T=2`), and starts `vllm serve` (`--engram-config '{"cpu_offload": true}'`): ```bash curl -fsSL https://raw.githubusercontent.com/jasontitus/loopedqwen-next/main/install_cuda.sh | bash ``` * **Already using [`alesha-pro/Strata`](https://github.com/alesha-pro/Strata)?** `ckpt_final.safetensors` + `ckpt_final.json` (`version: 3`, `num_passes: 2`, `dflash_bridges.*` preserved) is a 100% drop-in replacement: ```bash hf download sliderforthewin/Looped-Qwen3.8-Flash-Next ckpt_final.safetensors ckpt_final.json --local-dir ./merged_loop VLLM_LOOPED_CKPT=./merged_loop/ckpt_final.safetensors vllm serve Qwen/Qwen3.8-Flash-Next-FP8 ... ``` --- ## Included Files | Path | Size | Format | When to Use | |---|---:|---|---| | **`ckpt_final.safetensors`** + `ckpt_final.json` | `268 MB` | `version: 3` (`alesha_v3` schema, `T=2` default, `dflash_bridges.*` preserved) | **Default Unified Merged Adapter** — drop-in for `vLLM 0.34+`, `Strata`, and `loopedqwen-next`. | | **`mlx/default_t2/`** (`loop_adapter_mlx.safetensors` + `.json`) | `131.8 MB` | Pre-folded BF16 `MLX` sidecar (`T=2`) | **Default Apple Silicon Mac Sidecar (`T=2`)** — zero PyTorch required. | | **`mlx/default_t3/`** (`loop_adapter_mlx.safetensors` + `.json`) | `157.1 MB` | Pre-folded BF16 `MLX` sidecar (`T=3`) | **3-Pass Apple Silicon Mac Sidecar (`T=3`)**. | | **`sft_v21_direct/ckpt_0024.safetensors`** + `.json` | `127 MB` | `looped-qwen4-exp-v1` (`T=3`) | **Optional Non-Thinking (`Direct`) Competitive-Coding Specialist** (`61.54%` on `LCB Medium Direct52`). | | **`mlx/sft_v21_t3/`** | `83.0 MB` | Pre-folded BF16 `MLX` sidecar (`T=3`) | **Apple Silicon Mac `Direct`-Code Specialist Sidecar**. | | **`v1/ckpt_merged_v1.safetensors`** + `.json` | `264 MB` | `looped-qwen4-exp-v1` | Merged Adapter in native `looped-qwen4-exp-v1` layout. | | `mlx_sidecar.py` / `export_mlx_serve_loop.py` | `18 KB` | Python | Standalone `mlx.core` runtime helper & custom-`T` sidecar exporter. | --- ## How the Merge Works Averaging weights `(W_ours + W_theirs) / 2` across two independently trained looped adapters fails because low-rank `WorkspaceEntry` / `CrossPassMixer` bases live in arbitrary rotated coordinate systems and use different stream-RMS normalizations (`mul_ref_rms` + 16 `core_exit` mixers vs. `rms_match` + 4 `layer_tap` mixers). Instead, we froze **100%** of `@superalesha`'s RLVR recurrence scaffold (`workspace_entry.*`, all 16 `cross_pass_mixers.*`, `lora_pass_delta_raw`, and `dflash_bridges.*`, `max_diff == 0.0`) and ran 24 steps of readout-protected continual merging (`L40..47` frozen beneath `lm_head`) in the Core `L16..31` + Coda `L32..39` LoRA subspace — pairing verified `Direct` code supervision (`sqrt` doc-CE) 50/50 with online `` teacher-KL (`0.0014` nats/tok) against unmodified `@superalesha v3`. --- ## Credits & License - **Alexey ([`@superalesha`](https://x.com/superalesha) / [`alesha-pro`](https://huggingface.co/alesha-pro)):** Huge credit for training and open-sourcing [`alesha-pro/Looped-Qwen3.8-Flash-Next`](https://huggingface.co/alesha-pro/Looped-Qwen3.8-Flash-Next) (MIT) and [`Strata`](https://github.com/alesha-pro/Strata), whose 1,200-step SFT + 200-step GSPO RLVR scaffold forms the frozen recurrence backbone of this merged adapter. - **Qwen Team:** For open-sourcing `Qwen3.8-Flash-Next` and `Qwen3.8-Flash-Next-FP8`. - **[`@beamivalice`](https://github.com/beamivalice), `mlx-serve` (`@ddalcu`), & Apple `LoopCD` Authors (`arXiv:2610.02185`):** For `Sushi` STQ quantization, `LoopCD` contrastive decoding (`ddalcu/mlx-serve#1348`), and the Apple Silicon / MLX community pushing fast local MoE + recurrent-depth inference forward. MIT — see [`LICENSE`](LICENSE).