Can a language model run on AWS Lambda functions?
A developer at Bevyl set out to see whether a self-hosted language model could run on AWS Lambda functions instead of GPUs. The answer was yes, technically. Economically, it was a disaster. Reading a single 4,000-token document cost more than 80 times what a hosted alternative charges for the same job.
The idea grew out of the author's work at Bevyl, where he had been impressed by the performance and cost of Lambda functions. They can fan out CPU-bound work across many invocations at once, which suits jobs like running ffmpeg on long videos. He also pointed to Remotion, which uses massively parallel Lambdas to render videos, as an inspiration. He wondered whether the same fan-out pattern could handle inference.
He chose H2O-Lightning, a fine-tune of Qwen3.5-4B, because it was small and built for decisions. A decision model reads a document, answers a question about it and picks one option. That means a single forward pass through the network, which made it a reasonable candidate for the experiment.
The first obstacle was memory. Lambda functions were capped at 3 GB for the test, and the full model weighs 9.3 GB, so it would not fit in one function. The model does have 32 layers of about 225 MB each, however, and a single layer fits. That allowed him to assign one Lambda job to each layer for each block of tokens.
Each job is designed as a simple, idempotent API call. It reads its inputs from Amazon S3, runs the math for its layer and writes one object back. A job for a given layer and block must wait for the layer below it to finish the same block, and it also depends on its own previous block. The result is a staircase of work, with each layer starting one step after the one beneath it. Across 32 layers and the token blocks in a request, that came to 5,600 Lambda invocations for one model call.
The approach was not fully parallel. By the author's estimate, about 92 percent of the work could run in parallel, while roughly 8 percent had to run in strict order. That serial portion limited how much the fan-out could speed things up.
How much does it cost to run a model on AWS Lambda?
The results were slow and expensive. Reading a 4,000-token document took 17 seconds and cost 3.4 cents, which works out to about $8.40 per million tokens. Google sells a hosted decision model, Gemini Decision 1, for $0.10 per million tokens. By the author's math, the same read would cost 0.04 cents on that service, making his version more than 80 times more expensive. He had hoped for a tradeoff. He wrote that a version 40 times slower but 50 percent cheaper would have been interesting.
The project did produce some lessons. The author, who describes himself as an application developer rather than a machine learning specialist, said he was able to work with model layers and the transformers API without much difficulty. In his view, open models are starting to feel like any other API.
Why are GPUs better than CPUs for running language models?
The hardware lesson was clearer. Running one layer over a few thousand tokens amounts to a large matrix multiplication, which is exactly the kind of work GPUs are built to handle. CPUs, even in massive numbers, cannot match that efficiency. The author said his goal was to learn, and he considered the experiment worthwhile for that reason. He also made clear that the approach offers no shortcut. CPU time still costs money, and there is no cost arbitrage to be found in running inference this way.
Este artículo fue escrito con la asistencia de IA.
News Factory APP - noticias agénticas para impulsar tu SEO y AEO.
