this is probably my favorite article ive written. in this blog, i try to profile llm inference served using sglang and reason about the patterns, kernels and bottlenecks you would usually find in production. https://t.co/SkS4PWMxbU
Best explainer on Kimi K3 i've read.
It walks you through how the model works & the elegant innovation behind it:
- K3 is the biggest open model anyone has released: 2.8 trillion parameters total, though only 104 billion of them do the work on any given word.
- The problem Moonshot went after is memory. Normally a model keeps notes on every word it has read, and that pile grows with every token, which is why long conversations get slow and expensive.
- K3 mostly stops the memory pile from growing. Three out of every four layers use a new mechanism called Kimi Delta Attention, which keeps a fixed-size working memory and edits it as it goes, overwriting what's stale instead of hoarding everything. The fourth layer keeps a compressed record of each word so exact details are still recoverable when they matter.
- They proved this on a small model first. A 48B test version used up to 75% less memory and ran about 4× faster at long context, while matching or beating the conventional design on the benchmarks they reported.
- Training leaned hard on long jobs including coding, browsing, research, visual work, agent sessions running hundreds or thousands of tool calls in a row.
- 1 Million cached input tokens costs $0.30. An agent can pull the same repo, the same docs, the same tool definitions back into context over and over without the bill getting stupid. Moonshot credits that to the memory design working alongside their serving stack.
- The biggest takeaway: context window size is the main character, but what matters is what a model compresses, what it forgets, and how it gets exact information back.
Discrete Fourier Transform by hand ✍️ ~ 12 steps walkthrough below
Here is a little-known secret about the DFT and the inverse DFT: it is just matrix multiplication in both directions, one the transpose of the other, exactly like the forward pass and backpropagation I drew in other examples.
Goal: recover which cosine waves a signal is made of, using nothing but multiplication and addition.
= 1. Given =
Three signals written as sums of cosines, and a fourth, X, that we do not know yet.
= 2. Frequency matrix F =
Let us write the coefficients as a matrix. Each signal is a row, each frequency a column, so A = cos(w) + 2cos(2w) becomes [1, 2, 0, 0].
= 3. Sample the waves =
We read the four cosine waves at ten discrete time points. That word "discrete" is the whole difference between this and the continuous transform.
= 4. Cosine matrix W =
Let us write those samples as a matrix: each frequency a row, each time point a column.
= 5. Frequency to time =
We multiply F by W. That combines the four cosine waves in the proportions F specifies, and the result T is the three signals as they would look in time.
= 6. Transpose =
Let us stand each signal up as a column.
= 7. Time to frequency =
We multiply W by that transpose. Every cell is the dot product of one signal with one cosine wave, which measures how much of that wave the signal contains. Zero means none of it.
= 8. Scale =
Let us multiply by 2/n, with n = 10. The projections come out five times too large, and this is the correction.
= 9. Transpose back =
We turn it back around, and it is F again, exactly. That is the check: the transform recovered the coefficients we started from.
= 10. Now solve for X =
Let us run the same multiplication on the one signal whose recipe we never knew.
= 11. Scale =
We divide by 5 again.
= 12. Transpose back =
And X reads [0, 0, 3, 2], which says X = 3cos(3w) + 2cos(4w).
Note: I originally drew this to show that the DFT is a special case of a convolution layer, its filters fixed to sine and cosine waves rather than learned. No wonder, then, that a convolution layer free to learn its own filters can be trained to process signals.
💾 Save this post!
RLHF by hand ✍️ ~ 15 steps walkthrough below
Train a model on human text and it inherits human bias. It will assume a doctor is a "him", because the data says so.
RLHF is the correction. A human marks one preference, doc is them over doc is him, and the weights move.
But one correction is not the point. The hope is that the model learns the value behind it, gender neutrality, and applies it to professions nobody ever mentioned.
How does it work?
Goal: train a reward model from a single human comparison about doctors, then turn it on CEOs, filling in every cell yourself.
= 1. Given =
A reward model, an LLM, and two (prompt, next) pairs.
= 2. Preferences =
A human reads both pairs and picks a winner: (doc is, them) beats (doc is, him). The loser is not bad grammar, it is gender bias, and that is the whole signal.
= 3. Word embeddings =
Let us look up each word of the loser pair. These vectors are the reward model's input.
= 4. Linear layer =
We multiply by the reward model's weights and add its biases. Out come feature vectors, one per position.
= 5. Mean pool =
Let us multiply by [1/3, 1/3, 1/3], which averages the three positions into one sentence embedding.
= 6. Output layer =
We map that sentence down to a single number. Reward = 3.
= 7. The winner, the same way =
Let us repeat steps 3 to 6 on the winning pair. Reward = 5.
= 8. Winner minus loser =
We take the gap: 5 - 3 = 2. The reward model wants this positive and as large as it can make it.
= 9. Loss gradient =
Let us squash the gap into a probability, σ(2) ≈ 0.9, and subtract the target of 1. The gradient is -0.1, and it goes back through the purple weights. The reward model is now trained.
= 10. A prompt it has never seen =
We start the second half with "[S] CEO is". The feedback in step 2 was about doctors. Nothing connects a CEO to a doctor except what the reward model generalised.
= 11. Transformer =
Let us push it through attention and a feed forward layer, one vector per position.
= 12. Output probabilities =
We map each vector to a score over the vocabulary.
= 13. Sample =
Let us take the highest score. The model completes "CEO is" with "him", which is the same bias the human penalised in step 2.
= 14. Score it with the reward model =
We feed the new pair (CEO is, him) through steps 3 to 6. Reward = 3, exactly the score it gave "doc is him" in step 6. Nobody taught it about CEOs. The value transferred.
= 15. Loss gradient =
Let us set the loss to the negative of the reward, so minimising the loss maximises the reward. The gradient is a constant -1, and it goes back through the red weights.
The outputs:
Loser reward = 3, winner reward = 5
Reward gap = 2, predicted σ ≈ 0.9, reward model gradient = -0.1
LLM samples "him", reward = 3, LLM gradient = -1
Congrats! You just calculated RLHF by hand.
And you watched a value generalise: one comparison about doctors, and the model marks down "CEO is him" unprompted.
💾 Save this post!
Very cool paper from Microsoft.
The idea is to train agents on replayed teacher trajectories instead of live environment rollouts.
On-policy distillation for agentic tasks is expensive because every update needs fresh student rollouts through the environment plus teacher queries at each visited history.
New research from Microsoft Research and the University of Amsterdam introduces ReOPD, which reuses pre-collected teacher trajectories as replayed prefixes. The student acts at selected steps while the teacher supplies dense per-step supervision without executing anything new.
The paper also names a real pathology in multi-turn distillation, the prefix trap. Pushing histories toward the student's own distribution makes them more relevant to the student and simultaneously drags the teacher onto states where its targets are unreliable. Two-sided distribution shift between student occupancy and teacher reliability.
ReOPD treats this as reliability-aware prefix distribution design and implements it with a step-decaying sampling schedule that emphasizes early, lower-shift prefixes.
Across math reasoning with Python and search environments, over multiple teacher and student scales, it preserves or improves accuracy, uses zero tool calls during student training, and runs at least 4x faster per rollout.
Paper: https://t.co/Jg2RMZX17S
Learn to build effective AI agents in our academy: https://t.co/LRnpZN7L4c
Yes, open-source / open-weight models are important for a healthy AI ecosystem. That's how we can verify things, check claims, and keep up outside the closed labs. Plus, it gives us the freedom to run AI on our own hardware if we are not ready to share personal data and IPs with closed labs through using their models. (Not that proprietary models are bad, actually I use them a lot as well, but it wouldn't healthy not to have any alternatives.)
Anyway, while pretty much everyone is waiting for the Kimi K3 and Ling 3.0 weights to land on the model hub any day now, there were quite a few other interesting new open-weight model releases the past week. Yes, one of those weeks!
So, here are the architecture pics along with some notes on what I found most interesting:
1) Nanbeige 4.2 3B uses looped depth sharing. This basically means it runs the same 22-layer (=transformer block) stack twice. So, it extends the 22-layer architecture to 44-layers, but without duplicating the weights. (2x the transformer block compute but same memory footprint.)
Why? The info is a bit sparse, but section 2.1 of the Nanbeige 4.2 technical report says two passes gave the best trade-off and retained about 75% of the token efficiency of a standard architecture. More passes gave barely any gains but made the training much slower and much more expensive.
2) Laguna S 2.1 is poolside's Laguna model in a really nice size: 118B sparse MoE with 8B active parameters and a 1M-token context window. Otherwise, the architecture is pretty standard. It uses 36 sliding-window and 12 global (gated-)GQA layers. However, given this size, and the fact that it (just barely) runs on my DGX Spark (uses about <80 GB of RAM), this is right now the most interesting model for me personally. It's 3x bigger and thus a tad slower but maybe a good candidate as daily-driver-Qwen3.6-35B-replacement. (Still waiting on some more independent performance benchmarks though.)
3) Motif-3-Beta is a new 314B-A13B sparse MoE that is somewhat based on DeepSeek V4 in terms of mHC and latent attention. But it uses a new component, Grouped Differential Latent Attention, which is inspired by Multi-head Latent Attention. I probably should write an article about this some time, but for now, the tl;dr is as follows. Regular MLA compresses the keys and values into a smaller latent representation to mainly reduce the KV cache size. GDLA does a similar low-rank compression but puts the attention heads into groups and also learns a noise head for each group where the noise gets subtracted for filtering purposes... Anyway, a topic for another day!
4) Solar Open 2 is a new 250B-A15B hybrid MoE by Upstage that interleaves three Kimi Delta Attention layers with one GQA layer.
5) Antares 1B is a small model (and there is also an even smaller 0.3B variant) from Cisco starts that with the IBM Granite 4.0 1B backbone and uses SFT plus GRPO for terminal-based cybersecurity stuff. It is a nice example of task-specific post-training on a genuinely small model.
6) BTL-3 is a rank-32 LoRA adapter for Qwen3.6-27B aimed at coding agents and structured tool use. The really strong benchmark performance suggests that LoRA adapters are still a useful tool/technique in 2026.
I added all six to the LLM Architecture Gallery for some additional details:
https://t.co/JDtfup3ncn
Generative Adversarial Network (GAN) by hand ✍️ ~ 9 steps walkthrough below
The Gen in GenAI came from this landmark paper by Ian Goodfellow et al., 12 years ago.
The paper showed that a neural network can not only classify but also turn upside down to generate realistic looking images.
The secret? We pit two of them against each other: a Generator turns noise into fake data, and a Discriminator learns to tell fake from real, pushing the Generator to keep doing better.
One runs upside down, the other right way up.
I drew and calculated one entirely by hand.
Goal: generate realistic 4D data out of 2D noise, filling in every cell yourself.
= 1. Given =
Four noise vectors in 2D, and four real data vectors in 4D.
= 2. Generator, first layer =
Let us multiply the noise by weights and biases to get new features.
= 3. ReLU =
We apply the activation, and -1 and -2 are crossed out and set to 0.
= 4. Generator, second layer =
Let us multiply again. ReLU applies here too, but every value is already positive, so nothing changes. What comes out is the fake data F, made by a two-layer generator out of nothing but noise.
= 5. Discriminator, first layer =
We feed it both, the four fakes and the four real vectors, through the same weights. It never learns which is which from the layout, only from the numbers.
= 6. Discriminator, second layer =
Let us reduce each data vector to a single feature Z. Eight vectors in, eight numbers out.
= 7. Sigmoid =
We turn each Z into a probability Y. A 1 means the discriminator is certain the data is real, a 0 means certain it is fake.
= 8. Training the Discriminator =
Let us take the gradients as Y minus YD, where YD is what the discriminator should have said: 0 for the four fakes, 1 for the four real. Why so simple? Because pairing sigmoid with binary cross entropy loss makes the math collapse to exactly this subtraction. Its loss uses both halves of the page.
= 9. Training the Generator =
We do it again, as Y minus YG, and YG is [1, 1, 1, 1]: the generator wants the discriminator to call every fake real. Same predictions, different target, opposite goal. Its loss uses only the fakes.
The outputs:
Fake data F = [1, 2, 3, 1], [1, 1, 2, 1], [2, 2, 4, 2], [1, 0, 1, 1]
Predictions on fakes = [.7, .5, .9, .3]
Predictions on real = [.7, .9, .9, 1]
Discriminator gradients = [.7, .5, .9, .3] and [-.3, -.1, -.1, 0]
Generator gradients = [-.3, -.5, -.1, -.7]
The takeaway: the adversarial part is one subtraction done twice. The same eight predictions, scored against two opposite targets, send one set of gradients back through the blue weights and another back through the green ones.
💾 Save this post!
Announcing the hosted X MCP.
Agents now have access to the best real-time information source in the world.
Connect Grok, Cursor, or any MCP-compatible AI tool to the X API without any setup!
Check it out here: https://t.co/5MzPYwGFzD