11/30
Part 3 of 7 · The batch tradeLearn

A per-token target caps the batch, unless memory caps it first

Say the shop promises answers at 15 ms a token or faster, about 67 tokens a second. That's a per-token target, and it's the step time.

largest_batch tries each batch from 1 up to the number that fit in memory, and keeps the biggest whose step meets the target, or 0 when none does.

# 2,000 tokens a conversation, and 477 of them fit
print([largest_batch(QWEN, H100, 2000, target, 477) for target in (15, 30, 4)])
Predict

Which batch sizes come back for targets of 15 ms, 30 ms and 4 ms?

Pick one to see what it prints.
Pick an answer above to see the rest