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

docs: add documentation for installation requirements of DPA-2 #4178

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Oct 1, 2024

Fix #4161.

Summary by CodeRabbit

  • New Features

    • Added installation requirements for the DPA-2 model in the documentation, including customized OP library instructions.
  • Improvements

    • Enhanced error messaging in the border_op function for better user guidance.
    • Clarified parameter handling and documentation in the DescrptBlockRepformers class.
    • Improved logic for processing input tensors and neighbor lists in the forward method.
    • Strengthened input statistics handling in the compute_input_stats method.

njzjz added 2 commits October 1, 2024 17:16
Fix deepmodeling#4161.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@njzjz njzjz requested review from iProzd and wanghan-iapcm October 1, 2024 21:17
@njzjz njzjz linked an issue Oct 1, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

📝 Walkthrough

Walkthrough

The changes involve modifications to the DescrptBlockRepformers class in the repformers.py file, including enhancements to the constructor, error handling, and input processing methods. Additionally, the dpa2.md documentation has been updated to include installation requirements for the DPA-2 model on LAMMPS, specifically regarding the customized OP library and MPI usage.

Changes

File Path Change Summary
deepmd/pt/model/descriptor/repformers.py Updated DescrptBlockRepformers class constructor and methods, enhanced error messages, refined logic for input handling.
doc/model/dpa2.md Added a new section on installation requirements for DPA-2 model on LAMMPS, including OP library details.

Assessment against linked issues

Objective Addressed Explanation
Error handling for border_op operation (#[4161])
Documentation on customized OP library installation (#[4161])
Clarification of environmental variable requirements (#[4161]) No specific changes made to clarify environment variables.
Improvements to input handling in DescrptBlockRepformers (#[4161])

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.

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 (5)
doc/model/dpa2.md (2)

11-19: Excellent addition of installation requirements!

The new section on installation requirements is a valuable addition to the documentation. It directly addresses the issues mentioned in the PR objectives, particularly the NotImplementedError related to the customized PyTorch OP library. The information is clear, concise, and provides actionable instructions for users.

Consider adding information about the following environment variables mentioned in the related issue:

  • OMP_NUM_THREADS
  • DP_INTRA_OP_PARALLELISM_THREADS
  • DP_INTER_OP_PARALLELISM_THREADS

This additional information could help users avoid potential issues related to these variables.


11-19: Overall, excellent documentation update!

This addition to the documentation effectively addresses the installation requirements for the DPA-2 model, which was the primary objective of this PR. The new section provides clear instructions and recommendations that should help users avoid the errors encountered in issue #4161.

To further enhance the documentation:

  1. Consider adding a troubleshooting section that addresses common errors, including those mentioned in the issue (e.g., missing librdmacm.so.1, TensorFlow and PyTorch related errors).
  2. It might be helpful to provide a brief explanation of why the customized OP library is necessary, to give users a better understanding of its importance.
  3. If possible, include version compatibility information (e.g., which versions of DeepMD-kit, PyTorch, and LAMMPS are known to work together).

These additions would make the documentation even more robust and user-friendly.

deepmd/pt/model/descriptor/repformers.py (3)

Line range hint 186-186: Document the old_impl parameter in the constructor's docstring.

The parameter old_impl is missing from the docstring of the __init__ method in the DescrptBlockRepformers class. Please add documentation for this parameter to explain its purpose and usage.

Apply this diff to add the missing documentation:

             ln_eps : float, optional
                 The epsilon value for layer normalization.
             seed : int, optional
                 Random seed for parameter initialization.
+            old_impl : bool, optional
+                Whether to use the old implementation of `RepformerLayer`.
             use_sqrt_nnei : bool, optional
                 Whether to use the square root of the number of neighbors for symmetrization_op normalization instead of using the number of neighbors directly.

Line range hint 290-298: Add documentation for the comm_dict parameter in forward method.

The comm_dict parameter has been introduced to handle communication in distributed settings. To improve clarity, please document this parameter in the method's docstring, including its expected structure and usage.

Consider adding the following to the forward method's docstring:

         ):
+            r"""
+            Forward pass of the descriptor block.
+
+            Parameters
+            ----------
+            nlist : torch.Tensor
+                Neighbor list tensor.
+            extended_coord : torch.Tensor
+                Extended coordinates tensor.
+            extended_atype : torch.Tensor
+                Extended atomic types tensor.
+            extended_atype_embd : Optional[torch.Tensor], optional
+                Extended atomic type embeddings, by default None.
+            mapping : Optional[torch.Tensor], optional
+                Mapping tensor for gathering data, by default None.
+            comm_dict : Optional[Dict[str, torch.Tensor]], optional
+                Communication dictionary containing tensors for distributed computation, by default None.
+
+            """

Line range hint 366-376: Handle potential exceptions when accessing comm_dict keys.

The code assumes that certain keys exist in comm_dict. While assertions are used, consider adding exception handling or more descriptive error messages to aid debugging if a key is missing.

For example, you might replace assertions with explicit error messages:

-            assert "send_list" in comm_dict
+            if "send_list" not in comm_dict:
+                raise KeyError("comm_dict is missing the 'send_list' key.")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ad8bebe and 6cef7a1.

📒 Files selected for processing (2)
  • deepmd/pt/model/descriptor/repformers.py (1 hunks)
  • doc/model/dpa2.md (1 hunks)
🔇 Additional comments (3)
deepmd/pt/model/descriptor/repformers.py (3)

63-64: Enhanced error message in border_op function.

The updated error message provides additional context by directing users to the DPA-2 documentation. This improvement helps users understand the reason behind the NotImplementedError and how to resolve it.


Line range hint 197-232: Conditional instantiation of Repformer layers based on old_impl.

The code correctly adds support for using either the new RepformerLayer or the old implementation RepformerLayerOld based on the old_impl flag. This enhancement increases flexibility, allowing users to choose between implementations as needed.


Line range hint 351-376: Ensure correct handling of tensor dimensions in communication operations.

When comm_dict is not None, the code performs padding on g1 and uses torch.ops.deepmd.border_op. Please verify that tensor dimensions are correctly managed and that padding aligns with the expected shapes, especially considering the squeeze and unsqueeze operations.

Run the following script to check tensor dimensions after padding and the output of border_op:

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.46%. Comparing base (ad8bebe) to head (6cef7a1).
Report is 7 commits behind head on devel.

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #4178   +/-   ##
=======================================
  Coverage   83.46%   83.46%           
=======================================
  Files         537      537           
  Lines       52168    52168           
  Branches     3046     3046           
=======================================
  Hits        43543    43543           
  Misses       7678     7678           
  Partials      947      947           

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

@iProzd iProzd added this pull request to the merge queue Oct 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 7, 2024
@njzjz njzjz added this pull request to the merge queue Oct 7, 2024
Merged via the queue into deepmodeling:devel with commit d667929 Oct 7, 2024
60 checks passed
@njzjz njzjz deleted the docs-dpa2-install branch October 7, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when running LAMMPS in the devel branch
3 participants