[deps] bump transformers to 5.19.0 (#42784)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yihao Wang
2026-10-07 17:04:08 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent c52dcc5a01
commit 11972e5207
9 changed files with 48 additions and 9 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ dependencies = [
"torchcodec==0.17.0 ; sys_platform != 'linux' or (sys_platform == 'linux' and platform_machine != 'aarch64' and platform_machine != 'arm64' and platform_machine != 'armv7l')", # Not available on Linux ARM.
"torchvision",
"tqdm",
"transformers==5.17.0",
"transformers==5.19.0",
"uvicorn",
"uvloop",
"watchfiles",
+1 -1
View File
@@ -66,7 +66,7 @@ dependencies = [
"torchcodec==0.12.0 ; sys_platform != 'linux' or (sys_platform == 'linux' and platform_machine != 'aarch64' and platform_machine != 'arm64' and platform_machine != 'armv7l')",
"torchvision==0.29.0",
"tqdm",
"transformers==5.17.0",
"transformers==5.19.0",
"triton==3.8.0",
"uvicorn",
"uvloop",
+1 -1
View File
@@ -62,7 +62,7 @@ dependencies = [
"tiktoken",
"timm==1.0.16",
"tqdm",
"transformers==5.17.0",
"transformers==5.19.0",
"uvicorn",
"uvloop",
"xxhash",
+1 -1
View File
@@ -62,7 +62,7 @@ runtime_base = [
"soundfile==0.13.1",
"tiktoken",
"tqdm",
"transformers==5.17.0",
"transformers==5.19.0",
"uvicorn",
"uvloop",
"xxhash",
+1 -1
View File
@@ -66,7 +66,7 @@ dependencies = [
"torchcodec==0.13.0 ; sys_platform != 'linux' or (sys_platform == 'linux' and platform_machine != 'aarch64' and platform_machine != 'arm64' and platform_machine != 'armv7l')", # torch==2.13.0 on XPU uses torchcodec 0.13.0
"torchvision==0.28.0+xpu",
"tqdm",
"transformers==5.17.0",
"transformers==5.19.0",
"uvicorn",
"xxhash",
"uvloop",
@@ -33,6 +33,36 @@ def get_1d_sincos_pos_embed_from_grid(embed_dim, pos):
return np.concatenate([emb_sin, emb_cos], axis=1)
# transformers 5.19 renamed Dinov2's attention projections and split its SwiGLU input
# projection into gate/up. from_pretrained remaps legacy checkpoints on its own, but
# Hunyuan3D builds Dinov2Model from a config and loads its own state dict, where a
# non-strict load would silently leave these weights randomly initialized.
_DINOV2_LEGACY_RENAMES = (
("attention.attention.query.", "attention.q_proj."),
("attention.attention.key.", "attention.k_proj."),
("attention.attention.value.", "attention.v_proj."),
("attention.output.dense.", "attention.o_proj."),
("mlp.weights_out.", "mlp.down_proj."),
)
def _remap_legacy_dinov2_keys(module, state_dict, prefix, *args):
if not hasattr(module.encoder.layer[0].attention, "q_proj"):
return # transformers < 5.19 still uses the checkpoint's layout
layer_prefix = prefix + "encoder.layer."
for key in [k for k in state_dict if k.startswith(layer_prefix)]:
for old, new in _DINOV2_LEGACY_RENAMES:
if old in key:
state_dict[key.replace(old, new)] = state_dict.pop(key)
break
else:
if ".mlp.weights_in." in key:
# SwiGLU computed silu(first half) * second half of weights_in.
gate, up = state_dict.pop(key).chunk(2, dim=0)
state_dict[key.replace("mlp.weights_in.", "mlp.gate_proj.")] = gate
state_dict[key.replace("mlp.weights_in.", "mlp.up_proj.")] = up
class ImageEncoder(
ConditioningEncoderMixin, nn.Module, LayerwiseOffloadableModuleMixin
):
@@ -60,6 +90,8 @@ class ImageEncoder(
self.model = self.MODEL_CLASS.from_pretrained(version)
else:
self.model = self.MODEL_CLASS(self.MODEL_CONFIG_CLASS.from_dict(config))
if isinstance(self.model, Dinov2Model):
self.model.register_load_state_dict_pre_hook(_remap_legacy_dinov2_keys)
self.model.eval()
self.model.requires_grad_(False)
self.use_cls_token = use_cls_token
@@ -300,7 +300,14 @@ class Hunyuan3D2Pipeline(ComposedPipelineBase):
component = target_cls(**params)
if weights is not None:
component.load_state_dict(weights, strict=False)
# Extra checkpoint keys are tolerated, but a weight the module expects and
# the checkpoint lacks would stay randomly initialized and corrupt outputs.
missing = component.load_state_dict(weights, strict=False).missing_keys
if missing:
raise RuntimeError(
f"{cfg['target']} checkpoint is missing {len(missing)} weights, "
f"e.g. {missing[:5]}"
)
component.to(device=device, dtype=dtype)
return component.eval()