Goal
Support BitNet b1.58 models (e.g. microsoft/bitnet-b1.58-2B-4T) end-to-end, including NeoGPU's fused 4-plane lm_head optimization — the application-layer half of SKaiNET-developers/SKaiNET#1136 (vendored NeoGPU ternary LUT kernel; upstream agreement in anjaustin/neogpu#1).
This is also an architecture validation (see the proof points in SKaiNET-developers/SKaiNET#1136): a whole new model class with an exotic lm_head format should require no changes to this repo's network DSL, fusion machinery, or runtimes — only a ModelFamily, a network def built from stock layers, a declarative WeightForm request, and sampling-level code.
Per SKaiNET physiology, the fast lm_head is format-driven, not op-driven: formats, codecs and kernel packs (incl. BITNET_PLANES, SKaiNET#1150) live in the engine, dispatch picks the fused kernel from the weight's encoding, and the DSL/DAG keep a plain dense/matmul. This repo owns only the model-level parts: choosing that format for output.weight at load, and the two-stage sampling.
Dependency
This repo consumes SKaiNET via the Maven BOM (sk.ainet:skainet-bom) — work here needs a SKaiNET release containing:
- the
BITNET_B1_58 keep-packed GGUF loader + TernaryF32KernelPack (SKaiNET#1137–#1140)
- the
BITNET_PLANES encoding + lmhead_stage1 kernel pack (SKaiNET#1150; symbol exported in SKaiNET#1137) — this repo has no native build of its own
Why the fused lm_head
Upstream NeoGPU measured on Pi-4/Cortex-A72: full-vocab lm_head in 96 ms / 6.78 GOPS (4-thread, fused 4-plane LUT) vs 51 ms / 3.20 GOPS int8 with ~1.5% quant error. The weight format is 4 ternary planes with weights {1, ⅓, ⅑, 1/27} + per-row FP16 scale — effectively "8 bits as four ternary digits" (planes 4–7 exist too, used only for candidate rescoring).
Sub-issues
Follow-up candidate: forwardBatched computes the full-vocab projection for every prefill position then narrows to the last row — last-row-only lm_head is an easy independent win.
Verification
- Fused vs unfused logits parity on a real BitNet GGUF
- Decode via
skainet-cli producing coherent text at BitNet-2B4T dims (H=2560, F=6912, vocab≈128k)
- Reference target: ~1 tok/sec decode on Pi-4 class hardware (NeoGPU end-to-end measurement)
Goal
Support BitNet b1.58 models (e.g.
microsoft/bitnet-b1.58-2B-4T) end-to-end, including NeoGPU's fused 4-plane lm_head optimization — the application-layer half of SKaiNET-developers/SKaiNET#1136 (vendored NeoGPU ternary LUT kernel; upstream agreement in anjaustin/neogpu#1).This is also an architecture validation (see the proof points in SKaiNET-developers/SKaiNET#1136): a whole new model class with an exotic lm_head format should require no changes to this repo's network DSL, fusion machinery, or runtimes — only a
ModelFamily, a network def built from stock layers, a declarativeWeightFormrequest, and sampling-level code.Per SKaiNET physiology, the fast lm_head is format-driven, not op-driven: formats, codecs and kernel packs (incl.
BITNET_PLANES, SKaiNET#1150) live in the engine, dispatch picks the fused kernel from the weight's encoding, and the DSL/DAG keep a plain dense/matmul. This repo owns only the model-level parts: choosing that format foroutput.weightat load, and the two-stage sampling.Dependency
This repo consumes SKaiNET via the Maven BOM (
sk.ainet:skainet-bom) — work here needs a SKaiNET release containing:BITNET_B1_58keep-packed GGUF loader +TernaryF32KernelPack(SKaiNET#1137–#1140)BITNET_PLANESencoding +lmhead_stage1kernel pack (SKaiNET#1150; symbol exported in SKaiNET#1137) — this repo has no native build of its ownWhy the fused lm_head
Upstream NeoGPU measured on Pi-4/Cortex-A72: full-vocab lm_head in 96 ms / 6.78 GOPS (4-thread, fused 4-plane LUT) vs 51 ms / 3.20 GOPS int8 with ~1.5% quant error. The weight format is 4 ternary planes with weights {1, ⅓, ⅑, 1/27} + per-row FP16 scale — effectively "8 bits as four ternary digits" (planes 4–7 exist too, used only for candidate rescoring).
Sub-issues
BITNET_PLANESweight format (WeightFormrequest at load) + two-stage top-k decode — no new op/layer/fusion passFollow-up candidate:
forwardBatchedcomputes the full-vocab projection for every prefill position then narrows to the last row — last-row-only lm_head is an easy independent win.Verification
skainet-cliproducing coherent text at BitNet-2B4T dims (H=2560, F=6912, vocab≈128k)