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

Aadi/device-fix #25

Merged
merged 4 commits into from
Apr 22, 2024
Merged

Aadi/device-fix #25

merged 4 commits into from
Apr 22, 2024

Conversation

aaprasad
Copy link
Contributor

@aaprasad aaprasad commented Nov 10, 2023

  • fix device errors
  • use accelerator from config rather than hard coded

Summary by CodeRabbit

  • Refactor

    • Streamlined data loading by removing the conditional generator initialization.
    • Updated device assignment in embedding calculations to ensure consistency across devices.
  • Bug Fixes

    • Fixed an issue in post-processing where device mismatch could lead to incorrect validity assessments.
  • Tests

    • Temporarily suspended certain test configurations related to device settings.
    • Removed parameterization of device settings in post-processing tests for simplification.
  • Chores

    • Commented out default device settings in training script to adjust device selection logic.

* use accelerator from config rather than hard coded
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.39%. Comparing base (b69f4dd) to head (3f21a02).

❗ Current head 3f21a02 differs from pull request most recent head df2f0d9. Consider uploading reports for the commit df2f0d9 to get more accurate results

Additional details and impacted files
@@                     Coverage Diff                     @@
##           talmo/add-osx-arm64-env      #25      +/-   ##
===========================================================
+ Coverage                    75.00%   75.39%   +0.39%     
===========================================================
  Files                           24       24              
  Lines                         1532     1508      -24     
===========================================================
- Hits                          1149     1137      -12     
+ Misses                         383      371      -12     

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

@talmo talmo marked this pull request as ready for review December 6, 2023 22:26
Copy link
Contributor

coderabbitai bot commented Dec 6, 2023

Important

Auto Review Skipped

Auto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes across various files suggest a shift in how the codebase handles device assignments and initialization for PyTorch operations. There's a move away from explicit CUDA device checks and generator settings for data loading, towards a more streamlined approach that could be preparing for device-agnostic code or simplifying the configuration process.

Changes

File Path Change Summary
biogtr/config.py Removed generator initialization; adjusted DataLoader initialization.
biogtr/inference/post_processing.py
biogtr/models/embedding.py
Updated device assignments for tensor operations.
biogtr/training/train.py
tests/fixtures/torch.py
tests/test_inference.py
Commented out device selection and default device setting; removed test setup related to device configuration.

🐇✨
In the land of code and byte,
A rabbit hopped through the night.
Tweaking devices, left and right,
For tensors to compute just right. 🌙💻


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e30a6b5 and 3f21a02.
Files selected for processing (6)
  • biogtr/config.py (1 hunks)
  • biogtr/inference/post_processing.py (1 hunks)
  • biogtr/models/embedding.py (2 hunks)
  • biogtr/training/train.py (2 hunks)
  • tests/fixtures/torch.py (1 hunks)
  • tests/test_inference.py (1 hunks)
Additional comments: 9
biogtr/config.py (2)
  • 174-184: The summary indicates that the generator variable and its parameter have been removed from the DataLoader initialization, but the provided hunk does not show this change. Please verify if the summary is accurate or if the hunk is missing the relevant changes.

  • 174-184: The changes to the get_dataloader method, specifically the setting of the pin_memory flag based on the number of workers and the use of torch.multiprocessing.set_sharing_strategy("file_system"), are good practices for optimizing data loading when using multiple workers. This should help prevent too many open files error and improve data transfer to the GPU when using pin_memory.

biogtr/inference/post_processing.py (1)
  • 148-154: The change to convert id_inds to the device of valid before performing matrix multiplication is a good practice to avoid device mismatch errors, which aligns with the PR objective of addressing device-related issues.
biogtr/models/embedding.py (2)
  • 147-154: The changes in the _learned_pos_embedding function correctly ensure that tensors are moved to the appropriate device, which aligns with the PR's goal of dynamic device configuration.

  • 187-195: The changes in the _learned_temp_embedding function correctly ensure that tensors are moved to the appropriate device, which aligns with the PR's goal of dynamic device configuration.

biogtr/training/train.py (3)
  • 18-18: The device selection logic has been commented out, which aligns with the PR's objective to use configuration files for device settings. Ensure that the Config class or other parts of the code now handle device configuration as intended.

  • 27-27: The setting of the default device has been commented out. Verify that the new device management mechanism is correctly implemented and that the default device is set appropriately elsewhere in the code.

  • 15-21: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [15-30]

The code now uses accelerator and devices variables to configure the trainer. Ensure that these variables are set based on the new configuration approach and that they are used consistently throughout the code.

tests/fixtures/torch.py (1)
  • 1-23: The changes in tests/fixtures/torch.py are consistent with the PR objective to address device errors and the summary provided. The entire file has been commented out to temporarily suspend the test setup related to device configuration due to a device error in test_training. Ensure that the root cause of the device error is identified and resolved before re-enabling this fixture.

Comment on lines 71 to 72
#@pytest.mark.parametrize("set_default_device", ["cpu"], indirect=True)
def test_post_processing(): #set_default_device
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment #set_default_device is potentially misleading since the set_default_device parameter has been removed. Consider updating or removing this comment to avoid confusion.

- def test_post_processing(): #set_default_device
+ def test_post_processing():

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
#@pytest.mark.parametrize("set_default_device", ["cpu"], indirect=True)
def test_post_processing(): #set_default_device
#@pytest.mark.parametrize("set_default_device", ["cpu"], indirect=True)
def test_post_processing():

@@ -68,8 +68,8 @@
assert len(instances_pred[test_frame]["pred_track_ids"] == num_detected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion is incorrectly formed; it should assert the equality of the length of pred_track_ids to num_detected.

- assert len(instances_pred[test_frame]["pred_track_ids"] == num_detected)
+ assert len(instances_pred[test_frame]["pred_track_ids"]) == num_detected

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
assert len(instances_pred[test_frame]["pred_track_ids"] == num_detected)
assert len(instances_pred[test_frame]["pred_track_ids"]) == num_detected

Co-authored-by: aaprasad <aaprasad.ucsd.edu>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@aaprasad aaprasad changed the base branch from main to talmo/add-osx-arm64-env April 22, 2024 22:48
@aaprasad aaprasad merged commit a6220b5 into talmo/add-osx-arm64-env Apr 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant