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
- 8 billion parameters at 16 bits need 16 GB for weights
- 7 billion parameters at 4 bits need 3.5 GB
needed_gbadds the 20 percent overhead- A 30 billion model fits a 24 GB card at 4 bits but not at 8
- 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.