Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

LLM Cost Engineering

Free · sign in to start and track progress

1 · Spending less on the same work

  • 1Token economics of an agent fleet
  • 2Prompt caching as system design
  • 3Trimming and compacting context
  • 4Batch, flex and fast tiers

2 · Changing the model, and governing the spend

  • 5Cost-quality curves, routing and cascades
  • 6Distilling into small models
  • 7Self-hosting break-even

    Exercise answers

    • Answer: Build a serving cost calculator
    • Answer: Benchmark an engine yourself
  • 8Attribution, budgets and alerts
CapstoneCost-engineer an agent pipelineReference implementation

Module 2 · Changing the model, and governing the spend · Lesson 7

Self-hosting break-even

Turning GPU hourly rates and measured throughput into a cost per million tokens, comparing it with serverless and batch prices for the same open-weight model, and finding the utilisation and volume at which running vLLM or SGLang yourself pays.

75 min 1 video 3 exercises 6-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvRun GPU code on ModalServe a model with vLLM

By the end of this lesson you can

  • Compute self-hosted cost per million tokens from GPU price, measured throughput and utilisation
  • Explain how interactivity (tokens per second per user), sequence shape and engine features change throughput and therefore cost
  • Find the break-even utilisation and monthly volume against serverless, cached and batch prices, including operations cost
  • Benchmark an engine with vllm bench serve and decide between serverless, scale-to-zero GPUs and dedicated GPUs for a workload

On this page

  • Intuition: renting a van versus paying per parcel
  • The mechanism: from dollars per hour to dollars per token
  • A measured anchor
  • Comparing with serverless and batch
  • A worked example: the platform's open-model traffic
  • When self-hosting does win
  • Engines and what they buy you
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Intuition: renting a van versus paying per parcel
  2. 02The mechanism: from dollars per hour to dollars per token
  3. 03Comparing with serverless and batch
  4. 04A worked example: the platform's open-model traffic
  5. 05Engines and what they buy you
  6. 06Misconceptions and limits
  7. 07Connections
  8. 08Summary

Sources & further reading

  • Efficient Memory Management for Large Language Model Serving with PagedAttentionPaper · Kwon et al. · UC Berkeley · 2023SOSP 2023. The vLLM paper. Sections 2 and 6 show why throughput, and therefore cost per token, depends on how many requests fit in KV-cache memory at once.
  • SGLang: Efficient Execution of Structured Language Model ProgramsPaper · Zheng et al. · 2023NeurIPS 2024. RadixAttention prefix sharing and cache-aware scheduling, the main alternative engine to vLLM; read section 4 on prefix reuse across agent calls.
  • Mélange: Cost Efficient Large Language Model Serving by Exploiting GPU HeterogeneityPaper · Griggs, Liu, Yu, Kim, Chiang, Cheung, Stoica · 2024Shows that the cheapest GPU type depends on request size, rate and latency target, and that mixing GPU types cut deployment cost by up to 77% in conversational settings and 33% for document workloads.
  • Modal pricingDocs · ModalPer-second GPU prices (H100, H200, B200 and others) for serverless containers that scale to zero, plus region and non-preemptible multipliers.
  • Benchmark CLI (vLLM docs)Docs · vLLMvllm bench serve with random or real datasets, request rate and concurrency controls, reporting output and total token throughput, TTFT and time per output token.
  • gpt-oss 120B on H100 (InferenceX)Article · SemiAnalysis · 2026Measured vLLM throughput per H100 at several interactivity levels for an 8K-input, 1K-output workload, with cost per million tokens at stated GPU prices. The throughput anchor for this lesson's worked example.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 8 more sections
  • 3 hands-on exercises
  • A 6-question quiz
  • Progress, quiz scores and bookmarks