MotifChord language model: gated delta-net and chord attention blocks with an intra-block attention residual.
pip install codon-motif Copy PIP instructions
Motif Chord is a small, CPU-friendly decoder-only causal language model with a mixed attention trunk: low memory use and high compute efficiency at long context.
Gated Delta and Chord layers form one Block at a default 3:1 ratio, which balances long-text efficiency against exact retrieval. The overall structure:
To balance efficiency against precision the model uses a 3:1 mixed-attention ratio:
For positional encoding the project drops RoPE and follows the Bayesian Attention Mechanism instead.
To ease information dilution in deep stacks the model introduces Attention Residuals along the depth dimension (following the Kimi team's paper).
The model stacks several DecoderBlocks. Each Block holds 3 Gated Delta Decoders and 1 Chord Decoder, uses a parallel Attention-MLP residual (x = x + attn(x) + mlp(x)), and passes state between layers through AttnRes.
pip install codon-motif For an editable install from source (also pulls in the test dependencies):
pip install -e ".[dev]" Load a checkpoint from motif.model import MotifChordModel model = MotifChordModel.from_pretrained('MotifChord-Base.safetensors') from_pretrained accepts a safetensors file or shard directory, a bare state_dict checkpoint, and the pipeline checkpoints this project's trainer writes.
from motif.model import Sampler, TextGeneration from motif.tokenizer.tokenizer import PackedTokenizer tokenizer = PackedTokenizer('tokenizer.zip') model = MotifChordModel.from_pretrained('MotifChord-Base.safetensors').eval() generation = TextGeneration( model, tokenizer, 'The capital of France is', max_new_tokens=48, sampler=Sampler(temperature=0.8, top_k=50), ) print(generation.run().text) Chat Chat needs a post-trained checkpoint, and post-training is not finished yet.
Limited to a single GPU, all experiments ran on one 32 GB card (5090).
The model was pretrained on 13.78B tokens over 4,042,962 steps, using a progressive long-context schedule:
Training stayed stable throughout: the final cross-entropy loss converged around 2.8 with no visible loss spikes, which is the numerical-stability evidence for AttnRes plus the 3:1 hybrid attention recipe on a single card.
This project is an exploration of mixed-attention architectures on a single GPU, and it would not exist without the open-source community's research and high-quality datasets.
Particular thanks to the open datasets that provided the pretraining corpus:
Thanks to the open-source community (PyTorch, Triton, HuggingFace and more) for the tooling. This project used a "human-led architecture design + AI-assisted low-level implementation" model: the cache management, the AttnRes tensor-lifetime planning and the architecture alignment were done by the author, while much of the heavy kernel work (such as the fused Triton operators) was generated with AI coding tools and then debugged and performance-tuned rigorously by the author.
Finally, thanks to every developer who keeps exploring architectural boundaries under limited compute. As a 172M single-GPU project it may never top a leaderboard, but it shows that with an interesting enough architectural idea and a little engineering patience, you can still verify the frontier of academic papers yourself on limited hardware.
% 1. Gated DeltaNet @inproceedings{yang2025gated, title = {Gated Delta Networks: Improving Mamba2 with Delta Rule}, author = {Yang, Songlin and Kautz, Jan and Hatamizadeh, Ali}, booktitle = {International Conference on Learning Representations}, year = {2025}, eprint = {2412.06464}, archivePrefix = {arXiv}, url = {https://arxiv.org/abs/2412.06464} } % 2. Kimi Attention Residuals @misc{kimiteam2026attentionresiduals, title = {Attention Residuals}, author = {Kimi Team and others}, year = {2026}, eprint = {2603.15031}, archivePrefix = {arXiv}, primaryClass = {cs.CL}, url = {https://arxiv.org/abs/2603.15031} } % 3. Bayesian Attention Mechanism @inproceedings{bianchessi2026iclr-bayesian, title = {Bayesian Attention Mechanism: A Probabilistic Framework for Positional Encoding and Context Length Extrapolation}, author = {Bianchessi, Arthur S. and Aguirre, Yasmin C. and Barros, Rodrigo C. and Kupssinsk{\"u}, Lucas S.}, booktitle = {International Conference on Learning Representations}, year = {2026}, eprint = {2505.22842}, archivePrefix = {arXiv}, primaryClass = {cs.CL}, url = {https://arxiv.org/abs/2505.22842} } % 4. Qwen3-Next / Qwen3 Technical Report @misc{qwen3technicalreport, title = {Qwen3 Technical Report}, author = {Qwen Team}, year = {2025}, eprint = {2505.09388}, archivePrefix = {arXiv}, primaryClass = {cs.CL}, url = {https://arxiv.org/abs/2505.09388} } % 5. UltraData-Code @misc{openbmb_ultradata_code, title={UltraData-Code}, author={OpenBMB}, year={2026}, url={https://huggingface.co/datasets/openbmb/UltraData-Code} } % 6. arXiv Complete @misc{secemp9_arxiv_complete, title={arXiv Complete: A Snapshot of arXiv's Metadata, Version History, Submission Files and Rendered Documents}, author={secemp9}, year={2026}, url={https://huggingface.co/datasets/secemp9/arxiv-complete} } % 7. WMT17 Zh-En @dataset{fei_huang_2025_5g3elaik, author = {Fei Huang and Hao Zhou and Yang Liu and Hang Li and Minlie Huang}, title = {WMT17 Zh-En}, month = jan, year = 2025, publisher = {No Organization}, doi = {10.57702/5g3elaik}, url = {https://doi.org/10.57702/5g3elaik} } % 8. Nemotron-CC-Math-v1 @misc{nvidia_nemotron_cc_math_v1, title={Nemotron-CC-Math-v1}, author={{NVIDIA}}, year={2025}, url={https://huggingface.co/datasets/nvidia/Nemotron-CC-Math-v1} } % 9. Ultra-FineWeb-L3 @misc{ultra-fineweb-l3, title={Ultra-FineWeb-L3}, author={OpenBMB}, year={2026}, url={https://huggingface.co/datasets/openbmb/Ultra-FineWeb-L3}, publisher={Hugging Face} } Repository and development Model weights ship as release assets, not as commits. The test suite is self-contained: it trains its own tiny tokenizer and builds small models, so no checkpoint download is required.
pytest examples/ holds runnable scripts (verify.py checks the environment and weights first, chat.py talks to the model, generate.py continues text, pretrain.py and sft.py train). They need tokenizer.zip in the repository root or in ../. Temporary artefacts (corpora, checkpoints, the Triton kernel cache) are written under /.tmp and ignored.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




