BitLinear replaces traditional linear layers in BitNet, enabling 1-bit weights while retaining higher precision elsewhere to reduce model cost and energy use. section 9.3
Operationally, BitLinear supports:
- Replacing linear layers in BitNet attention and feed-forward components. section 9.3
- Replacing linear layers in Hugging Face and ordinary PyTorch models through dedicated helper functions. section 9.4
- Keeping input/output embeddings and sampling probabilities at higher precision while binarizing attention weights. section 9.3
Replacing a model's linear layers
Load a pretrained model, call replace_linears_in_hf(model) for a Hugging Face model or replace_linears_in_pytorch_model(model) for a PyTorch model, then run inference normally. section 9.4
Figure 9.4 The BitLinear component (left) and the BitNet architecture (right)
Use the architecture diagram to compare the BitLinear component with its placement in BitNet's Transformer layout. section 9.3
