bendtorch-load
Search uses release 1.2.0.0 · 96 definitions
Definitions (96)
- def require
- type W64
- def W64.of
- def W64.of_pair
- def W64.bit
- def W64.eq
- def W64.add_go
- def W64.adda + b, wrapping at 2^64: the low words' sum carries one when it wrapped (it is then below either term)
- def W64.mul_go
- def W64.mul_smalla * k for k < 2^16 (enough for bytes a number and decimal digits), wrapping at 2^64: lo = l1 2^16 + l0, so lo * k = (l1 k) 2^16 + l0 k, where both products fit a U32
- def W64.div10_go
- def W64.div10(a / 10, a % 10), by long division in 16-bit steps so no partial remainder overflows a U32
- def W64.is_zero
- def W64.show_go
- def W64.show_if
- def W64.showthe decimal digits, as U32.show writes them
- def W64.digits
- def W64.read_go
- def W64.read_if
- def W64.readA decimal number of 1 to 19 digits (every such number fits 64 bits); anything else is None
- def read_done
- def read_go
- def read_sized
- def readA raw, exact-size little-endian F32 file, read once into one source array: up to 2^32 - 1 numbers (16 GiB).
- def read_f32_atn little-endian F32 numbers at byte `off` of a file of any size (a tensor inside a larger file)
- def read_bf16_atn little-endian BF16 numbers at byte `off` of a file of any size, each widened exactly to F32 (bf16.to(torch.float32))
- def size_done
- def sizeA file's size in bytes, at any size
- def weights_done
- def weightsAll parameters in Layer.dump order.
- def train_readThe checkpoint layout is determined by the already initialized optimizer state, without a header: SGD: parameters; momentum: parameters, buffer; Adam/AdamW: parameters, m, v, 1 - b1^t, 1 - b2^t; AdamW with packed BF16 moments: parameters, the moments' tree (main.bend's pt_store), 1 - b1^t, 1 - b2^t, the whole file read.
- def cells_done
- def cells_ofthe number of F32 cells in a file (a packed-moment checkpoint carries its own sizes: its length is the file's)
- def train
- type Entryone tensor the model expects, in Layer.dump order: its name in the file and its shape (rows, columns, ...)
- def St.entry_name
- type Tok
- type Lexthe lexer's state between bytes: outside a token, inside a string (its characters reversed), just after a backslash in a string, inside a number
- type LexRa state and the tokens one byte completed, in order
- def St.digit
- def St.space
- def St.pun{ } [ ] : ,
- def St.out_go
- def St.out
- def St.str_go
- def St.num_enda number ends at the first byte that is not a digit, and that byte is then read as outside a token
- def St.num_go
- def St.step
- def St.pushts onto out, which holds the tokens so far in reverse
- def St.finthe end of the header: a number ends there, an unfinished string is malformed
- def St.lexthe header's tokens, in order; r is what the previous byte left
- type Recone top-level entry of the header: a tensor (or __metadata__, which no layout names)
- type Psthe pass over the tokens: the depth ({ and [ open a level), whether the last token was a colon, the last string, the current entry's name and field, what the entry holds so far, the numbers of the open list, the entries read (last first), and the count of tokens the header may not hold
- def Sp.stra string is a value after a colon (the dtype, at depth 2) or else a key, kept until its colon
- def Sp.colona colon makes the last string the entry's name (depth 1) or the field's (depth 2)
- def Sp.open{ opens a level; at depth 2 an entry starts empty
- def Sp.close} closes a level; closing depth 2 ends an entry
- def Sp.lopen
- def Sp.lclose] closes a list; at depth 3 it is the entry's shape or data_offsets
- def Sp.comma
- def Sp.numa number counts inside a list at depth 3; elsewhere it is not part of a tensor's entry
- def Sp.pun
- def Sp.step
- def Sp.parse
- def St.rec_name
- def St.find_put
- def St.findthe entry named `name`
- def St.prod
- def St.total
- def St.shape_eq
- def St.show_u
- def St.show_w
- type Planwhere a tensor is and how to read it, or why it cannot be read
- def St.plan_span
- def St.plan_ofdata_offsets must be [begin, end] with end - begin the tensor's bytes
- def St.plan_shape
- def St.plan_dtype
- def St.plan
- def St.read
- def St.got
- def St.thenreads one planned tensor into cells at .., then goes on with k
- def St.fillevery tensor of es, in order, into consecutive cells from at
- def St.le32
- def St.le64the header's length: the file's first 8 bytes, little-endian
- def St.count
- type HeaderA parsed safetensors header: where the data starts and each tensor's record.
- def St.parsed
- def St.header
- def St.lengththe format caps the header at 100 MB
- def St.first8
- def headerA safetensors file's header, parsed; the file is closed after it
- def tensors_fromThe tensors `layout` names, read from the file whose header is h, in the layout's order, into one array of n numbers
- def tensorsThe tensors `layout` names, read from a safetensors file in its order into one array of n numbers (F32 as they are, BF16 widened exactly).
- def pieceOne layer's parameters from the file whose header is h: `layout` names its tensors in Layer.dump order, and Layer.load fills them; the array they were read into is gone once this answers
- def twoA pair of parameters filled one after the other: the first piece's source array is released before the second is read
- def safetensorsAll parameters from a safetensors file: `layout` names the model's tensors in Layer.dump order (a tied output head is not in it, as SmolLM2's is not in its file), and Layer.load fills the parameters from them as `weights` does