Command Palette

Search for a command to run...

Hectal
Phase 13: Choosing and Adapting Models
LLM Engineering · Exercise 2 of 6 PreviousNext
Intermediate

Will the weights fit on the card?

Write weights_gb(params_billion, bits) returning the gigabytes needed for the weights: billions of parameters times bits divided by 8.

Write needed_gb(params_billion, bits, overhead=1.2) returning the weights times the overhead factor.

Write fits(params_billion, bits, gpu_gb, overhead=1.2) returning True when needed_gb is at most gpu_gb.

What Check tests

  1. 8 billion parameters at 16 bits need 16 GB for weights
  2. 7 billion parameters at 4 bits need 3.5 GB
  3. needed_gb adds the 20 percent overhead
  4. A 30 billion model fits a 24 GB card at 4 bits but not at 8
  5. The overhead argument is respected

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.