Skip to content
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

fix(tf): throw errors when loc_cellnum is 0 #4180

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Oct 2, 2024

Fix #4122.

Summary by CodeRabbit

  • New Features

    • Enhanced error handling in the computation process, providing clearer error messages for invalid local cell numbers.
  • Bug Fixes

    • Improved robustness of the compute_cell_info function to prevent failures due to invalid input conditions.

Fix deepmodeling#4122.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@njzjz njzjz linked an issue Oct 2, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Oct 2, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve the addition of error handling in the compute_cell_info function within the coord.cc file. A new header file, errors.h, is included to facilitate this. A conditional check is introduced to ensure that the computed loc_cellnum is positive; if not, a deepmd::deepmd_exception is thrown with a specific error message regarding the local cell number, indicating a potential issue with a periodic boundary condition box.

Changes

File Change Summary
source/lib/src/coord.cc Added #include "errors.h"; introduced error handling in compute_cell_info to check loc_cellnum and throw an exception if it is non-positive.

Assessment against linked issues

Objective Addressed Explanation
Ensure clear error message for zero box input (related to issue #4122)

Suggested reviewers

  • wanghan-iapcm
  • iProzd

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Core label Oct 2, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
source/lib/src/coord.cc (1)

99-104: LGTM: Improved error handling for zero loc_cellnum

The added check for loc_cellnum (cell_info[21]) effectively addresses the PR objective. The error message is informative and helps users identify the potential cause of the issue.

A minor suggestion to enhance the error message:

Consider adding more context to the error message. For example:

-        "loc_cellnum should be positive but is " +
-        std::to_string(cell_info[21]) +
-        ". You may give a PBC box with zero volume.");
+        "Invalid local cell number (loc_cellnum): expected a positive value, but got " +
+        std::to_string(cell_info[21]) +
+        ". This may occur if you provided a periodic boundary condition (PBC) box with zero volume.");

This change provides more context about what loc_cellnum represents and makes the error message slightly more user-friendly.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ad8bebe and 9f40295.

📒 Files selected for processing (1)
  • source/lib/src/coord.cc (2 hunks)
🔇 Additional comments (2)
source/lib/src/coord.cc (2)

7-7: LGTM: Inclusion of error handling header

The addition of the "errors.h" header is appropriate for the new error handling mechanism introduced in this PR. This change aligns well with the objective of improving error feedback for users.


Line range hint 1-150: Summary: Changes align well with PR objectives

The modifications in this file effectively address the PR objective of throwing errors when loc_cellnum is 0. The implementation is focused and minimal, adding proper error handling without introducing unnecessary changes. This approach improves the feedback to users when encountering issues related to zero volume periodic boundary condition boxes, as described in the linked issue #4122.

The changes are well-implemented and should help prevent confusion caused by misleading "invalid configuration argument" errors in CUDA operations when zero box inputs are provided.

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 83.46%. Comparing base (ad8bebe) to head (9f40295).
Report is 5 commits behind head on devel.

Files with missing lines Patch % Lines
source/lib/src/coord.cc 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #4180      +/-   ##
==========================================
- Coverage   83.46%   83.46%   -0.01%     
==========================================
  Files         537      537              
  Lines       52168    52171       +3     
  Branches     3046     3047       +1     
==========================================
  Hits        43543    43543              
- Misses       7678     7681       +3     
  Partials      947      947              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue Oct 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 4, 2024
@njzjz
Copy link
Member Author

njzjz commented Oct 4, 2024

The CI error has been submitted to data-apis/array-api-compat#186

@njzjz
Copy link
Member Author

njzjz commented Oct 4, 2024

Or shall we drop Python 3.8 support? Python 3.8 has reached EOL

@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue Oct 6, 2024
@wanghan-iapcm wanghan-iapcm removed this pull request from the merge queue due to a manual request Oct 6, 2024
@njzjz njzjz added this pull request to the merge queue Oct 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 6, 2024
@njzjz njzjz added this pull request to the merge queue Oct 6, 2024
Merged via the queue into deepmodeling:devel with commit a0747b9 Oct 7, 2024
60 checks passed
@njzjz njzjz deleted the loc_cellnum-zero-error branch October 7, 2024 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Zero box causes invalid configuration argument in CUDA
2 participants