Skip to content
Back to search

OpenMythos

SkillWorks with Claude CodeGitHub

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/kyegomez-openmythos/badge.svg)](/listings/kyegomez-openmythos)

HTML

<a href="/listings/kyegomez-openmythos"><img src="/api/listings/kyegomez-openmythos/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

pip install open-mythos

#uv pip install open-mythos

To enable Flash Attention 2 in `GQAttention` (requires CUDA and build tools):

pip install open-mythos[flash]

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 441 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # OpenMythos
  2. <p align="left">
  3. <a href="https://pypi.org/project/open-mythos/" target="_blank">
  4. <picture>
  5. <source srcset="https://img.shields.io/pypi/v/open-mythos?style=for-the-badge&color=3670A0" media="(prefers-color-scheme: dark)">
  6. <img alt="Version" src="https://img.shields.io/pypi/v/open-mythos?style=for-the-badge&color=3670A0">
  7. </picture>
  8. </a>
  9. <a href="https://twitter.com/kyegomezb/">
  10. <picture>
  11. <source srcset="https://img.shields.io/badge/Twitter-Follow-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" media="(prefers-color-scheme: dark)">
  12. <img src="https://img.shields.io/badge/Twitter-Follow-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Twitter">
  13. </picture>
  14. </a>
  15. <a href="https://discord.gg/3keGBK9Pvr" target="_blank">
  16. <picture>
  17. <source srcset="https://img.shields.io/badge/Discord-Join-5865F2?style=for-the-badge&logo=discord&logoColor=white" media="(prefers-color-scheme: dark)">
  18. <img alt="Discord" src="https://img.shields.io/badge/Discord-Join-5865F2?style=for-the-badge&logo=discord&logoColor=white">
  19. </picture>
  20. </a>
  21. <a href="https://pytorch.org" target="_blank">
  22. <picture>
  23. <source srcset="https://img.shields.io/badge/PyTorch-Implemented-EE4C2C?style=for-the-badge&logo=pytorch&logoColor=white" media="(prefers-color-scheme: dark)">
  24. <img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-Implemented-EE4C2C?style=for-the-badge&logo=pytorch&logoColor=white">
  25. </picture>
  26. </a>
  27. </p>
  28. > **Disclaimer:** OpenMythos is an independent, community-driven theoretical reconstruction based solely on publicly available research and speculation. It is not affiliated with, endorsed by, or connected to Anthropic or any of their proprietary systems.
  29. OpenMythos is an open-source, theoretical implementation of the Claude Mythos model. It implements a Recurrent-Depth Transformer (RDT) with three stages: **Prelude** (transformer blocks), a looped **Recurrent Block** (up to `max_loop_iters`), and a final **Coda**. Attention is switchable between MLA and GQA, and the feed-forward uses a sparse MoE with routed and shared experts ideal for exploring compute-adaptive, depth-variable reasoning.
  30. ## Installation
  31. ```bash
  32. pip install open-mythos
  33. #uv pip install open-mythos
  34. ```
  35. To enable Flash Attention 2 in `GQAttention` (requires CUDA and build tools):
  36. ```bash
  37. pip install open-mythos[flash]
  38. ```
  39. ## Usage
  40. ```python
  41. import torch
  42. from open_mythos.main import OpenMythos, MythosConfig
  43. attn_type = "mla" # or "gqa"
  44. base = {
  45. "vocab_size": 1000,
  46. "dim": 256,
  47. "n_heads": 8,
  48. "max_seq_len": 128,
  49. "max_loop_iters": 4,
  50. "prelude_layers": 1,
  51. "coda_layers": 1,
  52. "n_experts": 8,
  53. "n_shared_experts": 1,
  54. "n_experts_per_tok": 2,
  55. "expert_dim": 64,
  56. "lora_rank": 8,
  57. "attn_type": attn_type,
  58. }
  59. if attn_type == "gqa":
  60. cfg = MythosConfig(**base, n_kv_heads=2)
  61. else:
  62. cfg = MythosConfig(
  63. **base,
  64. n_kv_heads=8,
  65. kv_lora_rank=32,
  66. q_lora_rank=64,
  67. qk_rope_head_dim=16,
  68. qk_nope_head_dim=16,
  69. v_head_dim=16,
  70. )
  71. model = OpenMythos(cfg)
  72. total = sum(p.numel() for p in model.parameters())
  73. print(f"\n[{attn_type.upper()}] Parameters: {total:,}")
  74. ids = torch.randint(0, cfg.vocab_size, (2, 16))
  75. logits = model(ids, n_loops=4)
  76. print(f"[{attn_type.upper()}] Logits shape: {logits.shape}")
  77. out = model.generate(ids, max_new_tokens=8, n_loops=8)
  78. print(f"[{attn_type.upper()}] Generated shape: {out.shape}")
  79. A = model.recurrent.injection.get_A()
  80. rho = torch.linalg.eigvals(A).abs().max().item()
  81. print(
  82. f"[{attn_type.upper()}] Spectral radius ρ(A) = {rho:.4f} (must be < 1)"
  83. )
  84. ```
  85. ## Model Variants
  86. Pre-configured scales from 1B to 1T parameters:
  87. ```python
  88. from open_mythos import (
  89. mythos_1b,
  90. mythos_3b,
  91. mythos_10b,
  92. mythos_50b,
  93. mythos_100b,
  94. mythos_500b,
  95. mythos_1t,
  96. OpenMythos,
  97. )
  98. cfg = mythos_7b() # returns a MythosConfig
  99. model = OpenMythos(cfg)
  100. total = sum(p.numel() for p in model.parameters())
  101. print(f"Parameters: {total:,}")
  102. ```
  103. | Variant | `dim` | Experts | `expert_dim` | Loop iters | Context | Max output |
  104. |---|---|---|---|---|---|---|
  105. | `mythos_1b` | 2048 | 64 | 2048 | 16 | 4k | 4k |
  106. | `mythos_3b` | 3072 | 64 | 4096 | 16 | 4k | 4k |
  107. | `mythos_10b` | 4096 | 128 | 5632 | 24 | 8k | 4k |
  108. | `mythos_50b` | 6144 | 256 | 9728 | 32 | 8k | 4k |
  109. | `mythos_100b` | 8192 | 256 | 13568 | 32 | 1M | 128k |
  110. | `mythos_500b` | 12288 | 512 | 23040 | 48 | 1M | 128k |
  111. | `mythos_1t` | 16384 | 512 | 34560 | 64 | 1M | 128k |
  112. ---
  113. ## Training
  114. The training script for the 3B model on FineWeb-Edu is at [`training/3b_fine_web_edu.py`](training/3b_fine_web_edu.py).
  115. **Single GPU:**
  116. ```bash
  117. python training/3b_fine_web_edu.py
  118. ```
  119. **Multi-GPU (auto-detects GPU count):**
  120. ```bash
  121. torchrun --nproc_per_node=$(python -c "import torch; print(torch.cuda.device_count())") training/3b_fine_web_edu.py
  122. ```
  123. Key design choices:
  124. | Feature | Detail |
  125. |---|---|
  126. | Optimizer | AdamW |
  127. | Dataset | `HuggingFaceFW/fineweb-edu` (`sample-10BT` by default, swap to `sample-100BT` or `default` for full run) |
  128. | Tokenizer | `openai/gpt-oss-20b` via `MythosTokenizer` |
  129. | Parallelism | PyTorch DDP via `torchrun`, sharded streaming dataset |
  130. | Precision | bfloat16 on H100/A100, float16 + GradScaler on older GPUs |
  131. | Schedule | Linear warmup (2000 steps) → cosine decay |
  132. | Target | 30B tokens (~Chinchilla-adjusted for looped architecture) |
  133. ---
  134. ## Documentation
  135. | Page | Description |
  136. |---|---|
  137. | [`docs/open_mythos.md`](docs/open_mythos.md) | Full API reference for the `OpenMythos` class — constructor, `forward`, `generate`, all sub-modules, configuration reference, and usage examples |
  138. | [`docs/datasets.md`](docs/datasets.md) | Recommended training datasets with token budget guidance per model size |
  139. ---
  140. ## The Central Hypothesis
  141. Claude Mythos is suspected to be a **Recurrent-Depth Transformer (RDT)** — also called a Looped Transformer (LT). Rather than stacking hundreds of unique layers, a subset of layers is recycled and run through multiple times per forward pass. Same weights. More loops. Deeper thinking.
  142. This is not chain-of-thought. There is no intermediate token output. All of this reasoning happens **silently, inside a single forward pass**, in continuous latent space.
  143. ---
  144. ## Architecture
  145. A looped transformer divides its layers into three functional blocks:
  146. ```
  147. Input
  148. ↓
  149. [Prelude P] — standard transformer layers, run once
  150. ↓
  151. [Recurrent Block R] — looped T times
  152. ↑_______↓ (hidden state h updated each loop with input injection e)
  153. ↓
  154. [Coda C] — standard transformer layers, run once
  155. ↓
  156. Output
  157. ```
  158. The recurrent block update rule at each loop step t:
  159. ```
  160. h_{t+1} = A·h_t + B·e + Transformer(h_t, e)
  161. ```
  162. Where:
  163. - `h_t` is the hidden state after loop t
  164. - `e` is the encoded input (from the Prelude), injected at every loop
  165. - `A` and `B` are learned injection parameters
  166. - The Transformer blocks apply attention and MLP as usual
  167. The injection of `e` at every step is what prevents the model from drifting — it keeps the original input signal alive throughout the entire recurrence depth.
  168. The full implementation is in [`open_mythos/main.py`](open_mythos/main.py). See the [`OpenMythos` class reference](docs/open_mythos.md) for a detailed API walkthrough, configuration options, and usage examples.
  169. ### Attention Implementations
  170. The attention layer is switchable via `cfg.attn_type`:
  171. | Option | Class | Description |
  172. |---|---|---|
  173. | `"gqa"` | `GQAttention` | Grouped Query Attention (Ainslie et al., 2023) — fewer KV heads than Q heads (`n_kv_heads < n_heads`), reducing KV-cache memory by `n_heads / n_kv_heads`. Uses **Flash Attention 2** (Dao et al., 2023) when `flash-attn>=2.8.3` is installed: GQA is handled natively (no KV head expansion), I/O-bound-optimal, with a transparent fallback to manual scaled dot-product attention when the package is absent. |
  174. | `"mla"` | `MLAttention` | Multi-Latent Attention (DeepSeek-V2) — caches a compressed KV latent (`kv_lora_rank`) rather than full K/V, with split RoPE / no-RoPE head dims for position-aware compression. |
  175. RoPE is applied to Q and K before caching, so cached values do not need to be re-rotated on retrieval.
  176. ---
  177. ## Why This Explains Mythos
  178. ### 1. Systematic Generalization
  179. Vanilla transformers fail to combine knowledge in ways they have never seen during training. Looped transformers pass this test. The ability emerges through a **three-stage grokking process**:
  180. 1. Memorization — model fits training distribution
  181. 2. In-distribution generalization — model handles known compositions
  182. 3. Systematic generalization — model handles novel compositions OOD, abruptly and suddenly
  183. This is why Mythos feels qualitatively different from other models on novel questions — the capability phase-transitions in, rather than emerging gradually.
  184. ### 2. Depth Extrapolation
  185. Train on 5-hop reasoning chains. Test on 10-hop. Vanilla transformer fails. Looped transformer succeeds — by running more inference-time loops. This maps directly to the observation that Mythos handles deeply compositional problems (multi-step math, long-horizon planning, layered arguments) without explicit chain-of-thought.
  186. More loops at inference = deeper reasoning chains = harder problems solved.
  187. ### 3. Latent Thoughts as Implicit Chain-of-Thought
  188. Each loop iteration is the functional equivalent of one step of chain-of-thought, but operating in continuous latent space rather than token space. A looped model running T loops implicitly simulates T steps of CoT reasoning. This has been formally proven (Saunshi et al., 2025).
  189. Furthermore, continuous latent thoughts — unlike discrete token outputs — can encode **multiple alternative next steps simultaneously**. This allows something closer to breadth-first search over the reasoning space, rather than a single committed reasoning path. The model is effectively exploring many possible directions inside each forward pass before converging.
  190. ### 4. No Parameter Explosion
  191. A looped model with k layers run L times achieves the quality of a kL-layer non-looped model, with only k layers worth of parameters. For Mythos-scale deployments, this matters enormously:
  192. - Memory footprint does not grow with reasoning depth
  193. - Inference-time compute scales with loop count, not model size
  194. - This makes deeper reasoning "free" in terms of parameters
  195. ---
  196. ## The Stability Problem (and How It Was Likely Solved)
  197. Training looped models is notoriously unstable. Two failure modes dominate:
  198. - **Residual explosion** — the hidden state `h_t` grows unboundedly across loops
  199. - **Loss spikes** — training diverges suddenly due to large spectral norms in injection parameters
  200. ### The Dynamical Systems View
  201. Recast looping as a discrete linear time-invariant (LTI) dynamical system over the residual stream. Ignoring the nonlinear Transformer contribution, the recurrence becomes:
  202. ```
  203. h_{t+1} = A·h_t + B·e
  204. ```
  205. For this LTI system, stability is governed entirely by the **spectral radius** of A:
  206. - `ρ(A) < 1` → stable, convergent
  207. - `ρ(A) ≥ 1` → unstable, divergent
  208. Empirically, every divergent training run learns `ρ(A) ≥ 1`. Every convergent run maintains `ρ(A) < 1`.
  209. ### The Fix
  210. Constrain the injection parameters so that stability is guaranteed **by construction**:
  211. 1. Parameterize A as a continuous negative diagonal matrix
  212. 2. Discretize using ZOH/Euler schemes: `A_discrete = exp(Δt · A_continuous)`
  213. 3. Enforce negativity via `A := Diag(-exp(log_A))` with a learned scalar `Δt`
  214. 4. This ensures `ρ(A) < 1` always holds, regardless of learning rate or batch noise
  215. The result: the looped model becomes significantly more robust to hyperparameter selection and trains cleanly even at high learning rates. This is the Parcae architecture (Prairie et al., 2026), and it represents the most likely class of solution Anthropic used to make Mythos trainable.
  216. ---
  217. ## Scaling Laws for Looped Models
  218. Parcae establishes the first predictable scaling laws for looped training:
  219. - **Training**: For a fixed FLOP budget with fixed parameters, increasing mean recurrence and reducing token count yields a lower loss than training with minimal loops on more data. Optimal recurrence and optimal token count both follow **power laws** with consistent exponents across scales.
  220. - **Inference**: More test-time loops improves quality following a **predictable, saturating exponential decay** — gains are real but diminishing. This mirrors the inference-time scaling of chain-of-thought.
  221. At 770M parameters, a looped model achieves the downstream quality of a 1.3B fixed-depth Transformer trained on the same data — roughly **half the parameters for the same quality**.
  222. Applied to Mythos: if trained under these scaling laws, Mythos could be dramatically more parameter-efficient than it appears, with a large fraction of its apparent "capability" coming from loop depth rather than raw parameter count.
  223. ---
  224. ## The Loop Index Embedding Hypothesis
  225. A key open question is whether the looped block behaves **identically** on every iteration, or whether it can learn to do different things at different loop depths.
  226. Without any positional signal across loops, the same weights must handle both early-stage pattern matching and late-stage refinement — a tight constraint. A **RoPE-like embedding of the loop index** injected alongside the input at each step would allow the same parameters to implement functionally distinct operations across iterations, much like how RoPE allows the same attention heads to behave differently at different sequence positions.
  227. If Mythos uses this technique, each loop is not a repetition — it is a distinct computational phase, all sharing weights but operating in different representational regimes. This would substantially increase the expressiveness of the recurrent block without increasing parameter count.
  228. ---
  229. ## The Overthinking Problem
  230. More loops is not always better. Beyond a certain depth, excessive recurrence **degrades predictions** — the hidden state drifts past the solution and into noise. This is the "overthinking" failure mode.
  231. The original Universal Transformer (Dehghani et al., 2018) addressed this with an **Adaptive Computation Time (ACT)** halting mechanism: a learned scalar per position that dynamically decides when to stop looping. Positions that are harder to process receive more computation; simple tokens halt early.
  232. Mythos almost certainly has some version of this. The model cannot naively run the maximum number of loops on every input — it needs a learned signal for when the answer has converged. The ACT mechanism also makes the model **Turing-complete** under certain assumptions, which has theoretical implications for the class of problems it can solve.
  233. ---
  234. ## Mixture of Experts — Suspected for Large Parameter Counts
  235. The looped transformer explains the depth of Mythos's reasoning, but not the breadth. Handling wildly different domains — code, math, literature, science, law — with the same weights requires **Mixture of Experts (MoE)**. The suspected design replaces every FFN in the Recurrent Block with a fine-grained MoE layer: each FFN is split into many small experts (1/m the normal size), a router selects the top-mK of them per token via learned affinity scores, and a small number of **shared experts** are always activated regardless of routing to absorb common cross-domain knowledge — syntax, basic reasoning, general context — that would otherwise be redundantly learned by every routed expert. Routing collapse is prevented through a bias term on the router logits adjusted dynamically during training, keeping load balanced across experts without distorting the loss signal.
  236. As the hidden state `h_t` evolves across loop iterations, the router may select different expert subsets at each depth, making every loop computationally distinct despite shared weights. MoE provides breadth; looping provides depth. If the activation ratio is ~5%, Mythos could hold hundreds of billions of total parameters while activating only a small fraction per token — the true parameter count, if ever disclosed, would be a storage number, not a compute number.
  237. ---
  238. ## The Memorization-Reasoning Tradeoff
  239. Looped models exhibit an interesting dichotomy: looping improves reasoning but can hurt memorization. The recurrent structure is optimized for iterative composition — running a reasoning chain forward — but does not inherently improve the storage of rote facts.
  240. This maps to an observable characteristic of Mythos: it reasons exceptionally well about novel problems it has never seen, but its factual recall can be inconsistent. The architecture is structurally biased toward composition over memorization.
  241. Looping-based regularization (Saunshi et al., 2025) can be used to balance this tradeoff during training — applying stronger looping constraints for reasoning tasks while relaxing them for retrieval tasks.
  242. ---
  243. ## Parameter Reuse via LoRA Adaptation
  244. A complementary approach from Relaxed Recursive Transformers (Bae et al., 2024): rather than requiring fully identical weights at every loop, add a small **depth-wise LoRA module** at each iteration. This preserves the compactness of weight sharing while allowing each loop to adapt its behavior slightly.
  245. The result:
  246. - Each loop shares a large common weight matrix (the recursive base)
  247. - A small rank-r adaptation matrix shifts behavior per iteration depth
  248. - The total parameter overhead is minimal
  249. This bridges the gap between pure weight-tying (maximally parameter-efficient, less expressive) and fully distinct layers (maximally expressive, no parameter savings). Mythos likely sits somewhere on this spectrum.
  250. ---
  251. ## Continuous Depth-wise Batching
  252. A downstream consequence of the recursive architecture: **Continuous Depth-wise Batching**. Because all tokens share the same recurrent block, the model can exit the loop at different depths for different tokens or sequences — processing easy inputs quickly and hard inputs with more iterations, all within the same batch.
  253. Theoretical analysis suggests 2-3x improvements in inference throughput. For a deployed model like Mythos serving many users simultaneously, this would be a substantial efficiency gain.
  254. ---
  255. ## Summary: What Mythos Probably Is
  256. | Property | Description |
  257. |---|---|
  258. | Architecture | Recurrent-Depth Transformer (Prelude + Looped Recurrent Block + Coda) |
  259. | FFN layer | Suspected MoE — fine-grained experts + always-on shared experts |
  260. | Parameter count | Very large total; small fraction activated per token (~5% estimate) |
  261. | Reasoning mechanism | Implicit multi-hop via iterative latent updates — no token output between steps |
  262. | Inference-time scaling | More loops = deeper reasoning, following predictable exponential decay |
  263. | Training stability | LTI-constrained injection parameters with spectral radius < 1 |
  264. | Loop differentiation | Likely uses loop-index positional embedding (à la RoPE) per iteration |
  265. | Halting | Adaptive Computation Time or learned convergence criterion |
  266. | Attention | GQA (with optional Flash Attention 2) or MLA with compressed KV latent cache |
  267. | Scaling law | Optimal training scales looping and data together, not parameters alone |
  268. | Reasoning vs. memory | Structurally biased toward composition; memorization requires separate treatment |
  269. | Deployment | Continuous Depth-wise Batching enables variable compute per request |
  270. ---
  271. ## References
  272. ### Twitter / X
  273. - Why Claude Mythos is so good — looped transformer theory (Sigrid Jin): https://x.com/realsigridjin/status/2044620031410266276
  274. - LT implicit reasoning over parametric knowledge unlocks generalization (Yuekun Yao): https://x.com/yuekun_yao/status/2044229171627639004
  275. - Looped transformer cyclic trajectories and input injection (rosinality): https://x.com/rosinality/status/2043953033428541853
  276. - Parcae scaling laws for stable looped language models — thread (Hayden Prairie): https://x.com/hayden_prairie/status/2044453231913537927
  277. - RoPE-like loop index embedding idea to differentiate functions across iterations (davidad): https://x.com/davidad/status/2044453231913537927
  278. - On the Looped Transformers Controversy by ChrisHayduk: https://x.com/ChrisHayduk/status/2045947623572688943
  279. - On the Looped Transformers Controversy Summary by @realsigridjin https://x.com/realsigridjin/status/2046012743778766875
  280. ### Papers
  281. - Fine-grained expert segmentation and shared expert isolation in MoE: https://arxiv.org/abs/2401.06066
  282. - Loop, Think, & Generalize — Implicit Reasoning in Recurrent Depth Transformers: https://arxiv.org/pdf/2604.07822
  283. - Parcae — Scaling Laws for Stable Looped Language Models: https://arxiv.org/abs/2604.12946
  284. - Parcae blog: https://sandyresearch.github.io/parcae/
  285. - Universal Transformers: https://arxiv.org/pdf/1807.03819
  286. - Reasoning with Latent Thoughts — On the Power of Looped Transformers: https://arxiv.org/abs/2502.17416
  287. - Training Large Language Models to Reason in a Continuous Latent Space: https://arxiv.org/abs/2412.06769
  288. - Relaxed Recursive Transformers — Effective Parameter Sharing with Layer-wise LoRA: https://arxiv.org/pdf/2410.20672
  289. - Mixture-of-Depths Attention: https://arxiv.org/abs/2603.15619
  290. - Hyperloop Transformers: https://arxiv.org/abs/2604.21254
  291. - The Recurrent Transformer: Greater Effective Depth and Efficient Decoding: https://arxiv.org/abs/2604.21215
  292. - LT2: Linear-Time Looped Transformers: https://arxiv.org/pdf/2605.20670
  293. ---
  294. ## Citation
  295. If you use OpenMythos in your research or build on this work, please cite:
  296. ```bibtex
  297. @software{gomez2026openmythos,
  298. author = {Kye Gomez},
  299. title = {OpenMythos: A Theoretical Reconstruction of the Claude Mythos Architecture},
  300. year = {2026},
  301. url = {https://github.com/kyegomez/OpenMythos},
  302. note = {Recurrent-Depth Transformer with MoE, MLA, LTI-stable injection, and ACT halting}
  303. }
  304. ```
  305. ---
  306. ## License
  307. MIT License — Copyright (c) 2026 Kye Gomez. See [`LICENSE`](LICENSE) for the full text.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.