Skip to content

Commit ef84c6c

Browse files
author
Han Wang
committed
fix
1 parent 87e9b9d commit ef84c6c

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

deepmd/pt_expt/common.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,12 @@ def dpmodel_setattr(obj: torch.nn.Module, name: str, value: Any) -> tuple[bool,
216216

217217
# dpmodel object → pt_expt module
218218
if "_modules" in obj.__dict__:
219-
# Check if this is a NativeOP that needs conversion
220-
if isinstance(value, NativeOP) and not isinstance(value, torch.nn.Module):
221-
converted = try_convert_module(value)
222-
if converted is not None:
223-
return False, converted
224-
# If it's a NativeOP but not registered, this is likely a bug
225-
raise TypeError(
226-
f"Attempted to assign a dpmodel object of type {type(value).__name__} "
227-
f"but no converter is registered. Please call register_dpmodel_mapping "
228-
f"for this type."
229-
)
219+
converted = try_convert_module(value)
220+
if converted is not None:
221+
return False, converted
222+
# Note: Some NativeOP objects (like EnvMat) don't need conversion and can
223+
# be used directly. If a NativeOP truly needs conversion but isn't registered,
224+
# it will fail at runtime when the object is actually used.
230225

231226
return False, value
232227

0 commit comments

Comments
 (0)