Running a Language Model in About 14 MB of Memory: An Inference Experiment on a Printer
A recent experiment demonstrated that a small language model could perform forward inference on a printer while using only about 14.1 MB of peak memory. This article explains how an existing page-description-language interpreter, low-bit quantization, and dynamic layer loading made the experiment possible, as well as the resulting performance bottlenecks, engineering trade-offs, and practical limitations.
1. Background: Why Run a Model on a Printer?
Large language model inference typically depends on GPUs or dedicated accelerators. Model parameters, intermediate activations, and the attention key-value cache (KV cache) all consume memory, while inference also requires substantial parallel computing capacity. As a result, most inference services run in data centers, while endpoint devices generally handle only lightweight workloads.
The growth of edge computing raises another question: can a model run on an extremely resource-constrained device? Office printers are a representative example. They contain a processor and a small amount of memory, originally intended to parse page-description data and control printing hardware—not to run neural networks.
A recently published experiment showed that a printer could complete a forward pass of a small language model while using approximately 14.1 MB of peak memory. The significance of the experiment lies in demonstrating technical feasibility and revealing engineering strategies for severe resource constraints. It should not be interpreted as a production-ready deployment method.
2. Experiment Overview and Reported Measurements
According to public reports, the experiment used the following parameters:
- Model size: Approximately 270 million parameters across 18 Transformer layers.
- Peak memory: Approximately 14.1 MB, far below the memory required to load the complete model.
- Input processing (prefill): About 184 seconds to process a short input prompt.
- Single-token decoding: About 0.1 seconds to generate one output token.
- Total time: 184.1 seconds according to the report.
- Average speed: The report stated approximately 60 seconds per token, or about 1/60 of a token per second—not 60 tokens per second.
These figures do not appear to use entirely consistent measurement definitions. Prefill and decoding are two different inference stages with very different runtime characteristics. The reported “approximately 60 seconds per token” is a rough average across the overall process, while the 0.1-second figure may apply only to the decoding stage. These metrics should be kept separate and should not be directly reused to estimate performance in other environments.
3. Core Technical Principles
The experiment involved three key techniques: executing computations through an interpreter already available on the device, quantizing the model, and loading layers dynamically.
3.1 Using an Existing Interpreter for Computation
The printer’s processor runs a page-description-language interpreter capable of handling an instruction set that includes arithmetic, stack operations, and control flow. By encoding the required matrix operations, activation functions, and normalization steps as such instructions, the inference process can run entirely on the device.
This approach avoids modifying the printer’s firmware or attaching an external computing module. The trade-off is much lower efficiency than native instructions or a dedicated accelerator. Each interpreter instruction must be parsed and dispatched, and floating-point operations may need to be simulated in software, causing execution time to increase substantially.
3.2 Model Quantization
Quantization converts weights from higher-precision floating-point values to lower-bit integers. The approximate storage requirements for weights alone are:
| Data type | Bytes per parameter | Approximate storage for 270 million parameters |
|---|---|---|
| 32-bit floating point | 4 | 1.08 GB |
| 8-bit integer | 1 | 270 MB |
| 4-bit integer | 0.5 | 135 MB |
Even with 4-bit quantization, the complete set of model weights would still exceed 135 MB, far beyond the printer’s available memory. Quantization can reduce storage requirements, but it cannot solve the memory problem by itself. It must be combined with other techniques.
3.3 Dynamic Layer Loading
Dynamic layer loading keeps only one layer’s weights in memory at a time. After the layer finishes processing, its weights are released before the next layer is loaded. As a result, memory contains only the current layer’s weights, input activations, and a small number of temporary variables.
An illustrative implementation is:
def forward_streaming(token_ids, layer_store, embed, head):x = embed(token_ids) # Look up the initial vectorfor i in range(NUM_LAYERS):weights = layer_store.load(i) # Load the weights for layer ix = transformer_block(x, weights) # Run attention and feed-forward computationdel weights # Release the layer weightsreturn head(x) # Compute the probability distribution for the next token
Peak memory is determined mainly by the size of one layer’s weights and the intermediate results, rather than by the total model size. With 8-bit quantization, the average weight size per layer would be approximately 15 MB, calculated as 270 MB divided by 18. This is in the same general range as the reported 14.1 MB peak usage.
This calculation only indicates the order of magnitude. Actual layer sizes depend on the model architecture, and the embedding and output layers may account for significantly more or less than the average.
The cost is frequent data movement. Each layer must be read from external storage and then released, making storage bandwidth and I/O latency new bottlenecks.
4. Performance Bottlenecks
The reported measurements point to three major bottlenecks.
4.1 Computation During Prefill
Prefill processes all input tokens. Its computational cost is approximately proportional to the input length, and every token must pass through all 18 layers. The reported prefill time of about 184 seconds indicates that input processing accounts for most of the total runtime. Applications that use long prompts would experience an even greater increase in this cost.
4.2 I/O Overhead from Layer Switching
Each inference pass requires every layer to be loaded and released. As the number of input tokens increases, the number of layer transitions also increases. Without caching, the weights for the same layer must be read repeatedly.
4.3 Arithmetic Efficiency of the Interpreter
The interpreter executes instructions one at a time and lacks vectorization and parallel processing capabilities. Matrix multiplication is central to Transformer computation, but it is particularly inefficient in an interpreter. This explains why the same mathematical operations can be several orders of magnitude slower on a printer than on a general-purpose processor.
5. The Trade-Off Between Memory and Speed
Inference design in an extreme resource-constrained environment usually requires a balance between memory usage, speed, and accuracy. The following table compares several common strategies:
| Strategy | Memory usage | Inference speed | Main cost |
|---|---|---|---|
| Load the entire model at full precision | High | Fast | Requires a device with substantial memory |
| Load the entire quantized model | Medium | Relatively fast | Some accuracy loss; still requires considerable memory |
| Dynamically load quantized layers | Low | Slow | Frequent I/O and high latency |
| Dynamically load layers with partial caching | Medium-low | Medium | Requires extra memory for cached layers |
The printer experiment selected the approach with the lowest memory usage, making speed the primary cost. If a device has some additional memory available, caching frequently used layers or processing input in batches could improve efficiency.
6. Engineering Lessons for Developers
The experiment offers several lessons for general-purpose inference engineering:
- Estimate the memory budget first. Calculate weight storage by multiplying the parameter count by the number of bytes per parameter, then add activation memory and temporary buffers. If the budget is smaller than the complete model, consider layer streaming or a lower-precision representation.
- Separate the inference stages. Prefill and decoding have different runtime characteristics. For long-input workloads, optimization should focus on prefill, for example by limiting input length or reusing already computed cache data.
- Measure the actual bottleneck. Track computation time, data-loading time, and interpreter overhead separately instead of optimizing based on assumptions.
- Define acceptable accuracy limits. Quantization introduces error, so output quality should be evaluated on samples from the actual task.
- Assess whether the latency is acceptable. A delay of several dozen seconds per token is suitable only for offline or experimental workloads, not interactive applications.
7. Scope and Risks
From an engineering perspective, the main value of this type of experiment is educational and demonstrative. It illustrates the basic components of inference and shows how model architecture, memory layout, and numerical precision interact.
However, it is not suitable for production environments. The speed is far below practical requirements, and the approach depends on the behavior of an interpreter inside a specific device, making compatibility and stability difficult to guarantee. Long-running computation could also increase device wear.
Running workloads on equipment outside its intended purpose may create resource-consumption and security-review concerns as well. In a company or organizational environment, similar experiments should be authorized in advance and checked against the organization’s device-management policies.
Overall, the experiment demonstrates that small-model inference is technically possible under extreme memory constraints. For engineering teams, the more practical approach is to define latency, accuracy, and resource requirements first, then select an appropriate model size, quantization method, and deployment location.
