DevLog

Every step of building Lewi Surge, dated and written down as it happened, including the mistakes.

  1. Training

    memarch 12B-A2B is training

    The main training run of memarch started on 8 TPU v6e chips: about 12 billion parameters, 550k tokens per second (472 ms per step at 4×8192 tokens per chip), with the memory, the Instinct optimizer and the new fishki layers all on. Each chip uses 6.8 of 31 GB. We will post the first checkpoint results here.

  2. Engineering

    Memory at start on 8 chips

    Two of our test launches on 8 chips failed: the first crashed on the first step, the second froze while starting. The compiler showed why the start was so tight: generating the weights took 17 GB of temporary memory per chip, and the optimizer state was first built whole on every chip, 22 GB. Now the weights are generated one layer at a time (2.5 GB) and the optimizer state is split across chips from the start (3.3 GB). Starting the model went from 4.5 minutes to 4 seconds. Every run now also has a diagnostic mode: if the log stops for more than 3 minutes, it prints where each thread is waiting.

  3. Model

    Fishki: one model to train, another to use

    We found that our model was smaller than we thought. 11 of its 12 billion parameters sat in heavy layers that saw only the 6% most surprising words, so an ordinary word passed through about 0.3–0.4 billion parameters instead of 2. We rebuilt the heavy part as fishki: many equal small layers. In training, each step uses only 2 of them, chosen at random from the set for the kind of text in that step (code, math, Ukrainian, English, other languages); the whole step is one kind of text, so there is no routing of single words between chips. The finished model gives each word about 2 billion active parameters through a router. In tests at equal training time, a model trained this way beat the same model trained in its finished form all the time: by 0.12 on a small model, by 0.06–0.18 on a bigger one, and the gap did not shrink.

  4. Engineering

    Fast memory reads on TPU

    The rope memory (anchors in the text that the model can open again later) was the slowest part of the step on TPU. A new kernel for reading it cut the memory section from 575 to about 190 ms per step. With the memory in one layer, the full model ran at 515k tokens per second on 8 TPU v6e chips.

  5. Result

    The memory recalls facts far behind the window

    On a small model, the anchor memory now recalls facts placed far outside the attention window: 100% at 8k tokens, 99% at 16k and 98% at 32k. Two changes made the difference: anchors inside the window no longer take memory slots, and the search runs on position-aware keys.

  6. Result

    500k tokens per second on 8 TPU chips

    The training step reached the target set before the main run: 507k tokens per second on 8 TPU v6e chips, 517 ms per step at 4×8192 tokens per chip, with memory, experts and the Instinct optimizer all on. The last gains came from profiling: rematerialization now keeps the outputs of the expert exchange instead of recomputing it, and the exchange itself uses a faster data layout.

  7. Model

    A new component: Uroboros

    A new architectural component, Uroboros, was added to memarch. We will publish details after it is validated in training.

  8. Engineering

    First JAX runs on 8 chips

    The new step ran on 8 TPU v6e chips for the first time. The first problem was memory: the optimizer state was copied in full on every chip. It is now split across chips, which frees enough room for bigger batches, up to 8×8192 tokens per chip.

  9. Engineering

    The training step rewritten in JAX

    The PyTorch/XLA path topped out at about 268k tokens per second on 8 TPU v6e chips, so the whole training step was rewritten in JAX from scratch: the model, the memory, the Instinct optimizer and the mixture of experts. On one chip it matches the PyTorch version to six digits of loss, and across 8 chips it runs as one compiled program.

  10. Engineering

    One program per training step

    The step was rewritten so that nothing waits on the host: no micro-batches, the memory pass and the re-reading inside the compiled graph, and windowed attention for texts longer than the window without a dense mask. On an H100 the test model went from 196k to 312k tokens per second at 4k context, up to 436k with a bigger batch, with a third of the activation memory; 8k context is no longer slower per token than 4k. On 8 TPU chips the real-size model still ran at only 14k tokens per second: every cross-chip exchange split the compiled program into pieces. That is what we are fixing now, and the target before the main run starts is 500k tokens per second on the cluster.

  11. Training

    Memory on TPU, and a vocabulary in two levels

    The memory system now runs on TPU v6e: re-reading happens only on the 25% most surprising words of each chunk, with constant shapes instead of gathers. The 131k-word output head is split in two: a short head over the 8k most frequent words on every position, and the full head only where the target is rare (about 18% of positions). Quality improved (6.74 vs 6.86 on the small test) and the head costs 25 ms instead of 67. On one chip the real-width model reaches 44.8% MFU with memory on.

  12. Result

    1B scale test: memarch beats a same-size transformer

    Same data, same GPU, same validation windows, about 25 minutes each. memarch (2.25B parameters, 2 experts active) reached the transformer's final loss 35% sooner and finished 0.22 lower: 3.858 against 4.078 for a 1.28B dense transformer, at 448 ms per step against 768. Two caveats, written down: memory was off in this test (1k texts fit in the window), and the baseline used our own optimizer, which is stronger than AdamW.

  13. Research

    Racing modded-nanogpt, and losing honestly

    We ran the strongest public training recipe of the same size (modded-nanogpt, GPT-2 Medium track) on our data. It reached our final loss about 3.5 times faster and on 4 times fewer tokens. Our earlier 13% win was against our own plain transformer. The response was our own ideas only: word tables born with a phrasebook from corpus statistics (loss starts at 7.2 instead of 11.0), a hard-wired recognition reflex that copies words already seen, and homeostasis in the optimizer. By the next morning the gap on the Medium track had closed to 3.90 against 3.63, with memarch finishing first.

  14. Data

    The training corpus: about 320B tokens, deduplicated and decontaminated

    Tokenized on rented CPU servers in two days: The Stack v3 (permissive and unlicensed code, 120B), OpenCoder, FineWeb-Edu, FinePDFs-Edu, FineMath, Nemotron-CC-Math, OpenWebMath, FineWiki and HPLT Ukrainian. MinHash deduplication across all sources marks 6% of documents; benchmark decontamination with 13-gram overlap marks 0.009%. HumanEval turned out to be present in the corpus 164 problems out of 164, mostly GitHub copies, so without this step its score would mean nothing. Nothing is deleted: the marks sit next to the shards and the loader applies them.

  15. Research

    Instinct: an optimizer written from scratch

    memarch is not a transformer, so it got its own optimizer. Instinct keeps one momentum per weight (half of AdamW's state), scales the step per row, lets prediction surprise set the step size, and a homeostasis rule balances how much each neuron's inputs and outputs move. On the same plain transformer it beats both AdamW and Muon (5.555 against 5.818 and 5.786 at 10M tokens). The whole step, including the optimizer, runs on the accelerator with zero host stops, and the full build reached 52-53% MFU on the test GPU.

  16. Model

    memarch v2: memory, surprise anchors, expert banks

    The full architecture runs end to end: light sliding-window layers on every word, heavy mixture-of-experts layers only on the ~20% most surprising words, and an independent memory with fresh and dim cards, bookmarks into the text and re-reading. Recall from beyond the window: 99-100% regardless of distance. At ~300M parameters it reaches an AdamW transformer's final loss 13-15% sooner. The code is public under Apache-2.0 at github.com/prostos2162-maker/memarch.

  17. Decision

    Lewi Surge 7B-A1B is frozen; the next model gets a new architecture

    The 7B plan on Google Cloud TPU is on hold: the remaining credits are not enough to train it to a useful level with a standard transformer recipe. Instead of a smaller model, we are building a cheaper one: memarch, our own memory-inspired architecture with its own optimizer, designed to reach the same quality in fewer tokens and fewer FLOPs per token. The target stays a coding model with strong Ukrainian, about 12B total and 2B active parameters.

  18. Release

    Lewi Surge Preview 3B released

    Full mid-training on 0.5B tokens and chat fine-tuning on 0.52B tokens. HumanEval 29.3% for the chat-tuned model (chat template), MBPP 19.0%, HellaSwag 42.7%. The thinking mode is off: at this size its reasoning often does not terminate. Open weights under Apache-2.0.

  19. Training

    Mid-training and SFT on Google Cloud TPU v6e

    The first mid-training run kept weights in bf16 and about 96% of them never changed: updates that small round away to zero. We re-ran everything with fp32 master weights on an 8-chip TPU v6e, at about 130k tokens per second, and now check after every stage that the weights actually moved.

  20. Release

    An export bug caught before release

    Converting the model to bf16 silently tied the output head to the embeddings, making every logit 32 times too large. Greedy benchmarks hid it; sampling did not. The released weights carry the correct, separate output head.

  21. Release

    Base and Chat-Early on Hugging Face

    The base model and an early chat checkpoint, with less than a quarter of the planned fine-tuning, published with their limitations written down.

  22. Training

    Context to 128k tokens

    A long-document stage with the sequence split across eight TPU chips. Needle-in-a-haystack: found at 128k in 2 of 3 runs.

  23. Model

    Lewi Surge Preview, annealed

    Code-focused annealing lifted HumanEval from 18.9% to 25.0% and MBPP from 23.7% to 29.6% on the base model.