<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: samad</title>
    <description>The latest articles on DEV Community by samad (@samadrehman).</description>
    <link>https://dev.to/samadrehman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3726965%2Fbef219c1-666a-4510-916a-92aedda9fef2.png</url>
      <title>DEV Community: samad</title>
      <link>https://dev.to/samadrehman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samadrehman"/>
    <language>en</language>
    <item>
      <title>I rebuilt Taalas's mask-ROM trick in Python. Two of their numbers didn't add up.</title>
      <dc:creator>samad</dc:creator>
      <pubDate>Fri, 04 Dec 2026 19:36:45 +0000</pubDate>
      <link>https://dev.to/samadrehman/i-rebuilt-taalass-mask-rom-trick-in-python-two-of-their-numbers-didnt-add-up-4p7b</link>
      <guid>https://dev.to/samadrehman/i-rebuilt-taalass-mask-rom-trick-in-python-two-of-their-numbers-didnt-add-up-4p7b</guid>
      <description>&lt;p&gt;TL;DR — I modeled Taalas's HC1 from published numbers. A straightforward model of the same architecture lands at 3.14 T/weight, not 6.6. The KV cache outgrows the weight array at ~1,276 tokens. And the 6.6 figure yields a prediction: the budget runs out at ~6,470 tokens. Code and tests: github.com/samadrehman/Mini-Taalas&lt;/p&gt;

&lt;p&gt;Taalas announced HC1 in February 2026 with numbers that sound like a typo:&lt;/p&gt;

&lt;p&gt;17,000 tokens/second on Llama-3.1-8B&lt;br&gt;
53 billion transistors for 8.03 billion parameters — 6.6 transistors per weight&lt;br&gt;
3-bit and 6-bit weights, not 4-bit&lt;br&gt;
Weights baked into mask ROM at tape-out, not loaded from HBM&lt;br&gt;
The pitch is that a model's weights stop being data and become geometry. If that's true, the economics of inference change completely: no HBM, no memory bus, no batching for throughput. You pay once at the mask and then almost nothing per token.&lt;/p&gt;

&lt;p&gt;I wanted to know whether the numbers survive contact with arithmetic. So I built a small version: a compiler that turns a weight matrix into a via map, and a simulator that runs inference from that map alone — no weight tensor, no checkpoint, no state_dict.&lt;/p&gt;

&lt;p&gt;Repo: github.com/samadrehman/Mini-Taalas — 1,450 lines, 30 tests, no GPU. Everything below is reproducible with python run_tests.py.&lt;/p&gt;

&lt;p&gt;Two things came out of it. One confirms their design choice. One is a prediction that can be checked against the real chip.&lt;/p&gt;

&lt;p&gt;The part most people get wrong: the sum is not an adder tree&lt;br&gt;
The obvious way to build a multiplier-free dot product is a lookup table and an adder tree. That is also the way that kills the idea.&lt;/p&gt;

&lt;p&gt;If each weight contributes a product and you sum 4,096 of them with a tree, you spend roughly 10 transistors per weight on addition alone. SRAM is about 24 transistors per 4-bit weight. An adder-tree ROM is worse than the thing it replaces, before you count the ROM cells.&lt;/p&gt;

&lt;p&gt;Taalas's 6.6 T/weight only makes sense if the sum is free. And it can be, because of Kirchhoff:&lt;/p&gt;

&lt;p&gt;products[k, c] = x[c] * (k - 8)            # 16 product lines, k = 0..15&lt;br&gt;
picked[r, c]   = products[codes[r, c], c]  # the via selects one line&lt;br&gt;
y[r]           = scale[r] * sum_c picked[r, c] + bias[r]&lt;br&gt;
The column bus sums by charge sharing. Current from every cell on the column adds on the wire. No adder, no tree, no carry chain. One transistor per weight, one sense amplifier per column.&lt;/p&gt;

&lt;p&gt;That's the whole trick, and it's why the architecture is interesting: the summation is a physical property of the interconnect, not a circuit you pay for.&lt;/p&gt;

&lt;p&gt;The via is what stores the weight. Each cell has a 4×4 grid of candidate via positions — 16 positions, 4 bits. The transistor is identical in every cell. Only the via mask changes.&lt;/p&gt;

&lt;p&gt;That image is generated by bench/gds_render.py and written as real GDSII — 192 polygons across three layers (cell pad, via, upper-metal stub). The test suite reads the file back with gdstk and asserts the polygon count per layer, so the artifact is a valid layout file and not a picture of one.&lt;/p&gt;

&lt;p&gt;This is what makes a two-mask re-spin possible. A new model needs a new via mask and a new metal mask. Everything under it — the transistors, the array, the sense amps — is unchanged. That is the entire business case for a mask-ROM inference chip, and it is why "model lock-in" is the real risk rather than a footnote.&lt;/p&gt;

&lt;p&gt;Finding 1: 4-bit is not free. 6-bit is the honest operating point.&lt;br&gt;
I quantized GPT-2 small (124M) with GPTQ and measured perplexity on wikitext-2. fp32 baseline, then round-to-nearest, then GPTQ, at both 4 and 6 bits. Per-output-channel, per-group scales (group size 128).&lt;/p&gt;

&lt;p&gt;fp32 — 31.145&lt;br&gt;
4-bit RTN — 37.259 (+19.63%)&lt;br&gt;
4-bit GPTQ — 33.608 (+7.91%)&lt;br&gt;
6-bit RTN — 31.031 (−0.37%)&lt;br&gt;
6-bit GPTQ — 31.404 (+0.83%)&lt;br&gt;
GPTQ recovers most of RTN's damage at 4 bits — 19.6% down to 7.9% — but it does not reach lossless. Getting under 2% at 4 bits needs a smaller group size, activation-order, or QAT, and each of those costs you something in the compiler or the calibration pipeline.&lt;/p&gt;

&lt;p&gt;6-bit lands at +0.83%, which is inside the noise of a 2,048-token eval.&lt;/p&gt;

&lt;p&gt;This is why Taalas shipped 3-bit and 6-bit, not 4-bit. Their first silicon uses mixed precision: 6-bit where accuracy is fragile, 3-bit where it isn't. A uniform 4-bit ROM would have been the worst of both worlds — not lossless, and not dense enough to justify the mask respin.&lt;/p&gt;

&lt;p&gt;I originally set my own success criterion at "4-bit under 2%." The measurement said that was wrong, so I changed the criterion and wrote down why. A spec that survives contact with data unchanged is usually a spec nobody measured.&lt;/p&gt;

&lt;p&gt;Finding 2: the KV cache outgrows the ROM at about 1,276 tokens&lt;br&gt;
This is the one I didn't expect.&lt;/p&gt;

&lt;p&gt;Weights can live in ROM because they're frozen. The KV cache can't — it's written every token, so it lives in SRAM, and SRAM is expensive. I modeled Llama-3.1-8B's shape (32 layers, GQA with 8 KV heads, fp16 cache) and counted transistors per weight:&lt;/p&gt;

&lt;p&gt;512 tokens — 1.94 T/weight (ROM 1.00, SRAM 0.40)&lt;br&gt;
2,048 tokens — 3.14 T/weight (ROM 1.00, SRAM 1.60)&lt;br&gt;
8,192 tokens — 7.95 T/weight (ROM 1.00, SRAM 6.42)&lt;/p&gt;

&lt;p&gt;At 2K context the cache is already 1.6× the size of the weight array. At 8K it's 6.4×.&lt;/p&gt;

&lt;p&gt;"Configurable context size" on a chip like this is not a software setting. It is a statement about how much SRAM you bought, and SRAM is the part that scales badly. The ROM is a one-time cost that amortizes over every token forever; the cache is a per-token cost that grows linearly with how much you want the model to remember.&lt;/p&gt;

&lt;p&gt;Every "inference is now free" pitch has this hole in it, and it's an SRAM hole.&lt;/p&gt;

&lt;p&gt;Finding 3: the 6.6 figure implies about 2.1× overhead&lt;br&gt;
Here's the arithmetic that started all this.&lt;/p&gt;

&lt;p&gt;8.03B parameters at one transistor per weight is 8.03B transistors. HC1 has 53B. That's 6.6×.&lt;/p&gt;

&lt;p&gt;My naive model — ROM cells, control and wiring, drivers, sense amps, ADC, I/O, and the KV cache at 2K context — lands at 3.14 T/weight. To reach 6.6 you need another 2.10×.&lt;/p&gt;

&lt;p&gt;I don't know what that 2.1× is. Candidates, roughly in order of how much I'd bet on them:&lt;/p&gt;

&lt;p&gt;ECC. A 4-bit cell storing 4 bits plus parity is 5/4 = 1.25× on the array alone.&lt;br&gt;
Spare rows and columns. Mask ROM is programmed at manufacture; yield repair needs redundancy. This is routinely 10–20% of an array.&lt;br&gt;
The compute fabric. Softmax, LayerNorm, GELU, the attention score path. None of that is ROM, and at 17,000 tok/s it is not small.&lt;br&gt;
The actual bitcell. I assumed one transistor. A real mask-ROM cell may need a select device, or a differential pair for sensing, which would change the count substantially.&lt;br&gt;
I am presenting this as a question, not an answer. The gap is the interesting result: the public number is 2.1× larger than a straightforward model of the same architecture, and nobody has published a breakdown. If you work on this chip, you know which of those four it is. I'd like to.&lt;/p&gt;

&lt;p&gt;The prediction&lt;br&gt;
Take the model at face value and solve for the context length where it hits 6.6 T/weight.&lt;/p&gt;

&lt;p&gt;The 6.6 budget is exhausted at ~6,470 tokens. At 8,192 tokens the naive model already needs 7.95 T/weight — 20% over budget.&lt;/p&gt;

&lt;p&gt;So one of these is true:&lt;/p&gt;

&lt;p&gt;HC1's usable context is ≤ ~6.5K tokens, and the 8K/128K numbers in the marketing refer to something else, or&lt;br&gt;
The KV cache is not on-die — it lives in external memory, which reintroduces the memory bus the architecture was supposed to eliminate, or&lt;br&gt;
My model is wrong in a specific, findable way.&lt;br&gt;
That is a falsifiable claim about shipping hardware. It's the kind of thing you can only make by building the model and doing the arithmetic, and it's the reason this project was worth a week.&lt;/p&gt;

&lt;p&gt;What this is not&lt;br&gt;
Being precise about this matters more than the findings:&lt;/p&gt;

&lt;p&gt;Not manufacturable. The layout is a visualization. It is not DRC-clean, the pitch is not minimum, and there is no PDK behind it.&lt;br&gt;
Summation is modeled, not simulated electrically. No charge sharing, no noise, no sense-amp offset, no sneak paths. The claim is architectural, not electrical. Real arrays have to solve capacitance balancing per column, and that is exactly the part that's hard.&lt;br&gt;
One architecture. The fabric is generic only for models with the same shape. A different d_model or GQA ratio needs different lower layers, which is why "two masks for any model" is narrower than the press release implies.&lt;br&gt;
Model lock-in is the business risk. The ROM is frozen at tape-out. A new base model is a full re-spin. That's fine if you're selling a fixed model as a product; it's fatal if your customers expect to swap models quarterly.&lt;br&gt;
Patent status. The architecture is covered by US20250123802A1. This repo is for study and for FPGA targets, not a commercial mask-ROM implementation.&lt;br&gt;
Reproduce it&lt;br&gt;
python run_tests.py     # 30 tests: quantization, packing, ROM path, GDS, SRAM&lt;br&gt;
python demo.py          # compile -&amp;gt; save -&amp;gt; delete weights -&amp;gt; run from the map alone&lt;br&gt;
python bench/t1_accuracy.py --tokens 2048 --calib-samples 16 --bits 4&lt;br&gt;
python bench/t1_accuracy.py --tokens 2048 --calib-samples 16 --bits 6&lt;br&gt;
python bench/density_chart.py&lt;br&gt;
python bench/gds_render.py&lt;br&gt;
The test that matters is test_checkpoint_unnecessary: it saves the via map, deletes the weight tensor, and runs inference from the file. If the simulator could still find a weight tensor, the whole demo would be a matmul in costume.&lt;/p&gt;

&lt;p&gt;Why I built this&lt;br&gt;
I'm not trying to clone a chip. I'm trying to answer a question I couldn't answer from the outside: does the arithmetic of mask-ROM inference actually work, or does it only work in a press release?&lt;/p&gt;

&lt;p&gt;Two of the numbers hold up. One of them has a 2.1× gap nobody has explained. And there's a prediction about context length that someone with the hardware can check in an afternoon.&lt;/p&gt;

&lt;p&gt;If you work on inference hardware, compilers, or quantization and any of this is wrong, I'd genuinely like to know — the repo has the tests, and the tests are the argument.&lt;/p&gt;

&lt;p&gt;Code, spec, and every number: github.com/samadrehman/Mini-Taalas&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5eqfqll0lotw25a7yijg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5eqfqll0lotw25a7yijg.png" alt=" " width="800" height="477"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy3scize5773hvdn7s66z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy3scize5773hvdn7s66z.png" alt=" " width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hardware</category>
      <category>llm</category>
      <category>python</category>
    </item>
  </channel>
</rss>
