sysnote
Analysis

Engram sizes LoRA adapters by a dataset's bits; its own figure shows most rank predictions run high

Engram, a company that trains models for individual users, published "Predicting LoRA size for any dataset" on November 24. The post proposes a way to choose a LoRA adapter's rank before training: measure how many bits the dataset takes under the base model, then read the rank off a curve of how many bits an adapter of each rank can store. All experiments use Qwen/Qwen3.5-0.8B. The post names no individual authors and links no code; GitHub repository searches for "engram lora" and "lora capacity bits rank" turned up nothing from the company.

I recomputed two things from the numbers the post publishes, without training any adapters myself: the closed-form capacity for a single weight matrix, and the predicted and measured ranks for the 15 real-dataset fits in its main figure. The formula holds up well. The rank predictions are looser than the text says: 5 of the 15 land within 5%, 9 are too high by more than that, the worst by 46%, and one is too low.

Bits as the common unit

The method rests on the link between language models and compression. The number of bits needed to encode a text under a model is its negative log-likelihood in base 2, so a dataset's size "under θ" is its total loss in bits. Training an adapter lowers that loss, and the drop, in bits, is how much the adapter has stored.

To measure capacity without mixing in how learnable real data is, Engram generates synthetic data of a known size. It runs arithmetic coding backwards: it starts from N random bits and decodes them into text with the model itself, which gives a sample whose code length under the model is N bits. The text contains no pattern the model hasn't already learned, so any further drop in loss is memorization of the random choices. Engram describes the resulting estimates as conservative, worst-case ones.

The single-matrix formula

For one m × n matrix adapted at rank r, a second-order expansion of the log-likelihood gives capacity as the expected sum of the top r squared singular values of a Gaussian random matrix, divided by 2 ln 2. The derivation assumes the Fisher information factors as a Kronecker product, which the post says is not generally true. At full rank the result is mn/(2 ln 2) bits, a classical result from Wilks' theorem. At low rank it comes to about 1.40 bits per LoRA parameter for a 512 × 1024 v_proj in Qwen3.5-0.8B and 1.32 for its 1024 × 3584 up_proj.

I computed the expectation by averaging 20 SVDs of 512 × 1024 Gaussian matrices and compared it with the storage Engram measured in its Figure 3 (KB here are 1,000 bytes, which is what makes the post's own figures consistent):

LoRA rank on v_proj Formula Measured by Engram
4 1.04 KB 1.12 KB
16 3.96 KB 4.04 KB
64 13.81 KB 13.9 KB
128 23.94 KB 23.9 KB
256 37.32 KB 37.4 KB
512 47.24 KB 47.4 KB

From rank 16 up the two agree within 2%. At rank 4 the measurement is 7% above the formula. One detail for anyone repeating it: Qwen3.5-0.8B is a hybrid, and per its config only 6 of its 24 layers are full attention with a 512 × 1024 v_proj; the others use linear attention. The post doesn't say which layer Figure 3 adapts.

Whole models, where the formula stops

The closed form covers one matrix. When several are adapted together, Engram measures capacity per parameter rising with depth: 1.76 bits per parameter for a rank-4 LoRA on the top MLP, 3.29 for all 24 MLPs. The post says its theory can't explain this yet. So on real models the rank predictions don't come from the formula. They come from an empirical capacity curve, built by training on synthetic datasets of known size and extrapolating each loss curve to infinite training with a fitted log-logistic function.

The same experiments also produced a conservation result: the adapter raised the loss on fresh samples from the base model by about as many bits as it learned. Engram says this follows from the same second-order analysis, because on base-model samples the gradient averages zero. The example in its figure is a synthetic run, and the explanation assumes data drawn from the base model, so it says less about forgetting in ordinary fine-tuning.

The predictions on real data

The main result covers 12 real datasets, from 22k tokens of Engram's internal emails to 20.5M tokens of MMMLU, in two settings: one MLP layer (mlp[23]) and all linear layers. For each dataset Engram measures its bits, reads off a predicted rank, trains at ranks from half to twice that, and reports the smallest rank that stores 95% of the data. The figure's data is in the page's markup, with all 15 pairs:

Setting Dataset Size under the model Rank needed Predicted Predicted / needed
mlp[23] Engram (XS), internal emails 54.4k bits 4.26 3.45 0.81
mlp[23] MATH-500 160k bits 8.26 8.98 1.09
mlp[23] Harvey C&H (XS), synthetic law firm 748k bits 37.0 38.3 1.04
mlp[23] Developer Docs 1.05M bits 52.3 53.5 1.02
mlp[23] GSM8K 1.89M bits 95.5 95.8 1.00
mlp[23] swebench-django 4.4M bits 227 232 1.02
mlp[23] Engram (MD), research notes 5.02M bits at most 203 275 1.35 or more
mlp[23] Harvey C&H (SM) 6.56M bits 282 413 1.46
all-linear swebench-django 4.85M bits 2.20 2.80 1.27
all-linear Tulu 3 (2,000 samples) 5.33M bits 2.84 3.06 1.08
all-linear Engram (MD) 5.79M bits 2.38 3.31 1.39
all-linear Harvey C&H (SM) 7.64M bits 3.60 4.32 1.20
all-linear No Robots 8.84M bits 4.45 5.05 1.13
all-linear OpenThoughts3 (250 traces) 9.43M bits at most 5.49 5.41 about 0.99
all-linear MMMLU 68.5M bits 42.5 47.5 1.12

The text says the estimates are "useful enough to predict rank within 5% error" and that the measured points "fall almost on the blue line". On the figure's log scale, which runs from rank 1 to 1,024, they do. In numbers, 5 of the 15 are within 5%, and one of those, OpenThoughts3, has only an upper bound for the rank needed. Nine predictions are higher than needed by more than 5%, from 8% (Tulu 3) to 46% (Harvey C&H SM on one MLP, 413 against 282). The one miss in the other direction is the smallest dataset, Engram XS, where the predicted 3.45 is 19% below the 4.26 it took.

The direction of the error fits how the curve is built. It comes from data that is pure noise to the model, while real text has structure an adapter can use, so a real dataset of a given size in bits should be easier to store than a synthetic one. The largest overestimates are on the workspace documents, at ranks where the one-MLP curve is flattening and a small difference in bits moves the rank a lot. That is my reading of the table; the post doesn't discuss the misses.

For what Engram wants, the smallest adapter that holds a user's data, an overestimate is the safe error: the adapter is larger than necessary, but it fits. On one MLP, rank 413 instead of 282 means 46% more adapter parameters. The undershoot on the small dataset is the case where the predicted adapter wouldn't hold everything.

What it gives someone choosing a rank

With those error bars, the figures still give a sense of scale for a 0.8B model. An all-linear LoRA at rank 2 to 3 held the Django source from SWE-bench (2.5M tokens); rank 42.5 held 20.5M tokens of multilingual MMMLU. Engram writes that it expects the findings "to transfer cleanly to other base models", but every run in the post is on Qwen3.5-0.8B. Measuring a dataset's bits takes one forward pass over it (Engram extends the context to 2M tokens with YaRN and sums the windows), which is cheap next to training. The capacity curve has to be built once for each base model and adapter layout, and that is the part someone else can't reuse: the post publishes neither the synthetic curves nor the code that produces them.

Comments

No comments yet. Be the first.

Write a comment

Comments are published after review.