vllm.model_executor.model_loader.reload.geometry
¶
Integer geometry of the load plan: one traced copy_ as a box of the
checkpoint tensor plus a strided destination region, merging of writes, and
the byte runs a write covers. No torch state.
Classes:
-
Fallback–A name cannot be written directly; the message is the reported reason.
-
Region–as_stridedarguments relative to the target's storage offset, in
Functions:
-
box_and_region–Reduce one
copy_to a box of the (contiguous) checkpoint tensor and -
byte_runs–The bytes a strided write covers as [start, stop) runs; one covering
-
byte_span–The [start, stop) bytes from the first to the last element of a
-
merge_writes–Merge writes of one name that continue one another (a loader's
Fallback
¶
Region
dataclass
¶
as_strided arguments relative to the target's storage offset, in
elements of the write's dtype. shape is the shape of the write's box, or
that shape with some dimensions split.
Source code in vllm/model_executor/model_loader/reload/geometry.py
_merge(a, b)
¶
a and b as one write if b continues a along exactly one
box dim, into the same target, with an equal destination stride there.
Source code in vllm/model_executor/model_loader/reload/geometry.py
box_and_region(ckpt_shape, src_offset, dims)
¶
Reduce one copy_ to a box of the (contiguous) checkpoint tensor and
the destination shape and strides of the box's elements, in row-major box
order.
dims are the copied tensor's (size, source stride, destination
stride); src_offset is where its first element sits in the checkpoint
tensor. Each dim is assigned to the checkpoint dim its source stride steps
through, split where it spans several (flatten); the parts assigned to
one checkpoint dim must tile a contiguous range of it.
Example: P.copy_(W.t()) with W [4, 6] and P [6, 4] contiguous
has dims [(6, 1, 4), (4, 6, 1)]: the box is ((0, 4), (0, 6)) and
the destination shape (4, 6), stride (1, 4). A box dim the loader
splits and sends to unrelated places stays split: 6 becomes
(2, 3) with two destination strides.
Raises:
-
Fallback–the copy is not a view of a box (step slice, expand, ...).
Source code in vllm/model_executor/model_loader/reload/geometry.py
byte_runs(byte_offset, shape, stride, itemsize)
¶
The bytes a strided write covers as [start, stop) runs; one covering
span when there would be more than _MAX_RUNS.
Source code in vllm/model_executor/model_loader/reload/geometry.py
byte_span(byte_offset, shape, stride, itemsize)
¶
The [start, stop) bytes from the first to the last element of a non-empty strided write with non-negative strides.
Source code in vllm/model_executor/model_loader/reload/geometry.py
merge_writes(writes)
¶
Merge writes of one name that continue one another (a loader's per-expert or per-row loop) into single writes.