-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support array API #3922
feat: support array API #3922
Conversation
Fix deepmodeling#3430. This PR sets up the basic support for the array API, and make an example function (`compute_smooth_weight`) to support the array API. I believe NumPy and JAX have supported it (or through `array-api-compat`), so we don't need to write things twice for NumPy and JAX (although we can write them using the ChatGPT, it's still better to maintain only one thing). There are some challeging to use it in the TorchScript, so I give it up. Supporting more function can be implemented in the following PRs. Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Warning Rate limit exceeded@njzjz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 49 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes introduce array API compatibility within the codebase. This includes adding dependencies related to array API and a new test case to verify array operations using Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
deepmd/dpmodel/utils/env_mat.py (1)
Line range hint
69-72
: Consider simplifying conditional logic with a ternary operator.- if radial_only: - env_mat = t0 * weight - else: - env_mat = np.concatenate([t0, t1], axis=-1) * weight + env_mat = t0 * weight if radial_only else np.concatenate([t0, t1], axis=-1) * weightThis simplification reduces the lines of code and enhances readability by using a ternary operator instead of a full if-else block.
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## devel #3922 +/- ##
=======================================
Coverage 82.73% 82.73%
=======================================
Files 519 520 +1
Lines 50539 50549 +10
Branches 3015 3015
=======================================
+ Hits 41812 41821 +9
- Misses 7791 7792 +1
Partials 936 936 ☔ View full report in Codecov by Sentry. |
Fix deepmodeling#3430. This PR sets up the basic support for the array API, and make an example function (`compute_smooth_weight`) to support the array API. I believe NumPy and JAX have supported it (or through `array-api-compat`), so we don't need to write things twice for NumPy and JAX (although we can write them using the ChatGPT, it's still better to maintain only one thing). There are some challeging to use it in the TorchScript, so I give it up. Supporting more function can be implemented in the following PRs. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced testing for `compute_smooth_weight` function using `array_api_strict` for enhanced array operations. - **Chores** - Updated dependencies to include `'array-api-compat'` and `'array-api-strict>=2'` for improved compatibility and testing capabilities. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Fix #3430.
This PR sets up the basic support for the array API, and make an example function (
compute_smooth_weight
) to support the array API. I believe NumPy and JAX have supported it (or througharray-api-compat
), so we don't need to write things twice for NumPy and JAX (although we can write them using the ChatGPT, it's still better to maintain only one thing). There are some challeging to use it in the TorchScript, so I give it up. Supporting more function can be implemented in the following PRs.Summary by CodeRabbit
New Features
compute_smooth_weight
function usingarray_api_strict
for enhanced array operations.Chores
'array-api-compat'
and'array-api-strict>=2'
for improved compatibility and testing capabilities.