MCPcopy Create free account

hub / github.com/dhakalnirajan/LLaMA-BitNet / functions

Functions24 in github.com/dhakalnirajan/LLaMA-BitNet

↓ 2 callersFunction_replace_linear_in_module
Recursively replaces every nn.Linear inside *module* with BitLinear, skipping the token embedding and lm_head (which stay full-precision).
utils.py:153
↓ 2 callersFunctionconvert_to_bitnet
Convert a HuggingFace LlamaForCausalLM to a BitNet b1.58 model in-place. Steps (exactly as described in the training manuscript): 1. R
utils.py:181
↓ 2 callersFunctiongenerate
Generate text continuation for *prompt*. Args: model: The BitNet LlamaForCausalLM. tokenizer: Matching
inference.py:102
↓ 1 callersMethod__init__
(self, dim: int, eps: float = 1e-6)
utils.py:73
↓ 1 callersFunction_model_has_bitlinear
Return True if at least one module in the model is already a BitLinear.
inference.py:54
↓ 1 callersFunction_quantize_activations_int8
Per-token absmax activation quantisation to int8 range [-127, 127]. scale = max(|x|, dim=-1) / 127 (per token, shape [batch, seq, 1]) x
utils.py:49
↓ 1 callersFunction_quantize_weights_ternary
Absmean weight quantisation → {-1, 0, +1}. scale = mean(|W|) + ε (per weight-matrix, scalar) W_q = round_clamp(W / scale) vi
utils.py:32
↓ 1 callersFunction_remove_decoder_prenorms
Remove the pre-attention and pre-FFN RMSNorms from every decoder layer. Per the paper: "Remove RMSNorm before attention and SwiGLU because
utils.py:165
↓ 1 callersFunctionbuild_dataloader
Load and tokenise the dataset. The dataset is expected to have a "text" column. Each example is tokenised and truncated / padded to `co
train.py:114
↓ 1 callersFunctionbuild_model
Build a small LLaMA 2 model from scratch, then convert to BitNet.
train.py:155
↓ 1 callersFunctioncount_parameters
(model: nn.Module)
train.py:106
↓ 1 callersMethodfrom_linear
Construct a BitLinear from an existing nn.Linear, copying its weight.
utils.py:134
↓ 1 callersFunctionget_autocast_ctx
Return a bf16 autocast context when supported, otherwise a no-op.
train.py:97
↓ 1 callersFunctionget_device
()
train.py:89
↓ 1 callersFunctionget_device
()
inference.py:46
↓ 1 callersFunctionload_model
Load model and tokenizer from *model_path*. If the saved model does not yet contain BitLinear layers (e.g. a plain LLaMA checkpoint), th
inference.py:59
↓ 1 callersFunctionmain
()
inference.py:173
↓ 1 callersFunctionparse_args
()
train.py:294
↓ 1 callersFunctionparse_args
()
inference.py:159
↓ 1 callersFunctiontrain
(cfg: dict)
train.py:178
Method__init__
( self, in_features: int, out_features: int, bias: bool = False, # pa
utils.py:103
Methodforward
(self, x: torch.Tensor)
utils.py:78
Methodforward
(self, x: torch.Tensor)
utils.py:114
Functiontokenise
(batch)
train.py:127