metalscope
A view inside your local model
21 November 2026
I wanted a little avatar for my local model: something beside the terminal that showed what was happening inside the model as it worked. After a few attempts that didn't feel right, it became more practical, and more fun, to visualise the model's internal state itself and make that the show. That turned into metalscope.
Here's a quick demo. The rest of the post goes through each feature in turn.
Metalscope sits on top of two inference engines for Apple Silicon: oMLX, by jundot, who now works on it full time at Hugging Face, and ds4 from antirez. It leaves the inference kernels of both alone. On oMLX it installs hooks into the running server and on ds4 it applies a small patch, and in both cases the job is the same: record traces, usually activations, while the model generates. From those traces we can pull out some fun information about how the model is working things out, and get a glimpse of its internal state.
All of this shows up in Pi, a coding agent that runs in your terminal: metalscope adds a dock beside the chat that fills in live as the model generates, plus a few commands. The clips in this post are all recorded in Pi with that dock open.
It comes with a handful of features:
- Token probabilities for every prediction: the reply coloured by the assigned probability
- Engram analysis to see which predictions leaned on the model's static lookup table
- Logit and Jacobian lenses to look at the model's internal state and at when it might have decided what to say
- Mixture of Experts routing to see which parts of the model are used for which kind of prediction
- Steering - a mostly experimental way to control the model's output through its activations, without having to use prompts!
There are lots of ways to interpret these traces, so rather than focusing on one, the goal of metalscope is to find a fun way to visualise all of them and present them in a way anyone can understand.
It's also just about having something to look at while the model is processing away: the full dock when you want to inspect things, or the mini dock as a little light show. The traces aren't free though and the numbers for every model are at the end.
Required
- A Mac.
- An engine to serve the model: oMLX for MLX models, or ds4 for Qwen3.8 Flash Next and DeepSeek V4.1 Flash.
- Pi for the dock. Without it, the same features work from the command line (but no visual dock).
- Not every feature runs on every model, so each one below lists what it runs on. Replies and maps work with any chat model, the engram needs a model that has one, and the expert map needs a mixture of experts. Residual streams are handled differently per model since there's a lot of variety but hopefully the display is fun and informative on a basic level.
Quick feature overview
Replies
- Any chat model
- Any chat model
- Qwen3.5 2B
- Qwen3.6 35B
- Qwen3.8 27B
- Qwen3.8 Flash Next
- Inkling 2 Mini
- Qwen3.8 Flash Next
- DeepSeek V4.1 Flash
← → step through the tokens, u jumps to the next unsure one, f follows the reply.ctrl+\ opens the dock, m swaps it for the mini dock.The first thing in the dock is simply the reply itself, with each token colour coded by the probability the model gave it. As in the demo, it appears in the dock in real time as the model generates.
m swaps the dock for the mini dock while a reply is written.Alongside the reply there's the probability map, which is the same thing laid out as a grid (thinking is dimmed), and the current token with the top 10 predictions at that step. Then come the lenses and the expert map: a grid per layer where every cell is an individual expert. You can move through all the tokens both during and after generation.
← → one token at a time, u the next unsure one, 1 the whole session as a map.Maps
- Any chat model
- Any chat model
← → move through the cells, and TOKENS shows the ten candidates the model weighed for the one in focus.1 opens it full size, the whole session.The reply and the probability map show the same thing, but sometimes it's nicer to have a condensed, at-a-glance view of how the model is generating. The example below shows how clearly the probabilities differ with the kind of text. In the first pane the model lists the countries of the world with their capitals, and the map is mostly green: outside of the prose, most of those tokens are very obvious. In the third pane the model is asked for a nonsense poem, and interestingly the result is a string of tokens with much flatter distributions. It's tempting to read this as confidence but that's not really what it is. A nonsense poem has lots of equally good next words, so the probability is spread across them.
The second pane is code, which has a very structured syntax and grammar, so the map is mostly green as well. The two tokens that decide what the function is going to be about, print and tokens, are among the least obvious (39% and 45%), while the def just before them is at 100%.
Engram
- Qwen3.8 Flash Next
- Qwen3.8 Flash Next
- DeepSeek V4.1 Flashdisk streaming only
g on a finished reply.Engrams were first introduced by DeepSeek in a paper, although DeepSeek V4, which came out afterwards, didn't use one. Qwen3.8 Flash Next shipped its own version in August, and DeepSeek V4.1 Flash followed a few weeks later. Both run well on my M5 Max with 128 GB of RAM and I use them a lot, so it was natural to see how much the engram actually helps.
The name is a play on "n-grams" (an engram is also the neuroscience word for a memory trace), and you can think of the module as the model's internal look-up table for information that doesn't really need any context. Take King Arthur: a well-known figure who shows up in tons of stories about knights and adventures in Britain. The usual thinking was that this kind of knowledge is spread through the model's layers, and that the representation of an "Arthur" token has to be refined layer by layer, meaning all that knowledge about King Arthur might not really be available until the model has processed the token through several layers. The new architecture from DeepSeek (and now Qwen) tackles that with an engram module, which is functionally a trained look-up table that gives static information a designated place.
Once the model has finished a reply, press g in the dock. Metalscope runs the reply through the model a second time with the engram switched off, and compares each token's probability with and without it; the dock colour codes the tokens it helped. It scores the reply already written, not what the model would have written without it.
This can take a while, so there's a little "processing" animation and a loading bar to tell you how long it might take. The probability map is then repurposed as an engram map, to give a sense of how many of the tokens were helped. Ask the model to count from 1 to 100 and almost nothing is helped (about 1% when measured), since no actual knowledge is needed for that.
g: the lookup's share of each token.To demo this, we ask the local model for the opening of Wikipedia's article on black holes. It's a very information-dense topic, covering lots of subtopics and full of terminology: exactly the type of text that might benefit from a lookup that passes in a bit more than you'd get from the text alone. In the frame below you can hover over the tokens (as you can in the dock) to see which ones benefited most from the lookup.
It's somewhat surprising how well the model still predicts the same text with the engram switched off: almost half of the tokens here got no help from it at all. Still, it's a hint that a lot of what the engram stores can also be worked out the long way, through the layers.
Lenses
- Every model
- Qwen3.5 2B
- Qwen3.6 35B
- Qwen3.8 Flash Next
- Inkling 2 Minifitted with /jlens learn; none ships
- Qwen3.8 Flash Next
- and + change how many layers are read, s switches lens./jlens learn windows 8 fits a lens on 8 windows of text; a published one can be converted.The features so far mostly work from the model's output: the logits and probabilities. The rest look at the internal activations, which are just as interesting but very much up for interpretation.
We present the lens below as a kind of microscope, one we can make deeper or shallower depending on how much information we want. The logit lens is a very simple idea: take the final output layer, the one that produces the logits, and stick it after any other layer. That gives you the prediction the model would have made had it stopped processing at that point.
It does give a sense of the internal state, but it's not a great lens. Nothing really forces the representations at the beginning or middle of a model to line up with the output layer, so the logit lens often only starts to show any consistency near the end of the model.
The Jacobian lens, on the other hand, shows a lot more consistency, but it needs some additional training. Instead of using the output layer alone, it adds a matrix per layer that aligns the directions of the internal representation with the directions the output layer expects. To get that matrix we measure, over lots of text, how a small change to a layer's state changes the model's final state (that's the Jacobian) and take the average. A layer's state goes through its matrix first and only then through the output layer; the logit lens is the same thing with the matrix left out. The result is a clearer and more consistent picture of which "tokens" or concepts are being represented, and a hint of when the model settled on what to say.
To visualise this neatly, metalscope has a "SETTLING" map, which shows the layer at which the model "settled" on its decision to output a specific token. What's interesting is that tokens which appear later in the text are often already represented in the internal state several tokens beforehand. The window we fit on is only 128 tokens by default, but that's plenty of time for concepts to show up in the model's internal state.
2 puts the J-lens and the logit lens side by side.Here the lens already reads "syrup" at layer 4, while low-probability words like "warm" or "like" never settle in the lens but are still output at the end. A token settling early doesn't mean the processing after it is wasted: that computation can still set up concepts that show up later on, and is still part of the model's planning.
Held-out hit@10: how often the model's own next token is in the lens's top 10, scored after each window of the fit. Dashed: each model's logit lens, which needs no fit. Each model is scored on its own middle layers (Flash Next 20 to 44, the 35B 16 to 36, Inkling 2 Mini 7 of its layer visits), so compare a model with its own dashed line, not with another model. Inkling's first 7 windows were scored another way and are left out.
Tokens a second at each setting, on a log axis (the table below has the same numbers). Each lens step reads more layers, from the lightest to every layer the lens has. A 300-token reply, the median of 3.
The more windows of text we include in the lens training, the better the fit: on Flash Next, the model's next token was in the lens's top 10 for 15% of held-out positions after 1 window and 28% after 36, against 14% for the logit lens (the dashed lines), which needs no training at all. Those scores are over the middle layers only (20 to 44), which is the hard part: by the last layers any lens agrees with the output. A window took about 35 minutes on my Mac, and you can't really use the model to chat or work in the meantime, so it's an overnight job.
In metalscope, a simple /jlens learn windows 8 fits the lens on 8 windows of text. It loads its own MLX copy of the model, so it only works for models served by oMLX and not ds4. Once the lens is learned, though, you can easily use it with ds4, which is often the faster inference path: metalscope gives you a neat way of linking a lens to any served version of the same model.
We can control how many layers we read, and every layer read has a cost. A logit lens reading is one extra matmul: the layer's state through the output layer. A J-lens reading is two: first through the lens matrix, then through the output layer. The output layer matmul covers the whole vocabulary, the same one the model does once per token to make its prediction, so reading many layers repeats the most expensive step many times and your decode speed drops. It's a reasonable slowdown though, and the lenses are some of the more fun things to look at and play around with.
Word swap (experimental)
- Qwen3.5 2B
- Qwen3.6 35B
- Qwen3.8 Flash Next
- Inkling 2 Minifitted with /jlens learn; none ships
- Qwen3.8 Flash Next
enter on a token, type the new word, and the reply is redone from that token. /steer old>new does it for a whole reply.So a lens gives us a sense of what the model could have said. But sometimes we might want it to say something else! The Jacobian lens gives us a fun way to encourage that.
If we take a token's row of the output layer and pass it back through the Jacobian lens, we get a vector for that token in the internal state: the direction to nudge the state at that layer to make the token more likely. If I want the "Lord" token to be more likely, I can find its vector and add it to the internal state at a given layer. In the same way, I can find the vector of a token I want gone and take it out. In metalscope you can either delete a word or swap it for another, and that may change what the model goes on to say.
It's mostly a fun experiment, but maybe you could stop a model overthinking by swapping "Wait!" for "Aha!". And depending on the word you remove, you might change the token without changing the overall meaning of the sentence.
Experts
- Qwen3.6 35B
- Qwen3.8 Flash Next
- Inkling 2 Mini
- Qwen3.8 Flash Next
- DeepSeek V4.1 Flash
4 then enter opens a layer, then one expert: the tokens it is most distinctive for, counted from your own traced chats.4. metalscope experts layout seats experts that fire together side by side.The most visually striking part of metalscope is the expert map. Naturally it's only there for MoE models: with a dense model, that space is mostly filled by additional lenses.
Routing is fun to watch, and it's easy to see why we call them "experts": the intuitive picture is that the model smartly hands out specialities, sending each MLP the kinds of tokens, or sequences of tokens, it has been trained to handle best. In reality that's only a small part of the story, and what an expert ends up learning is often not all that intuitive.
Sometimes, though, we do get a fun glimpse of what's going on. If we ask the model to name all the knights of the Round Table, the expert map shows which expert in each layer was routed which token, and in layer 8 at least, expert 151 gets every one of the knights' names! So voilà, we have (loosely) identified a name expert.
Is this useful? Not directly, but it is interesting. Experts that specialise cleanly can hint at healthy training dynamics, but without watching the training itself it's hard to say much: all we have is the finished model. Specialisation is something you might want to emerge, but in practice it's rarely the main target. At best it's a diagnostic; for a local setup, it's a good light show.
Steering
- Qwen3.5 2B
- Qwen3.6 35B
- Qwen3.8 27B
- Qwen3.8 Flash Next
- Inkling 2 Mini
- Qwen3.8 Flash Next
- DeepSeek V4.1 Flash
/steer NAME turns it on. /concept learn NAME makes a new one: the model writes its own example texts, then tests doses in conversation. 6 opens the Steer page with the test chats.Steering is the most experimental part of the repository, but it reveals a lot of underlying structure in the activations. It needs no model training, so it's relatively light on your machine's memory, but it does need a lot of generation and measurement.
ds4 has shipped its own directional steering built from prompt files you write yourself, and there's a proposal to port it to oMLX. Metalscope adds a short recipe around it: the local model writes its own pairs, the dose is calibrated in conversation, and it's all switched on and off from the dock.
The recipe has many parts and relies on the model itself to generate all the data. That makes it a bit slow, but it's very satisfying that your own local model can produce the vector that lets you push and pull it towards a certain style.
What we show below is the result of /concept learn shakespearean. The recipe:
- The model writes 16 pairs of lines: the same sentence with and without the concept.
- Both sides of every pair go through the model again, and we record the internal state at one layer.
- Average the states of the "with" lines, average the "without" lines, and subtract: what's left points (loosely) toward the concept.
- Calibrate: the model holds 3 short conversations (18 replies) at each of a ladder of doses, with the vector added at every token.
- The model grades its own replies for style, coherence and usefulness, 0-3 each. A reply is good if all three score at least 2.
- The dose with the most good replies becomes the default.
No weights are touched and there's no prompt: the vector is added to the model's state as it generates. Worth noting that the local model grading itself is a weak spot, since it may go easy on its own replies. Still, it keeps everything self-contained on your machine.
6: the Steer page.enter turns pirate on at its default dose; m swaps the mini dock and the full one.Adding the vector at every token, in just one layer, is enough to really drive the model's style of speech. Too high a dose clearly breaks things though (often more so the longer you chat, since every token gets pushed).
/steer shakespearean turns it on by command, at its default dose, for a Monday pep talk.Qwen3.8 27B oQ4e-mtp on oMLX, all three concepts calibrated the same day with the same 18 turns. A reply is good when it shows the concept and stays coherent and useful. Dose 0 is no steering.
pirate on three models, each calibrated and graded by itself: Qwen3.8 Flash Next (ds4 q4k), Qwen3.8 27B (oMLX), DeepSeek V4.1 Flash (ds4 q2, with Pi's system prompt and tools; the others with a plain one). Dose 0 is no steering.
Finding the right dose matters though. The chart shows good replies out of 18 at each dose. Dose too strongly and the model breaks; dose too little and nothing happens: the push is too small to register against the rest of the model's state.
Each model needs its own calibration: the same concept peaks at a different dose on different models.
One side experiment: instead of adding a vector, amplify single neurons. On Qwen3.6 35B one neuron was enough to get some of "joyful" (10 good replies out of 18, against 15 for the learned vector); on the larger Flash Next it took about 20 together (17 of 18). If a more reliable recipe turns up, it'll go into metalscope as well!
Other models
Impact on decode speed
In speed, model by model:
Tokens a second at each setting, on a log axis (the table below has the same numbers). Each lens step reads more layers, from the lightest to every layer the lens has. A 300-token reply, the median of 3.
| Tracing off | nothing is recorded, which matches default engine speed. |
| Tracing on, lenses off | enables everything in the dock but LENS: each token's probability and top 10 candidates, the expert routing and the residual stream. |
| Tracing on, lenses on | the logit and Jacobian lenses as well, read at more layers at each of five steps: lightest is the fewest layers, default the middle step, fullest every layer the lens has. - and + in the dock change the step. |
| tracing on | ||||||
|---|---|---|---|---|---|---|
| precision | tracing off | lenses off | light lens | default lens | full lens | |
| Qwen3.5 2B, oMLX | 4-bit | 288 | 264 | 209 | 218 | 183 |
| Qwen3.6 35B, oMLX | 4-bit | 205 | 192 | 169 | 158 | 112 |
| Qwen3.8 27B (MTP), oMLX | oQ4e | 57 | 58 | 54 | 48 | 40 |
| Qwen3.8 Flash Next, oMLX | oQ4e | 44 | 41 | 34 | 21 | 11 |
| Inkling 2 Mini (MTP), oMLX | oQ4e | 74 | 64 | 53 | 28 | 11 |
| Qwen3.8 Flash Next, ds4 | q4k | 69 | 63 | 55 | 40 | 18 |
| DeepSeek V4.1 Flash, ds4 | q2 | 16 | 16 | 16 | 15 | 14 |
Tokens a second from metalscope bench on an M5 Max with 128 GB: a 300-token reply, the median of 3, each setting after a minute's rest.
Try it
A Mac with Apple Silicon, and oMLX or ds4 serving the model. The README has the rest.
uv tool install git+https://github.com/nanastassacos/metalscope
metalscope omlx install
metalscope omlx restart
npm install -g @earendil-works/pi-coding-agent
metalscope pi install
metalscope doctor
Built on ds4, oMLX, Pi and Anthropic's Jacobian lens. If you try it, I'd love to hear what you see, and if you're into mechanistic interpretability, which analysis you'd like to see included.
One feature did not make it: attention sources, which showed for each token the stretch of the conversation its attention drew on most. On Flash Next that was the very first stretch (the attention sink) on 71% of tokens, so it was neither informative nor fun to look at, and it was removed.