Skip to content

feat: implement vectorized integer bit-packing and 2:4 sparsity runtimes - #2

Merged
Prajwal7-2002 merged 1 commit into
mainfrom
feature/bit-packing-runtimes
Oct 26, 2026
Merged

Prajwal7-2002 merged 1 commit into
mainfrom
feature/bit-packing-runtimes

Conversation

@Prajwal7-2002

Copy link
Copy Markdown
Owner

Summary

Implements Phase 2 of quantbench: high-performance, vectorized sub-byte bit-packing runtimes in pure Python and PyTorch.

Key Additions

  1. INT4 Bit-Packing Runtime (quantbench.quant.packing.int4_pack):
    • Packs pairs of 4-bit integers (unsigned [0, 15] or signed two's complement [-8, 7]) into single \uint8\ byte containers: \�yte = (v0 & 0x0F) | ((v1 & 0x0F) << 4).
    • Vectorized unpacking with sign-extension arithmetic.
    • Dynamic shape padding for tensors with odd dimensions.
  2. BitNet 1.58b Ternary Packing (quantbench.quant.packing.ternary_pack):
    • 2-bit SIMD packing: 4 ternary weights per byte using offset binary mapping \u = v + 1 \in {0, 1, 2}\ (8x compression over FP16).
    • Radix-3 Base-3 packing: 5 ternary weights per byte (\3^5 = 243 < 256), achieving maximum information-theoretic density.
  3. 2:4 Structured Sparsity Metadata (quantbench.quant.packing.sparse_pack):
    • NVIDIA Ampere/Ada/Hopper sparse tensor core layout.
    • Row-wise magnitude pruning, value condensation to 50% storage (M, N/2), and 2-bit column metadata index packing into 4-bit nibbles (M, N/8).
    • Lossless decompress scatter restoring exact tensor sparsity.
  4. CLI Pack-Inspect:
    • \quantbench pack-inspect --format int4|ternary|sparse24\ for terminal bit layout visualization.
  5. Quality & Validation:
    • 22/22 unit tests passing in 2.18s with 93% test coverage.
    • All Ruff lint and formatting checks passing.

Add sub-byte packing runtimes for INT4, BitNet 1.58b ternary, and 2:4 structured sparsity with exhaustive test coverage and CLI inspection.
@Prajwal7-2002
Prajwal7-2002 merged commit cc98313 into main Oct 26, 2026
7 checks passed
@Prajwal7-2002
Prajwal7-2002 deleted the feature/bit-packing-runtimes branch October 26, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant