vllm.model_executor.parameter
¶
Classes:
-
BasevLLMParameter–Base parameter for vLLM linear layers. Extends the torch.nn.parameter
-
ChannelQuantScaleParameter–Parameter class for weight scales loaded for weights with
-
GroupQuantScaleParameter–Parameter class for weight scales loaded for weights with
-
ModelWeightParameter–Parameter class for linear layer weights. Uses both column and
-
PackedColumnParameter–Parameter for model parameters which are packed on disk
-
PackedvLLMParameter–Parameter for model weights which are packed on disk.
-
PerTensorScaleParameter–Parameter class for scales where the number of scales is
-
RowvLLMParameter–Parameter class defining weight_loading functionality
BasevLLMParameter
¶
Bases: Parameter
Base parameter for vLLM linear layers. Extends the torch.nn.parameter by taking in a linear weight loader. Will copy the loaded weight into the parameter when the provided weight loader is called.
Methods:
-
__init__–Initialize the BasevLLMParameter.
BlockQuantScaleParameter
¶
Bases: _ColumnvLLMParameter, RowvLLMParameter
Parameter class for weight scales loaded for weights with block-wise quantization. Uses both column and row parallelism.
ChannelQuantScaleParameter
¶
Bases: _ColumnvLLMParameter
Parameter class for weight scales loaded for weights with channel-wise quantization. Equivalent to _ColumnvLLMParameter.
GroupQuantScaleParameter
¶
Bases: _ColumnvLLMParameter, RowvLLMParameter
Parameter class for weight scales loaded for weights with grouped quantization. Uses both column and row parallelism.
ModelWeightParameter
¶
Bases: _ColumnvLLMParameter, RowvLLMParameter
Parameter class for linear layer weights. Uses both column and row parallelism.
PackedColumnParameter
¶
Bases: _ColumnvLLMParameter
Parameter for model parameters which are packed on disk and support column parallelism only. See PackedvLLMParameter for more details on the packed properties.
PackedvLLMParameter
¶
Bases: ModelWeightParameter
Parameter for model weights which are packed on disk. Example: GPTQ Marlin weights are int4 or int8, packed into int32. Extends the ModelWeightParameter to take in the packed factor, the packed dimension, and optionally, marlin tile size for marlin kernels. Adjusts the shard_size and shard_offset for fused linear layers model weight loading by accounting for packing and optionally, marlin tile size.
PerTensorScaleParameter
¶
Bases: BasevLLMParameter
Parameter class for scales where the number of scales is equivalent to the number of logical matrices in fused linear layers (e.g. for QKV, there are 3 scales loaded from disk). This is relevant to weights with per-tensor quantization. Adds functionality to map the scalers to a shard during weight loading.
Note: additional parameter manipulation may be handled for each quantization config specifically, within process_weights_after_loading
_load_into_shard_id(loaded_weight, shard_id, **kwargs)
¶
Slice the parameter data based on the shard id for loading.
RowvLLMParameter
¶
Bases: BasevLLMParameter
Parameter class defining weight_loading functionality (load_row_parallel_weight) for parameters being loaded into linear layers with row parallel functionality. Requires an input_dim to be defined.
SharedWeightParameter
¶
Bases: BasevLLMParameter
Parameter for weights with many shared tensors across a model.
For example, when applying transforms to the "gate" and "up" partitions of
MergedColumnParallelLinear, the transform weights must stay separate
tensors in order to allow for tensor memory sharing between layers.
Methods:
-
add_partition–Add a partition to the weight parameter. Partitions whose
data_key
add_partition(index, data_key, *args, **kwargs)
¶
Add a partition to the weight parameter. Partitions whose data_key
is the same will share tensor data
Parameters:
_ColumnvLLMParameter
¶
Bases: BasevLLMParameter
Private class defining weight loading functionality (load_merged_column_weight, load_qkv_weight) for parameters being loaded into linear layers with column parallelism. This includes QKV and MLP layers which are not already fused on disk. Requires an output dimension to be defined. Called within the weight loader of each of the column parallel linear layers.
permute_param_layout_(param, input_dim, output_dim, **kwargs)
¶
Permute a parameter's layout to the specified input and output dimensions, useful for forcing the parameter into a known layout, for example, if I need a packed (quantized) weight matrix to be in the layout {input_dim = 0, output_dim = 1, packed_dim = 0} then I can call: permute_param_layout_(x, input_dim=0, output_dim=1, packed_dim=0) to ensure x is in the correct layout (permuting it to the correct layout if required, asserting if it cannot get it to the correct layout)