weight_utils
¶
Utilities for downloading and initializing model weights.
Functions¶
fastvideo.models.loader.weight_utils.default_weight_loader
¶
Default weight loader.
Source code in fastvideo/models/loader/weight_utils.py
fastvideo.models.loader.weight_utils.enable_hf_transfer
¶
automatically activates hf_transfer
Source code in fastvideo/models/loader/weight_utils.py
fastvideo.models.loader.weight_utils.filter_files_not_needed_for_inference
¶
Exclude files that are not needed for inference.
See https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/trainer.py#L227-L233
Source code in fastvideo/models/loader/weight_utils.py
fastvideo.models.loader.weight_utils.maybe_remap_kv_scale_name
¶
Remap the name of FP8 k/v_scale parameters.
This function handles the remapping of FP8 k/v_scale parameter names. It detects if the given name ends with a suffix and attempts to remap it to the expected name format in the model. If the remapped name is not found in the params_dict, a warning is printed and None is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The original loaded checkpoint parameter name. |
required |
params_dict
|
dict
|
Dictionary containing the model's named parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str | None
|
The remapped parameter name if successful, or the original name if no remapping is needed. |
None |
str | None
|
If the remapped name is not found in params_dict. |
Source code in fastvideo/models/loader/weight_utils.py
fastvideo.models.loader.weight_utils.pt_weights_iterator
¶
pt_weights_iterator(hf_weights_files: list[str], to_cpu: bool = True) -> Generator[tuple[str, Tensor], None, None]
Iterate over the weights in the model bin/pt files.
Source code in fastvideo/models/loader/weight_utils.py
fastvideo.models.loader.weight_utils.safetensors_weights_iterator
¶
safetensors_weights_iterator(hf_weights_files: list[str], to_cpu: bool = True) -> Generator[tuple[str, Tensor], None, None]
Iterate over the weights in the model safetensor files.