This issue comes from a Codex global scan of deepmodeling/deepmd-kit at commit 73de44b1f94471b2e3bdb6b11f57b34d7bc791bb.
Problem
The Paddle DPA3 descriptor tries to honor trainable=False by setting param.requires_grad = trainable:
|
# set trainable |
|
for param in self.parameters(): |
|
param.requires_grad = trainable |
Other Paddle descriptors freeze parameters with stop_gradient, which is the Paddle parameter flag used by autograd:
|
# set trainable |
|
self.trainable = trainable |
|
for param in self.parameters(): |
|
param.stop_gradient = not trainable |
|
# set trainable |
|
for param in self.parameters(): |
|
param.stop_gradient = not trainable |
Impact
Users configuring a non-trainable Paddle DPA3 descriptor can still update descriptor parameters during training because the freeze pass writes a PyTorch-style attribute instead of Paddle's stop_gradient flag. DPA3's RepFlow/MLP parameters rely on this outer descriptor freeze pass, so the requested freeze does not take effect.
Suggested fix
Use the same Paddle pattern as the neighboring descriptors:
for param in self.parameters():
param.stop_gradient = not trainable
If Paddle exposes any additional trainable-state APIs in the supported versions, keep this consistent across all Paddle descriptor wrappers.
This issue comes from a Codex global scan of
deepmodeling/deepmd-kitat commit73de44b1f94471b2e3bdb6b11f57b34d7bc791bb.Problem
The Paddle DPA3 descriptor tries to honor
trainable=Falseby settingparam.requires_grad = trainable:deepmd-kit/deepmd/pd/model/descriptor/dpa3.py
Lines 251 to 253 in 73de44b
Other Paddle descriptors freeze parameters with
stop_gradient, which is the Paddle parameter flag used by autograd:deepmd-kit/deepmd/pd/model/descriptor/se_a.py
Lines 528 to 531 in 73de44b
deepmd-kit/deepmd/pd/model/descriptor/dpa2.py
Lines 331 to 333 in 73de44b
Impact
Users configuring a non-trainable Paddle DPA3 descriptor can still update descriptor parameters during training because the freeze pass writes a PyTorch-style attribute instead of Paddle's
stop_gradientflag. DPA3's RepFlow/MLP parameters rely on this outer descriptor freeze pass, so the requested freeze does not take effect.Suggested fix
Use the same Paddle pattern as the neighboring descriptors:
If Paddle exposes any additional trainable-state APIs in the supported versions, keep this consistent across all Paddle descriptor wrappers.