{"slug": "serving-qwen-via-aws-lambdas-for-fun-and-80x-negative-profit", "title": "Serving Qwen via AWS Lambdas for fun and 80x negative profit", "summary": "A developer at Bevyl split inference of H2O-Lightning, a fine-tune of Qwen3.5-4B, across 5,600 AWS Lambda jobs to run one 32-layer model without a GPU, and the experiment cost $8.40 per million tokens — more than 80 times Google's $0.10 per million token price for its hosted Gemini Decision 1 model. Reading a 4,000-token document took 17 seconds and cost 3.4 cents on the Lambda setup, versus 0.04 cents on Gemini Decision 1, because each layer's 225 MB of the 9.3 GB model had to be loaded from S3 under a 3 GB per-Lambda memory limit. The author concluded that a single layer over a few thousand tokens is a large matrix multiply better suited to a GPU, and that \"CPU still costs dollars, there's no arbitrage here.", "body_md": "[← Writing](https://noahbuilt.it/writing)\n\n# Serving Qwen via 5,600 Lambdas for fun and 80x negative profit\n\n## Who needs a GPU?\n\nIn my work at [Bevyl](https://www.bevyl.ai) I was really impressed by the performance and cost characteristics of AWS Lambdas. They can massively distribute and fan out CPU-bound work, which is amazing for things like ffmpeg on long videos.\n\nSo I was curious if it was possible to run inference on self-hosted models using Lambdas. It was a random idea built on a hunch, and I like to prove such ideas right or wrong by building. In this case I was very wrong, but it was a good lesson!\n\nI picked [H2O-Lightning](https://huggingface.co/h2oai/h2o-lightning-4b), a fine-tune of Qwen3.5-4B, because I wanted a small model built for decisions. I figured if this architecture had any legs, only doing decision models (a single forward pass) is the move. A decision model reads a document and answers a question about it by picking one option.\n\n## Fanning out\n\nSo the trick, if it's possible, would be fanning out. I was inspired how Remotion uses massively parallelized Lambdas to render videos.\n\nI wanted to prove this was possible to do, so I kept a constraint of a 3 GB limit for Lambdas. The whole model is 9.3 GB, so it does not fit in one. But it has 32 layers of about 225 MB each, and one layer fits. That gave me one Lambda job per layer per block of tokens.\n\nThink of the Lambda as a simple idempotent API. A job reads inputs from S3, does the math, and writes one object back.\n\n```\nx = load(f\"{doc}/{layer - 1}/{block}\")\nmemory = load(f\"{doc}/{layer}/{block - 1}\")\n\ny, memory = model.layers[layer](x, memory)\n\ns3.put_object(\n    Key=f\"{doc}/{layer}/{block}\",\n    Body=pack(y, memory),\n)\n```\n\nEach job waits on the layer above for the same block and on its own previous block. Each layer starts one step after the layer above it, like a staircase 32 layers deep.\n\nI'm proud of the win: splitting a model call across 5,600 Lambdas is kinda wild.\n\n## The bill\n\nIf it was 40x slower but 50% cheaper, that'd be interesting.\n\nReading a 4,000-token document takes 17 seconds and costs 3.4 cents. That works out to $8.40 per million tokens. Google sells a hosted decision model, [Gemini Decision 1](https://ai.google.dev/gemini-api/docs/pricing), for $0.10 per million tokens, so the same read costs 0.04 cents there. Mine is more than 80 times more expensive.\n\n## Takeaways\n\n### Model engineering is not so hard in 2026!\n\nI'm a [dumb application developer](https://noahbuilt.it), but I was able to play with model layers and transformers API pretty easily! With good devex, it feels like open models are just another API at this point.\n\n### I need a GPU\n\nLearned this the hard way but a very powerful lesson! One layer over a few thousand tokens is a big matrix multiply, which is what GPUs are built for. My goal was to learn anyway so it's a good lesson.\n\n### Freedom ain't free\n\nCPU still costs dollars, there's no arbitrage here.", "url": "https://wpnews.pro/news/serving-qwen-via-aws-lambdas-for-fun-and-80x-negative-profit", "canonical_source": "https://noahbuilt.it/writing/qwen-on-5600-lambdas", "published_at": "2026-11-25 03:28:06+00:00", "updated_at": "2026-11-25 03:44:09.688620+00:00", "lang": "en", "topics": ["ai-infrastructure", "large-language-models", "ai-tools"], "entities": ["AWS Lambda", "H2O-Lightning", "Qwen3.5-4B", "Bevyl", "Google", "Gemini Decision 1", "Amazon S3"], "also_reported_by": [], "takeaway": "Fanning a 32-layer Qwen3.5-4B fine-tune across 5,600 AWS Lambdas cost $8.40 per million tokens and 17 seconds per 4,000-token document, over 80x Google's $0.10 per million tokens for Gemini Decision 1, because each 225 MB layer had to be shuttled through S3.", "recommendation": {"advice": "Keep transformer inference on GPUs: splitting layers across CPU Lambdas cost $8.40 per million tokens versus $0.10 hosted, since each layer is a large matrix multiply and S3 round-trips dominate.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/serving-qwen-via-aws-lambdas-for-fun-and-80x-negative-profit", "markdown": "https://wpnews.pro/news/serving-qwen-via-aws-lambdas-for-fun-and-80x-negative-profit.md", "text": "https://wpnews.pro/news/serving-qwen-via-aws-lambdas-for-fun-and-80x-negative-profit.txt", "jsonld": "https://wpnews.pro/news/serving-qwen-via-aws-lambdas-for-fun-and-80x-negative-profit.jsonld"}}