[Solution] ValueError from transformers due to torch.load safety check
For anyone encountering this ValueError from the transformers library:
ValueError: Due to a serious vulnerability issue in `torch.load`, even with `weights_only=True`, we now require users to upgrade torch to at least v2.6 in order to use the function. This version restriction does not apply when loading files with safetensors.
See the vulnerability report here https://nvd.nist.gov/vuln/detail/CVE-2025-32434
even after downgrading PyTorch to < 2.4, here is the solution:
Problem:
The hy3dgen package requires transformers >= 4.48.0. However, these newer versions of transformers have their own built-in safety check that prevents loading .bin files (like the one for the text_encoder), causing a ValueError regardless of the PyTorch version.
This solution manually disables the safety check inside the transformers library.
open .../site-packages/transformers/utils/import_utils.py in conda environment or other environments
find check_torch_load_is_safe() function, and replace it:
def check_torch_load_is_safe():
"""
if not is_torch_greater_or_equal("2.6"):
raise ValueError(
"Due to a serious vulnerability issue in `torch.load`, even with `weights_only=True`, we now require users "
"to upgrade torch to at least v2.6 in order to use the function. This version restriction does not apply "
"when loading files with safetensors."
"\nSee the vulnerability report here https://nvd.nist.gov/vuln/detail/CVE-2025-32434"
)
"""
pass
This allows the .bin file to be loaded without errors while keeping the required transformers version.
I upgraded PyTorch to 2.6, and the code ran without issues.