ALL INTELLIGENCE
Hacker News AIT2·Infra

Running Qwen Inference on AWS Lambda Costs 80x More

Original title: Serving Qwen via AWS Lambdas for fun and 80x negative profit
58AI Score

The author split the Qwen3.5-4B fine-tune H2O-Lightning layer by layer across AWS Lambda functions to test whether GPU-free parallel inference could work. The answer is no: a single layer over thousands of tokens is a large matrix multiply that CPUs handle poorly, and the resulting cost was roughly 80x higher with no arbitrage. A useful negative engineering result that maps the limits of serverless CPU for LLM inference.

Full Report

Contents7 sections

Who needs a GPU?

In my work at Bevyl 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.

So 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!

I picked H2O-Lightning, 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.

Fanning out

So the trick, if it's possible, would be fanning out. I was inspired how Remotion uses massively parallelized Lambdas to render videos.

I 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.

Think of the Lambda as a simple idempotent API. A job reads inputs from S3, does the math, and writes one object back.

PYTHON
x = load(f"{doc}/{layer - 1}/{block}")
memory = load(f"{doc}/{layer}/{block - 1}")

y, memory = model.layers[layer](x), memory

s3.put_object(
    Key=f"{doc}/{layer}/{block}",
    Body=pack(y, memory),
)

Each 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.

92% of the work parallelizes, 8% is serialParallel but not.

I'm proud of the win: splitting a model call across 5,600 Lambdas is kinda wild.

One request, 32 layers, 5,600 Lambda invocationsLambda job that has to run in orderLambda job that can run any timePoint at a job to follow its block.Win: the math worked; I had split a model call into 5,600 Lambda invocations. Fail: 17 seconds to read ~4k tokens.

The bill

If it was 40x slower but 50% cheaper, that'd be interesting.

Reading 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, for $0.10 per million tokens, so the same read costs 0.04 cents there. Mine is more than 80 times more expensive.

More than 80 times the price of a hosted decision model

Takeaways

Model engineering is not so hard in 2026!

I'm a dumb application developer, 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.

I need a GPU

Learned 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.

Freedom ain't free

CPU still costs dollars, there's no arbitrage here.