An open, frozen-milestone recreation of Thinking Machines Lab's BBBK (Big Beautiful Blackwell Kernel) 4-bit MoE training and RL megakernel from End-to-End 4-Bit Training, targeting thinkingmachines/Inkling-2-Small (594B total / 17B active, H=4608, I=2304, E=384, top_k=8, 40 NVFP4 layers + 8 MXFP8 layers) on NVIDIA B300 SXM6 AC (sm_103a).
Branches:
mainis focused strictly on the Inkling 2 Small BBBK megakernel. Earlier multi-accelerator work (TPU v6e MoE kernels and standalone B200nvfp4_quantizeexperiments) is preserved on thedevbranch.
T / GPU |
v0_pytorch (BF16) |
v0_unfused_nvfp4 |
v1_umma_stack |
v2_epilogue_stack |
v3_bbbk_fused (1-GPU) |
v4_bbbk_ep8 (8× B300 E2E) |
v5_mxfp8_fwd (L40–47) |
v5_bbbk_bwd (MXFP8 SR) |
|---|---|---|---|---|---|---|---|---|
| 1 | 4,610.4 µs | 1,828.8 µs | 1,046.6 µs | 276.2 µs | 106.5 µs (17.2× / 43.3× pt) |
347.6 µs (1W) | 127.5 µs | 4,781.5 µs |
| 16 | 12,754.4 µs | 1,795.5 µs | 1,071.0 µs | 329.7 µs (5.4×) |
414.6 µs | 400.6 µs (1W) | 361.5 µs | 2,907.7 µs |
| 64 | 14,864.8 µs | 1,841.8 µs | 1,100.9 µs | 352.3 µs (5.2×) |
434.4 µs | 430.5 µs (1W) | 389.6 µs | 2,847.2 µs |
| 256 | 15,252.8 µs | 2,083.6 µs | 1,201.6 µs | 381.4 µs (5.5×) |
443.5 µs | 471.5 µs (1W) | 390.5 µs | 2,902.9 µs |
| 2048 | 16,195.3 µs | 6,562.9 µs | 5,020.3 µs | 669.4 µs (9.8×, 1,559 TF) |
683.0 µs (542.7 µs warm L2) |
1,065.6 µs (2W, 7.84 PF node) |
898.1 µs | 3,919.5 µs |
| 4096 | 16,305.4 µs | 11,764.3 µs | 9,165.4 µs | 926.7 µs (12.7× / 17.6× pt, 2,253 TF) |
947.5 µs (847.9 µs warm L2) |
1,743.6 µs (1W, 9.58 PF node) |
1,520.3 µs | 4,978.8 µs |
quokka/reference/— Exact FP32 PyTorch references:inkling2_moe.py(dual-softcapped SwiGLU,Inkling2TopKRouter, checkpoint NVFP4/MXFP8 codecs, BBBK fwd/bwd),nvfp4.py(fouroversix_mae),mxfp8.py,fixed8.py(S2F6),hadamard.py(32D RHT),requant.py,rounding.py.quokka/cuda/bbbk/— Frozensm_103amilestone kernels (v0_baseline.py,v1_gemm_umma.{cu,py},v2_epilogue_alu.{cu,py},bbbk_fused_epilogue.{cu,py},v3_v4_sched_comms.{cu,py},bbbk_ep8_megakernel.py,v5_mxfp8_bwd.{cu,py}).quokka/cuda/roofline_b300.py— Act 0 NVIDIA B300 roofline calculator (15 PFLOPS NVFP4, 5 PFLOPS MXFP8, 8 TB/s HBM3E, 900 GB/s NVLink 5).quokka/cuda/csrc/— Basenvfp4_quantizeCUDA kernel used byv0_baselineandv2comparisons.bench/bbbk_harness.py— Same-process, rotating-order verification and benchmark harness across all frozen milestones.scripts/modal_b300.py— Zero-waste ModalB300:1/B300:8runner (CPU-onlysm_103acompile + SASS/NCU parsing, 2s scaledown, hard subprocess watchdog).docs/learn/bbbk/— Full lab notebooks,ncusummaries, SASS/register dumps, dead-end post-mortems, and open performance frontiers (start atdocs/learn/bbbk/README.md).
# Local CPU reference tests & B300 roofline ($0 GPU)
uv run pytest -q tests/test_inkling2_moe.py tests/test_nvfp4.py tests/test_mxfp8.py tests/test_fixed8.py tests/test_hadamard.py tests/test_requant.py tests/test_rounding.py
uv run python -m quokka.cuda.roofline_b300
# Modal B300: CPU-only sm_103a SASS/PTX dump ($0 GPU)
uv run modal run scripts/modal_b300.py --cpu --cmd "python scripts/dump_asm.py"
# Modal B300:1 same-process v0 -> v5 progression benchmark
uv run modal run scripts/modal_b300.py --no-build --cmd \
"python bench/bbbk_harness.py --milestones v0_pytorch,v0_unfused_nvfp4,v1_umma_stack,v2_epilogue_stack,v3_bbbk_fused,v5_mxfp8_fwd,v5_bbbk_bwd --tokens 1,16,64,256,2048,4096"Apache-2.0, see LICENSE.