Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-284

Int4 Packing

Problem

Compute the storage bytes of packed int4 values: bits = num_values * 4, bytes = ceil(bits / 8).

The signature is int4_packed_bytes(num_values). Return an integer.

Hint

Packing two int4 values per byte is why 4-bit models shrink 8x versus fp32.

Test cases

case 1
in: [8]
expected: 4
case 2
in: [1]
expected: 1
case 3
in: [7]
expected: 4
case 4
in: [16]
expected: 8
case 5
in: [100]
expected: 50
Starter codePython
def int4_packed_bytes(num_values):
    # Your code here
    pass

5 test cases · run your code against them in the editor