Skip to content

vllm.model_executor.model_loader.reload.trace

Tracing a model's weight loaders on zero-storage checkpoint tensors.

A TraceTensor stands in for one checkpoint tensor while load_weights runs. View ops (VIEW_OPS) return a child that knows, as a meta view over the checkpoint tensor, where each of its elements sits in that tensor. What a trace cannot settle by itself (copy_ from it, ops outside VIEW_OPS, value reads) it hands to the bake's _PlanSink (bake.py), which decides what each means for the plan; nothing moves data.

Classes:

  • TraceTensor –

    Zero-storage meta tensor that records how a loader slices a checkpoint

TraceTensor

Bases: Tensor

Zero-storage meta tensor that records how a loader slices a checkpoint tensor.

_geom is a meta view over a contiguous meta tensor of the checkpoint shape: its offset and strides say which checkpoint element each element of this tensor is. It is None (and _lost says why) once this tensor is no longer a view of the checkpoint tensor. _sink is the bake that owns the trace.

Methods:

  • checkpoint –

    The whole checkpoint tensor name.

_is_noop_to(args, kwargs)

.to() that keeps the dtype, such as .to(param.device): a device move keeps every byte, and a trace has no device to move from.

_view(func, args, kwargs)

Run the view op on _geom for the children's shapes and geometry; on a plain meta tensor when that is lost or fails.

checkpoint(name, shape, dtype, sink) classmethod

The whole checkpoint tensor name.

_is_basic_index(index)

Whether index holds only ints, int slices, None and Ellipsis.