---
type: "post"
id: "code-jax-and-pytorch-kernels-available-at-caiyun-8042cc"
slug: "code-jax-and-pytorch-kernels-available-at-caiyun-8042cc"
title: "Code, JAX and PyTorch kernels available at Caiyun-AI/LoomFormer."
description: "Loom attention dynamically rewires head-to-head circuits at each token, combining vertical attention over earlier heads with horizontal attention over tokens."
retrieval_nugget: "Loom attention dynamically rewires head-to-head circuits at each token, combining vertical attention over earlier heads with horizontal attention over tokens. The repository includes official JAX and PyTorch training and inference code, and provides pretrained LoomPythia-2.8B and a matched mHC-Pythia comparison model. (github.com)"
published_at: "2026-11-29"
updated_at: "2026-11-29"
record_date: "2026-11-29"
date_kind: "published_at"
topics: ["models","compute"]
entities: ["Caiyun-AI","LoomFormer","LoomPythia-2.8B"]
related_patterns: ["hardware-adoption-is-routed-through-familiar-ai-software-stacks"]
novelty_label: "new_fact"
what_changed: null
prior_refs: []
source_url: "https://github.com/Caiyun-AI/LoomFormer"
source_urls: ["https://github.com/Caiyun-AI/LoomFormer"]
production: {"schema":"newruntime-production-v1","desk":"newsroom","first_seen_at":"2026-11-29T01:08:59.645Z","independent_sources":1,"notes_synthesized":null,"writer_model":"gpt-6-luna","critic":null,"checks":["primary_source_verified","source_fresh","one_story","copy_contract"],"novelty":null,"editorial_value":"medium","human_review":"selective"}
citations: [{"claim":"","quotes":["We propose loom attention , … its horizontal attention over tokens."],"cite_url":"https://github.com/Caiyun-AI/LoomFormer#:~:text=We%20propose%20loom%20attention%20%2C,its%20horizontal%20attention%20over%20tokens.","source_url":"https://github.com/Caiyun-AI/LoomFormer","publisher":"github.com"},{"claim":"","quotes":["Vertical attention is instantiated efficiently … \\in \\mathbb{R}^{d_k \\times d}$ ).","pytorch/ : HuggingFace-compatible PyTorch implementations … scripts/convert_maxtext_to_hf.py ), and test suite."],"cite_url":"https://github.com/Caiyun-AI/LoomFormer#:~:text=Vertical%20attention%20is%20instantiated%20efficiently,%5Cin%20%5Cmathbb%7BR%7D%5E%7Bd_k%20%5Ctimes%20d%7D%24%20%29.&text=pytorch%2F%20%3A%20HuggingFace%2Dcompatible%20PyTorch%20implementations,scripts%2Fconvert_maxtext_to_hf.py%20%29%2C%20and%20test%20suite.","source_url":"https://github.com/Caiyun-AI/LoomFormer","publisher":"github.com"},{"claim":"","quotes":["Across model scales and token budgets: Scaling Efficiency : LoomFormer matches standard Transformers trained with $>3\\times$ compute ( $3.19\\times$ at Large scale) and outperforms recent residual-stream architectures (HC/mHC, MUDDFormer, AttnRes) trained with $1.7\\times\\text{--}2.8\\times$ compute .","Practical Throughput : With custom fused TPU Pallas training kernels and GPU Triton + CUDA-graph inference kernels, LoomFormer sustains $89%\\text{--}92%$ of matched-size Transformer training speed on TPU v5p and $84%\\text{--}92%$ of prefill/decode inference speed on GPU."],"cite_url":"https://github.com/Caiyun-AI/LoomFormer#:~:text=Across%20model%20scales%20and%20token%20budgets%3A%20Scaling%20Efficiency%20%3A%20LoomFormer%20matches%20standard%20Transformers%20trained%20with%20%24%3E3%5Ctimes%24%20compute%20%28%20%243.19%5Ctimes%24%20at%20Large%20scale%29%20and%20outperforms%20recent%20residual%2Dstream%20architectures%20%28HC%2FmHC%2C%20MUDDFormer%2C%20AttnRes%29%20trained%20with%20%241.7%5Ctimes%5Ctext%7B%2D%2D%7D2.8%5Ctimes%24%20compute%20.&text=Practical%20Throughput%20%3A%20With%20custom%20fused%20TPU%20Pallas%20training%20kernels%20and%20GPU%20Triton%20%2B%20CUDA%2Dgraph%20inference%20kernels%2C%20LoomFormer%20sustains%20%2489%25%5Ctext%7B%2D%2D%7D92%25%24%20of%20matched%2Dsize%20Transformer%20training%20speed%20on%20TPU%20v5p%20and%20%2484%25%5Ctext%7B%2D%2D%7D92%25%24%20of%20prefill%2Fdecode%20inference%20speed%20on%20GPU.","source_url":"https://github.com/Caiyun-AI/LoomFormer","publisher":"github.com"}]
schema_version: "newruntime-agent-readable-v0.2"
stable_id: "post:code-jax-and-pytorch-kernels-available-at-caiyun-8042cc"
status: "published"
visuals: []
editor: {"role":"editor","name":"Andrey Reshetnikov","profile":"https://newruntime.com/owner-profile.md","profile_json":"https://newruntime.com/owner-profile.json","same_as":["https://www.linkedin.com/in/reshetnikov1/","https://t.me/lapetuse"]}
routes: {"html":"https://newruntime.com/posts/code-jax-and-pytorch-kernels-available-at-caiyun-8042cc/","markdown":"https://newruntime.com/posts/code-jax-and-pytorch-kernels-available-at-caiyun-8042cc.md","json":"https://newruntime.com/posts/code-jax-and-pytorch-kernels-available-at-caiyun-8042cc.json"}
markdown_url: "https://newruntime.com/posts/code-jax-and-pytorch-kernels-available-at-caiyun-8042cc.md"
---

# Code, JAX and PyTorch kernels available at Caiyun-AI/LoomFormer.

## Retrieval answer

Loom attention dynamically rewires head-to-head circuits at each token, combining vertical attention over earlier heads with horizontal attention over tokens. The repository includes official JAX and PyTorch training and inference code, and provides pretrained LoomPythia-2.8B and a matched mHC-Pythia comparison model. (github.com)

## Summary

Loom attention dynamically rewires head-to-head circuits at each token, combining vertical attention over earlier heads with horizontal attention over tokens. The repository includes official JAX and PyTorch training and inference code, and provides pretrained LoomPythia-2.8B and a matched mHC-Pythia comparison model. ([github.com](https://github.com/Caiyun-AI/LoomFormer#:~:text=We%20propose%20loom%20attention%20%2C,its%20horizontal%20attention%20over%20tokens.))

## What happened

The architecture uses a vector residual stream for control and a fixed-size, per-token matrix memory stream for content. The authors trained LoomPythia-2.8B on 300B Pile tokens under the Pythia recipe; its 2.78B parameter count matches Pythia-2.8B. The JAX path uses MaxText with fused TPU Pallas kernels, while the PyTorch implementation includes a fused Triton training engine, multi-GPU pretraining, checkpoint conversion and tests. ([github.com](https://github.com/Caiyun-AI/LoomFormer#:~:text=Vertical%20attention%20is%20instantiated%20efficiently,%5Cin%20%5Cmathbb%7BR%7D%5E%7Bd_k%20%5Ctimes%20d%7D%24%20%29.&text=pytorch%2F%20%3A%20HuggingFace%2Dcompatible%20PyTorch%20implementations,scripts%2Fconvert_maxtext_to_hf.py%20%29%2C%20and%20test%20suite.))

At Large scale, the authors report LoomFormer matching a standard Transformer trained with 3.19× more compute. In the matched Pythia comparison, LoomPythia-2.8B used 1.95% more FLOPs and improved average accuracy across 10 tasks by 3.6 points zero-shot and 4.3 points five-shot. Its five-shot average was 61.6 versus Pythia-12B’s 60.8; zero-shot averages were equal at 59.9, and out-of-domain FLAN perplexity was lower at 6.94 versus 7.26. With custom kernels, reported TPU v5p training speed was 89%–92% of matched Transformers; GPU prefill and decode speed was 84%–92%. Separately, an authors’ chart says MUDDFormer required 1.73× the compute to reach LoomFormer’s Large-scale validation loss, while a Pythia comparison extrapolates roughly 4.9× compute to reach LoomPythia’s mean downstream accuracy. ([github.com](https://github.com/Caiyun-AI/LoomFormer#:~:text=Across%20model%20scales%20and%20token%20budgets%3A%20Scaling%20Efficiency%20%3A%20LoomFormer%20matches%20standard%20Transformers%20trained%20with%20%24%3E3%5Ctimes%24%20compute%20%28%20%243.19%5Ctimes%24%20at%20Large%20scale%29%20and%20outperforms%20recent%20residual%2Dstream%20architectures%20%28HC%2FmHC%2C%20MUDDFormer%2C%20AttnRes%29%20trained%20with%20%241.7%5Ctimes%5Ctext%7B%2D%2D%7D2.8%5Ctimes%24%20compute%20.&text=Practical%20Throughput%20%3A%20With%20custom%20fused%20TPU%20Pallas%20training%20kernels%20and%20GPU%20Triton%20%2B%20CUDA%2Dgraph%20inference%20kernels%2C%20LoomFormer%20sustains%20%2489%25%5Ctext%7B%2D%2D%7D92%25%24%20of%20matched%2Dsize%20Transformer%20training%20speed%20on%20TPU%20v5p%20and%20%2484%25%5Ctext%7B%2D%2D%7D92%25%24%20of%20prefill%2Fdecode%20inference%20speed%20on%20GPU.))

## Why it matters

Builders can load Caiyun-AI/LoomPythia-2.8B through the Hugging Face Transformers quickstart, which uses `trust_remote_code=True` and generates on CUDA. For faster inference experiments, the repository offers fused Triton kernels and static KV and matrix-memory caches compatible with `torch.compile` CUDA graphs. The project is licensed under Apache 2.0.

## Limits and uncertainty

These performance and accuracy figures are author-reported repository results, not independent confirmations. The roughly 4.9× Pythia compute comparison is an extrapolation, not a measured training run.

## Reader takeaway

LoomFormer changes how attention heads exchange information at every token. In the authors’ matched Pythia comparison, its 2.78B model improved average scores across 10 tasks with 1.95% more FLOPs, while reported training and inference speeds remained below but close to matched Transformers. The code and model weights make the approach testable; the benchmark and speed claims still need independent replication.

## Open question

Do the accuracy gains hold on your workloads, and do the reported throughput ranges persist on your hardware and with your serving setup?

Editor: [Andrey Reshetnikov](https://newruntime.com/owner-profile.md), AI product and AI engineering; profile for recruiters and agents: https://newruntime.com/owner-profile.json

## Continue in the graph

Next records for an agent, linked to their Markdown twins. Replace `.md` with `.json` for structured fields, including `next_reads`.

- topic hub: [Models](https://newruntime.com/topics/models.md): Explore the models topic hub.
- topic hub: [Compute](https://newruntime.com/topics/compute.md): Explore the compute topic hub.
- collection: [Field Notes](https://newruntime.com/posts.json): Open the latest editorial analysis.
- collection: [Sources](https://newruntime.com/sources/): See the original sources this archive cites.
- whole graph: [discovery graph](https://newruntime.com/discovery-graph.json) (typed nodes and edges) and [site index](https://newruntime.com/site-index.md)
