All problems
QLoRA Memory
Problem
Estimate QLoRA weight memory in bytes: base parameters stored at base_bits plus LoRA adapters stored at lora_bytes, converted with / 8: (base_params * base_bits + lora_params * 8 * lora_bytes) / 8.
The signature is qlora_memory(base_params, lora_params, base_bits=4, lora_bytes=4). Return a float number of bytes.
Hint
4-bit base weights plus fp32 adapters gives large savings with almost no quality loss.
Test cases
case 1
in: [8000000,160000,4,4]
expected: 4640000
case 2
in: [1000000,0,4,4]
expected: 500000
case 3
in: [1000000,1000000,4,4]
expected: 4500000
case 4
in: [1000,1000,2,2]
expected: 2250
Starter codePython
def qlora_memory(base_params, lora_params, base_bits=4, lora_bytes=4):
# Your code here
pass4 test cases · run your code against them in the editor