Gemma-4-31B-Loop-Compact (23.1 GB Hourglass INT4/INT8 + Procrustes K=1..4 Recurrent Funnel)

Author: Matt West (Google Scholar · GitHub · Hugging Face · ORCID · DOI: 10.5281/zenodo.24419425)

Gemma-4-31B-Loop-Compact is a retrofitted depth-recurrent and hourglass-compressed adapter package for google/gemma-4-31B-it accompanying the research monograph Rotating the Bottleneck.

Coherent multi-pass recurrence across an 87.1 degree rotating manifold

What Problem Does This Solve?

Retrofitting multi-layer recurrent loops onto a frozen dense transformer (L24..L42 in Gemma 4 31B, d_model = 5376) normally fails for two geometric reasons:

  1. 87.1-degree coordinate rotation across depth: Paired residual states at loop exit H_out[42] and loop entry H_in[24] sit nearly orthogonal (cos = +0.0514, ~87.1°), so naive loop-back feeds signals in sideways (KL = 0.3626 nats).
  2. Block-scalar attenuation: Gemma 4 scales each block output by a learned layer_scalar < 1 (median = 0.824), decaying unanchored skip states across passes.

Solving the exact 5376 x 5376 closed-form SVD Orthogonal Procrustes rotation ($R_0 = U V^\top$, 0 gradient steps) snaps cross-layer cosine alignment 16x to +0.8326 and cuts zero-shot 2-loop KL drift 84% (0.3626 -> 0.0581 nats). Pairing that bridge with first-pass skip anchoring, funnel-preserving Hourglass INT4/INT8 + -25% outer MLP width pruning (62.55 GB -> 23.08 GB, fitting on a single 24 GB GPU), and 12.5 minutes of <thought>-to-latent Loop-LoRA self-distillation across K = 1..4 passes unlocks silent (0-CoT) multi-step reasoning while keeping 100% of the base weights frozen.

Gemma-4-Loop-Compact Scorecard

Verified 0-CoT (no_think) Benchmark Scorecard

All evaluations run with zero <thought> chain-of-thought tokens on held-out suites (0 prompt overlap with distillation items; full raw JSONs locked in xmattwest/afriat):

Condition (0 CoT tokens) VRAM / Size Loops K Held-Out KL (nats) 3-Hop 5-Hop 7-Hop (Unseen) Multi-Hop All (n=128) 0%-Loan Balance (n=48) Word Prob (n=48)
google/gemma-4-31B-it (BF16 1-Pass) 62.55 GB 1 0.0000 3.1% 0.0% 0.0% 0.8% 0.0% 0.0%
Uniform-Compact (0-Shot flat prune) 22.18 GB 1 0.5320 3.1% 0.0% 0.0% 0.8% 0.0% 0.0%
Hourglass-Compact (0-Shot protected funnel) 22.77 GB 1 0.5075 3.1% 0.0% 0.0% 0.8% 0.0% 0.0%
Gemma-4-Loop-Compact (K = 1) 23.08 GB 1 0.4565 43.8% 3.1% 3.1% 12.5% 91.7% 14.6%
Gemma-4-Loop-Compact (K = 2) 23.08 GB 2 0.5274 71.9% 18.8% 9.4% 25.8% (32x) 83.3% 6.2%
Gemma-4-Loop-Compact (K = 4) 23.08 GB 4 0.5423 68.8% 15.6% 12.5% 24.2% 93.8% 22.9%

Zero-FLOP Null-Space Alignment Inside the Bridge (R_safe)

Because L24..L42 is simultaneously the multi-hop reasoning bottleneck and the moral/affective synthesis funnel identified in Part 1, this package also includes the 3D non-financial moral basis $Q_{42} \in \mathbb{R}^{5376 \times 3}$. Calling controller.bridge.apply_safety_fold(active=True) folds $P_\perp = I - Q_{42} Q_{42}^\top$ directly into the 5376 x 5376 Procrustes matrix ($R_{\text{safe}} = R_{\text{proc}} P_\perp$) at zero extra runtime FLOPs and 0.0% multi-hop accuracy loss.

Quickstart (~23.3 GB VRAM on 1x 24 GB GPU)

This repository contains the 416 MB Procrustes bridge, step-indexed K=1..4 Loop-LoRA adapters, adaptive L42 halting head, and Hourglass neuron-importance masks (0.00e+00 verified reload logit diff). At load time, it streamingly compresses google/gemma-4-31B-it in-place from 62.55 GB down to 23.08 GB:

git clone https://github.com/xmattwest/afriat.git
cd afriat
pip install -e ".[gpu]" huggingface_hub
from huggingface_hub import snapshot_download
from modeling_gemma4_loop_compact import load_gemma4_loop_compact

pkg_dir = snapshot_download("xmattwest/Gemma-4-31B-Loop-Compact")

controller = load_gemma4_loop_compact(
    package_dir=pkg_dir,
    base_model_id="google/gemma-4-31B-it",  # Requires accepting Google's Gemma 4 license on HF
    device_map="cuda",
)

# Optional: fold zero-FLOP orthogonal moral-subspace projection into the loop bridge
# controller.bridge.apply_safety_fold(active=True)

prompt = "Track the integer x across hops and answer ONLY with FINAL_INTEGER: <int>..."
inputs = controller.harness.tokenizer(prompt, return_tensors="pt").to("cuda")

with controller.active_recurrence(n_loops=2, adaptive=False):
    out_ids = controller.harness.model.generate(**inputs, max_new_tokens=24, do_sample=False)

print(controller.harness.tokenizer.decode(out_ids[0], skip_special_tokens=True))

Links & Citation

@article{west2026rotating,
  title   = {Rotating the Bottleneck: Read/Write Funnel Dissection, Hourglass Sparsity, and Procrustes Mid-Stack Recurrence in Gemma 4 31B},
  author  = {West, Matt},
  year    = {2026},
  month   = nov,
  url     = {https://shelltoho.me/pubs/rotating-the-bottleneck/}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for xmattwest/Gemma-4-31B-Loop-Compact

Adapter
(399)
this model

Dataset used to train xmattwest/Gemma-4-31B-Loop-Compact