Claude Architect WorkshopPDFEPUBlearnwithparam.comkaas.team

Professional, lesson 5

Model tiering

Choose the tier per step on a golden set

Lumen Supply runs its largest model on every step of its ticket pipeline, because one hard-coded id was copied everywhere. The bill is far above what the work needs, and a step that a small model does as well takes 5.9 seconds on the largest. This lesson measures each step on each tier and gives every step the lowest tier that passes. This is the ticket pipeline at Lumen Supply, an online electronics shop. It has three steps: classify labels a ticket, draft writes the return-window reply, and review finds the defect in a finished reply. You will sweep every step over three tiers, read quality, time and cost together, and write the registry that picks.

I doWatch the failure and its fix.

One pipeline, three steps, three tiers

A tier is a model size: a small one, a middle one and the largest. A bigger tier costs more and takes longer. It does not always answer better, so the right tier depends on the step.

Each step has a golden set of thirty items with known answers, a quality bar and a latency budget. The sweep runs the step on each tier and scores it. The registry holds the bar and the budget, and pick chooses the tier.

Three things go wrong, in this order. One model id is hard-coded in every step, so cost and speed follow the biggest model. No step has a latency budget, so nothing says when a tier is too slow. And the sweep is read as one number for the whole set, so the trade-off inside a step is never seen.

Each step is swept over three tiers. The registry reads quality, time and cost together.Classifylabel a ticketDraftwrite a replyReviewfind the defectThree tiersHaiku, Sonnet, OpusRegistrybar and budgetpick()the lowest passing tierthe amber box holds the bar and the budgetEach step is swept over three tiers. The registry reads quality, time and cost together.Classifylabel a ticketDraftwrite a replyReviewfind the defectThree tiersHaiku, Sonnet, OpusRegistrybar and budgetpick()the lowest passing tierthe amber box holds the bar and the budget

A sweep table for one step

The classify step labels thirty tickets. All three tiers get all thirty right. The small tier takes 3.0 seconds and costs $1.19 for 10,000 tickets. The middle tier takes 2.9 seconds and costs $2.38, and the largest takes 5.9 seconds and costs $4.76.

Open a card to see the calls behind a cell: each keeps its tokens in and out, and its seconds. Cost is those tokens times the tier's price per million tokens, so the small tier's 1,118 in and 493 out come to $1.19 for 10,000 tickets. The prices are this lab's figures from recording day, so check the pricing page.

Each cell is one recorded run of the whole golden set. Its time stands in for the p95 you would read on live traffic, so treat a small gap as noise.

  1. classify30 golden items, bar 90%, latency budget 4.0 s
  2. TierHaiku: 30 of 30 right, 3.7 s, $0.21 for 10,000 tickets, CHOSEN
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 1050,
      "missed": []
    }
  3. TierSonnet: 30 of 30 right, 2.9 s, $2.38 for 10,000 tickets, PASSED
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 500,
      "missed": []
    }
  4. TierOpus: 30 of 30 right, 5.9 s, $4.76 for 10,000 tickets, SLOWER
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 500,
      "missed": []
    }
  5. Registryclassify runs on Haiku

CHOSEN: Haiku on classify, 100% right in 3.7 s.

The pick rule, written as code

pick takes a step and the scores of each tier, and returns the lowest tier that meets the step's quality bar and fits its latency budget. If no tier passes, it returns nothing, so a failing step is seen and not hidden.

registry holds the bar and the budget for each step, and MODELS is the only place a tier becomes a model id. A tier is a cost and speed setting. It is not a guarantee of quality, so the bar decides what is good enough.

starter/tiers.py
1"""EDIT THIS FILE. It has two planted defects.21. pick(): it returns the largest tier whatever the scores say.32. registry(): no step has a latency budget, so no tier is ever too slow.45Run `./workshop check model-tiering` until it is green, then6`./workshop watch model-tiering`.7"""89from kit.api import Json10from kit.models import TIERS1112MODELS = dict(TIERS)13ORDER = ["haiku", "sonnet", "opus"]141516def registry() -> Json:17 """The quality bar and latency budget of each step.18 `bar` is the share of the golden set a tier must get right, and19 `budget` the most seconds one run may take.20 """21 return {22 "classify": {"bar": 0.9, "budget": None},23 "draft": {"bar": 1.0, "budget": None},24 "review": {"bar": 0.95, "budget": None},25 }262728def pick(step: str, scores: Json) -> str | None:29 """Return the tier a step should run on.30 `scores` maps each tier to its `quality` and `seconds` on the golden set.31 """32 return ORDER[-1]

Does the largest model win every step?

The largest model is the most capable one in the family. It seems the safe choice for every step of the pipeline.

Predict: Does the largest model win every step?

  1. ANo. It wins few steps and costs the most.
  2. BYes. It is the most capable.
Show the answer

A. The lowest tier that passes the bar is the right one. The largest is chosen only where nothing smaller passes.

The largest model on every step

This is a real run on Claude Haiku 5.5 and two larger tiers, recorded once and replayed here. The largest tier gets all thirty classify tickets right in 5.9 seconds for $4.76. The small tier gets the same thirty right in 3.0 seconds for $1.19.

The starting pick returns the largest tier whatever the scores, and no step has a budget. Across the three steps that is $32.00 for 10,000 tickets. Nothing in the code says that classify is over time, because nothing gives it a limit.

  1. classify30 golden items, bar 90%, no latency budget
  2. TierHaiku: 30 of 30 right, 3.7 s, $0.21 for 10,000 tickets, PASSED
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 1050,
      "missed": []
    }
  3. TierSonnet: 30 of 30 right, 2.9 s, $2.38 for 10,000 tickets, PASSED
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 500,
      "missed": []
    }
  4. TierOpus: 30 of 30 right, 5.9 s, $4.76 for 10,000 tickets, OVERSPENT
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 500,
      "missed": []
    }
  5. Registryclassify runs on Opus

OVERSPENT: Opus on classify, 100% right in 5.9 s.

A registry and a pick per step

registry now gives every step a bar and a latency budget. Classify needs 90% inside 4 seconds. Draft needs every item right inside 12 seconds, because the customer reads it. Review needs 95% inside 10. pick walks the tiers from the smallest and stops at the first that passes both.

The same sweep now chooses the small tier for classify, the middle tier for draft and the middle tier for review. Across the three steps the bill is $15.48 for 10,000 tickets, against $32.00. The id lives in one file, so a new model is one line in MODELS and a new sweep.

Cost is tokens times price. The draft step writes the most, about 2,100 tokens for thirty replies on the middle tier, so it is the largest line in the bill. A saving on a step is worth most where the step writes the most.

How one step is judged, in order.Golden setTierScoreRegistry30 classify itemsanswersquality, seconds, costlowest passing tier
tiers.pygreen lines are what the fix adds
1"""The solution: a budget for every step, and the lowest passing tier."""23from kit.api import Json4from kit.models import TIERS56MODELS = dict(TIERS)7ORDER = ["haiku", "sonnet", "opus"]8910def registry() -> Json:11 """The quality bar and latency budget of each step.12 `bar` is the share of the golden set a tier must get right, and13 `budget` the most seconds one run may take.14 """15 return {16 "classify": {"bar": 0.9, "budget": 4.0},17 "draft": {"bar": 1.0, "budget": 12.0},18 "review": {"bar": 0.95, "budget": 10.0},19 }202122def pick(step: str, scores: Json) -> str | None:23 """Return the lowest tier that passes the bar within the budget.24 `scores` maps each tier to its `quality` and `seconds` on the golden set.25 Returns None when no tier passes, so a failing step is seen, not hidden.26 """27 rule = registry()[step]2829 for tier in ORDER:30 got = scores[tier]31 if got["quality"] >= rule["bar"] and got["seconds"] <= rule["budget"]:32 return tier3334 return None
We doChange one setting at a time and predict.

The same input now ends well

Switch between the two registries with the same step. The three tiers score the same in both runs. The card marked "This is where the runs split" is the registry's choice: the largest tier without the fix, the small tier with it.

The data did not change. The registry did. With a budget of 4 seconds, the largest tier is too slow for classify, and with a bar of 90% the small tier is good enough.

This part is interactive in the lab: run ./workshop watch model-tiering.

Try it: tier and step

Change one setting at a time. Every combination is a recorded run, so this works with no internet.

Draft needs the middle tier. The small tier gets 29 of 30 replies right, and the bar is every one. It said an SSD return window was open when its last day had passed. Review needs the middle tier too, because the small tier finds 27 of 30 defects against a bar of 95%.

In this recording no step needs the largest tier. It passes where the middle tier passes, and it is slower and dearer. A harder review set could change that, so the sweep runs again when the work changes.

This part is interactive in the lab: run ./workshop watch model-tiering.

The sweep as a table

In the starting registry every budget is None. The fix sets 4, 12 and 10 seconds.

Read the table across a row, never down a column. The small tier is the cheapest on every step, and it passes only on classify. The middle tier passes on all three and is chosen for two. The largest passes on all three too, and is over budget on every one.

Quality, time and cost are three columns, and no one decides. Set the budget on p95, since a few slow calls vanish in a mean: 1.6 seconds can sit beside a p95 of 3.4. Extended thinking adds time and is not a tier.

  1. classify30 golden items, bar 90%, latency budget 4.0 s
  2. TierHaiku: 30 of 30 right, 3.7 s, $0.21 for 10,000 tickets, CHOSEN
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 1050,
      "missed": []
    }
  3. TierSonnet: 30 of 30 right, 2.9 s, $2.38 for 10,000 tickets, PASSED
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 500,
      "missed": []
    }
  4. TierOpus: 30 of 30 right, 5.9 s, $4.76 for 10,000 tickets, SLOWER
    Show the result
    {
      "tokens in": 1072,
      "tokens out": 500,
      "missed": []
    }
  5. Registryclassify runs on Haiku

CHOSEN: Haiku on classify, 100% right in 3.7 s.

You doFix the starting code, then test yourself.

You do: pick the lowest tier that passes

Copy the starting code and open work/model-tiering/tiers.py. pick() returns the largest tier whatever the scores say, and registry() gives no step a latency budget.

Terminal
./workshop start model-tiering
./workshop check model-tiering
./workshop watch model-tiering

The checks want a budget on every step and the lowest tier that meets both the bar and the budget. When no tier passes, pick() returns None.

Check your understanding

Answer each question, then read why every option is right or wrong. The wrong options are the mistakes engineers make on the job.

1. Lumen's ticket pipeline has three steps, classify, draft and review, and every one calls the same largest model id, copied from the first prototype. The monthly bill is far above plan, and the classify step takes 4 seconds against a 1 second budget. A golden set of 30 items exists for each step. What should the team change first?

  1. AMove all three steps to the smallest tier, because the bill is the loudest problem and one cheap model is simpler.
  2. BKeep the largest tier on every step and ask for a bigger budget, since it is the choice nobody can fault.
  3. CRun each step on each tier against its golden set, then give every step the lowest tier that passes.
  4. DScore the whole pipeline once on the combined sets and keep whichever single model has the best total.
Show the answer

Answer: C

  • A One small model may fail the draft or review step. The fix is a choice per step, and a smaller tier is right only where its score passes the bar.
  • B The largest tier is not the safest choice. It is the slowest and the dearest, and here it breaks the classify budget.
  • C Correct. A sweep of tier by step shows where a small tier passes and where it does not. Each step then gets the cheapest tier that is good enough and fast enough.
  • D One total hides the step where a tier fails. A tier that is excellent on classify can still be wrong on review.

2. On the classify golden set of 30 tickets, the smallest tier gets 96% right in 0.8 seconds. The middle tier gets 96% in 2, and the largest gets 97% in 4. The bar is 90% and the budget is 1 second. Which tier should the classify step use, and why?

  1. AThe smallest tier, because it passes the bar inside the budget at the lowest cost, and the extra point is not needed.
  2. BThe largest tier, because one more point of accuracy is worth paying for on every ticket that comes in.
  3. CThe middle tier, because it sits between the other two and so balances accuracy against cost and speed.
  4. DThe largest tier, with a cache added to bring its 4 seconds down to the 1 second budget for repeats.
Show the answer

Answer: A

  • A Correct. The bar is 90%, and 96% clears it. The smallest tier also fits the budget, so it is the lowest tier that passes.
  • B The bar is 90%, so the extra point buys nothing the step needs, and the largest tier misses the 1 second budget.
  • C The middle tier scores the same 96% but takes 2 seconds, over the budget. Sitting between two tiers is not a reason.
  • D A cache changes what repeated calls cost, not how long a first call takes. The tier is the lever here.

3. The draft step writes the return-window reply a customer reads, so its bar is 100% on a golden set of 30 orders. The smallest tier gets 29 of 30 right in 7 seconds. The middle tier gets 30 of 30 in 10.8 and the largest gets 30 of 30 in 14.8, against a 12 second budget. Which tier should the draft step use?

  1. AThe largest tier, because the draft is customer facing and so the strongest model is the safe one.
  2. BThe smallest tier, after lowering the bar to 95% so that its 29 of 30 passes and the cost stays low.
  3. CThe smallest tier, with its thinking effort turned up until it reaches 30 of 30 on the golden set.
  4. DThe middle tier, the lowest tier that passes the bar and fits the budget.
Show the answer

Answer: D

  • A The largest tier also passes, but it takes 14.8 seconds against a 12 second budget. Safe does not mean over budget.
  • B A bar moved after the result is no bar. The reply is customer facing, so the 100% was set for a reason.
  • C Effort is a separate lever and it adds time. It does not turn a smaller tier into a larger one, and it was not measured.
  • D Correct. Move up one tier only as far as the bar needs. The largest is slower and dearer.

4. A review board asks what evidence supports the tier chosen for the review step before it goes live. The step must find the defect in a finished reply, with a stated bar and latency budget, and the board meets once. Which inputs should the team show it? Select two.

  1. AEach tier's score on the step's golden set, read against the bar.
  2. BThe order of the three tiers in the vendor's lineup, from the largest down, with each tier's list price.
  3. CThe time each tier took on the step, read against the latency budget.
  4. DOne accuracy average over classify, draft and review for each tier, shown in a single chart.
Show the answer

Answer: A, C

  • A Correct. A score on this step's own golden set is the evidence that the tier is good enough for the work.
  • B The lineup says which tier is larger, not whether it is needed. It is a reason to buy the most, not a measurement.
  • C Correct. A tier that passes the bar but misses the budget is still the wrong tier, so the time is half the evidence.
  • D An average over three steps hides the step where a tier fails, so it cannot support a choice for one step.

5. The draft step meets its accuracy bar on its golden set, but its p95 latency is 3.4 seconds and the SLA allows 2 seconds. Its mean latency is 1.6 seconds, and the SLA is a fixed term of the contract. The team owns the step's tier and its prompt, and the next review is in two weeks. What should the team do?

  1. AAccept it, because the mean is under 2 seconds and the accuracy bar is met, so the step is within the contract.
  2. BChange the tier or the step's design, such as a shorter output, then measure p95 again against the 2 seconds.
  3. CMove the step to the largest tier, since better answers will make the calls faster and bring the p95 down.
  4. DRetry every call that runs past 2 seconds, so that the slow calls are replaced by quick ones.
Show the answer

Answer: B

  • A The SLA is about the tail. A mean of 1.6 seconds can hold one call in twenty at 3.4, and those are the customers who wait.
  • B Correct. The tail is what is over, so change the lever that sets it, and then re-measure p95.
  • C A larger tier is usually slower, not faster, so this would widen the gap to the SLA.
  • D A retry waits out the slow call and then makes another, so a customer's wait grows. It does not fix what made the call slow.

6. A pipeline step runs on a middle tier with a mean latency of 2.1 seconds and a p95 of 3.0 seconds at normal traffic. When traffic doubles, the mean stays at 2.1 seconds but the p95 rises to 5.5 seconds. The SLA is a p95 of 4 seconds, and the cost per ticket has not changed. What does the team conclude?

  1. AThe step is healthy, because the mean did not move and the bill per ticket is the same as before.
  2. BThe tier is too small for the load, so move the step to the largest tier to absorb the traffic.
  3. CThe mean was the wrong number to watch, so set the budget on p95 and find what slows the slowest calls.
  4. DTreat the rise as a cost problem, since slower calls mean that the step is using more tokens.
Show the answer

Answer: C

  • A A flat mean can sit beside a long tail. The p95 passed the 4 second SLA while the mean looked fine.
  • B A larger tier is slower per call, so it would not absorb the load and may push the p95 further past the SLA.
  • C Correct. Tune for the tail. Budget on p95, then look at what the slowest calls share, such as queueing.
  • D Latency and cost are different measures. A slow call is not a dear one, and the bill said nothing about the tail.

7. A review step runs on the middle tier and takes 11 seconds against a 10 second budget. Its golden set score is well above the bar, and the team may not move to a bigger tier because the bill is already at its cap. Which levers cut the latency without a bigger model? Select two.

  1. ATurn on extended thinking so that the model works out a shorter answer before it writes.
  2. BTry the smaller tier on the golden set, and use it if it still passes the bar.
  3. CCopy a faster model's id into this step's code and leave the other steps as they are.
  4. DAsk for less output, such as a one word label instead of an explanation.
Show the answer

Answer: B, D

  • A Extended thinking adds reasoning, so the call takes longer. It is a separate lever from the tier and it does not shorten the answer.
  • B Correct. A smaller tier is faster, and the sweep tells you whether it still clears the bar before you switch.
  • C A hard-coded id skips the sweep, so nobody knows if that model passes. The id belongs in the registry, chosen by the pick.
  • D Correct. Output tokens are generated one after another, so a shorter answer is a faster one at any tier.

8. On the draft step the larger tier gets 100% right in 14.8 seconds, and the smaller tier gets 97% right in 7 seconds. The sponsor asks for full accuracy and a 10 second answer, and no tier gives both on the golden set. The launch is in a week. How should the team respond?

  1. AChoose the largest tier and ship with a note that latency will be tuned after launch, since accuracy matters most.
  2. BState the trade-off with the numbers for each tier, and ask the owner to choose which to give up.
  3. CChoose the smaller tier and retry any answer it gets wrong, so that accuracy reaches 100% inside 10 seconds.
  4. DCombine accuracy and latency into one score and ship the tier with the higher number.
Show the answer

Answer: B

  • A The largest tier takes 14.8 seconds, so the 10 second goal is missed at launch. A note to tune it later is a promise the data does not support.
  • B Correct. When the goals conflict, put both numbers side by side and let the owner choose, so the trade is made in the open.
  • C A retry adds a second call to the wait, so the answer takes longer than 7 seconds. It also does not say which answers were wrong.
  • D A blended score hides which goal was given up, and the weights decide the answer. The owner should make that call openly.

Play: predict the output

This pick reads the tiers in the order the sweep file lists them.

python
def pick(step: str, scores: Json) -> str | None:
    rule = registry()[step]
    for tier, got in scores.items():
        if got["quality"] >= rule["bar"] and got["seconds"] <= rule["budget"]:
            return tier
    return None

Predict: The sweep file lists opus first, and all three tiers pass classify. Which tier is picked?

  1. AOpus, because it is the first passing tier in the file.
  2. BHaiku, because it is the cheapest tier that passes.
Show the answer

A. A dict keeps the order its data arrived in, and that order is not cost. Walk a fixed list from cheapest to largest, so the file cannot change the pick.

References

Conclusions

  • Choose the tier for each step, from a sweep of tier by step on a golden set.
  • Give every step a quality bar and a latency budget, and pick the lowest tier that meets both.
  • Read quality, time and cost together, and keep the model id in one place.

You can now sweep a pipeline over tiers, write a registry with a bar and a budget for each step, and pick the lowest passing tier.

Tier

A model size, which sets cost and speed but does not guarantee quality

Golden set

A fixed set of items with known answers, used to score a step

Quality bar

The share of the golden set a tier must get right for a step

Latency budget

The most seconds a step may take, set by the owner

Registry

The one place that holds each step's bar, budget and model ids

p95

The time that 95 of every 100 calls meet or beat