fix(jax): fix repflows JIT issues#4775
Conversation
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn>
There was a problem hiding this comment.
Pull Request Overview
The PR addresses JIT incompatibility in repflows by guarding the Python int() conversion behind a dynamic selection flag.
- Guard
int()call withself.use_dynamic_selto avoid JIT errors when static. - Default
n_edgeto0when dynamic selection is disabled.
Comments suppressed due to low confidence (1)
deepmd/dpmodel/descriptor/repflows.py:1329
- Using Python int(...) inside JIT can break tracing. To maintain JIT compatibility and consistent array types, prefer using
.item()on the xp scalar. For example:
n_edge = xp.sum(xp.astype(nlist_mask, xp.int32)).item() if self.use_dynamic_sel else xp.array(0, dtype=xp.int32)n_edge = (int(xp.sum(xp.astype(nlist_mask, xp.int32))) if self.use_dynamic_sel else 0)
📝 WalkthroughWalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RepFlowLayer
User->>RepFlowLayer: call(...)
alt use_dynamic_sel is True
RepFlowLayer->>RepFlowLayer: n_edge = int(nlist_mask.sum())
else use_dynamic_sel is False
RepFlowLayer->>RepFlowLayer: n_edge = 0
end
RepFlowLayer-->>User: result
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (29)
🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #4775 +/- ##
=======================================
Coverage 84.79% 84.79%
=======================================
Files 698 698
Lines 67746 67746
Branches 3540 3540
=======================================
+ Hits 57444 57445 +1
Misses 9171 9171
+ Partials 1131 1130 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit