fastvideo.v1.models.loader.weight_utils
#
Utilities for downloading and initializing model weights.
Module Contents#
Classes#
Functions#
Default weight loader. |
|
automatically activates hf_transfer |
|
Exclude files that are not needed for inference. |
|
Remap the name of FP8 k/v_scale parameters. |
|
Iterate over the weights in the model bin/pt files. |
|
Iterate over the weights in the model safetensor files. |
Data#
API#
- class fastvideo.v1.models.loader.weight_utils.DisabledTqdm(*args, **kwargs)[source]#
Bases:
tqdm.auto.tqdm
Initialization
- fastvideo.v1.models.loader.weight_utils.default_weight_loader(param: torch.Tensor, loaded_weight: torch.Tensor) None [source]#
Default weight loader.
- fastvideo.v1.models.loader.weight_utils.enable_hf_transfer() None [source]#
automatically activates hf_transfer
- fastvideo.v1.models.loader.weight_utils.filter_duplicate_safetensors_files(hf_weights_files: List[str], hf_folder: str, index_file: str) List[str] [source]#
- fastvideo.v1.models.loader.weight_utils.filter_files_not_needed_for_inference(hf_weights_files: List[str]) List[str] [source]#
Exclude files that are not needed for inference.
See https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/trainer.py#L227-L233
- fastvideo.v1.models.loader.weight_utils.get_lock(model_name_or_path: Union[str, pathlib.Path], cache_dir: Optional[str] = None)[source]#
- fastvideo.v1.models.loader.weight_utils.maybe_remap_kv_scale_name(name: str, params_dict: dict) Optional[str] [source]#
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:
- Returns:
The remapped parameter name if successful, or the original name if no remapping is needed. None: If the remapped name is not found in params_dict.
- Return type:
- fastvideo.v1.models.loader.weight_utils.pt_weights_iterator(hf_weights_files: List[str]) Generator[Tuple[str, torch.Tensor], None, None] [source]#
Iterate over the weights in the model bin/pt files.