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

Made splitting only happen at densification. #30

Merged
merged 6 commits into from
Sep 12, 2024
Merged

Conversation

mmcdermott
Copy link
Owner

@mmcdermott mmcdermott commented Sep 12, 2024

Closes #21

Summary by CodeRabbit

  • New Features

    • Simplified handling of nested ragged tensors for easier data structure management.
    • Enhanced slicing operations for improved clarity and efficiency.
    • Improved error handling during concatenation operations.
  • Bug Fixes

    • Removed unnecessary checks and redundant calculations, enhancing performance and reliability.
  • Refactor

    • Streamlined initialization and loading processes for better readability and maintainability.
  • Chores

    • Adjusted benchmarking configuration to lower alert thresholds for performance regressions and modified job failure behavior.
    • Simplified permissions in the benchmarking job configuration.

Copy link

coderabbitai bot commented Sep 12, 2024

Warning

Rate limit exceeded

@mmcdermott has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 3 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

Commits

Files that changed from the base of the PR and between f687e9e and f2e0466.

Walkthrough

The changes in the pull request focus on simplifying the handling of nested ragged tensors in the ragged_numpy.py file. Key modifications include flattening nested lists into a single array during tensor initialization, streamlining the load method by removing unnecessary checks, enhancing the __getitem__ method for clarity in slicing, and refining the concatenate method for better error handling. Additionally, adjustments were made to the benchmarking configuration in the .github/workflows/benchmark.yaml file, altering alert thresholds and failure behaviors.

Changes

Files Change Summary
src/nested_ragged_tensors/ragged_numpy.py Simplified initialization by flattening nested lists, streamlined load, modified __getitem__ for clarity, refined concatenate for error handling.
.github/workflows/benchmark.yaml Adjusted benchmarking job configuration by lowering alert threshold and changing failure behavior.

Assessment against linked issues

Objective Addressed Explanation
Tensors should not be split into lists of lists until densification (#21)

Poem

In the land of tensors, so deep and wide,
A rabbit hops forth with changes to guide.
Flattened arrays, oh what a delight,
Slicing and loading, all done just right!
With clearer paths and errors in sight,
Our code now dances, oh what a sight! 🐇✨


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.
    • @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

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1b41e1b and b8df7c0.

Files selected for processing (1)
  • src/nested_ragged_tensors/ragged_numpy.py (11 hunks)
Additional context used
Ruff
src/nested_ragged_tensors/ragged_numpy.py

555-558: Use ternary operator vals_end = offset if len(B) == 0 else B[-1] + offset instead of if-else-block

Replace if-else-block with vals_end = offset if len(B) == 0 else B[-1] + offset

(SIM108)

Additional comments not posted (6)
src/nested_ragged_tensors/ragged_numpy.py (6)

90-90: LGTM!

The changes simplify the initialization of tensors by flattening nested lists into a single array, which reduces complexity in the data structure and allows for a more straightforward inference of data types. The changes are consistent with the summary provided.


255-255: LGTM!

The changes simplify the handling of nested ragged tensors during initialization. Flattening the values before processing reduces complexity and the need for intermediate data structures. The changes are consistent with the summary provided.

Also applies to: 257-257, 271-271


320-321: LGTM!

The changes simplify the loading of tensors by removing unnecessary checks for meta keys, which leads to a more direct assignment of tensor values. The changes are consistent with the summary provided.


525-525: LGTM!

The changes simplify the logic for determining start and end indices during slicing operations. The bounds are correctly applied without redundant calculations, improving efficiency. The changes also enhance the clarity of the slicing logic. The changes are consistent with the summary provided.

Also applies to: 550-559, 560-564


983-991: LGTM!

The changes improve the error handling during concatenation operations. Clearer feedback is provided when concatenation fails, making it easier to diagnose issues. The changes are consistent with the summary provided.


1105-1105: LGTM!

The changes simplify the load_slice method by removing the split operation. The values are directly assigned instead, reducing unnecessary processing. The changes are consistent with the summary provided.

src/nested_ragged_tensors/ragged_numpy.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.49%. Comparing base (1b41e1b) to head (f2e0466).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/nested_ragged_tensors/ragged_numpy.py 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
- Coverage   92.77%   92.49%   -0.28%     
==========================================
  Files           2        2              
  Lines         332      333       +1     
==========================================
  Hits          308      308              
- Misses         24       25       +1     

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

@mmcdermott
Copy link
Owner Author

This currently causes a significant reduction in overall speed, and, unexpectedly (and unimportantly) a degradation in preparation time:
image
I'll try some different ways to densify the data.

Copy link

@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: 1

Outside diff range and nitpick comments (2)
.github/workflows/benchmark.yaml (2)

38-38: Monitor the impact of the lower alert threshold.

Lowering the alert-threshold to "150%" can help detect performance regressions more quickly. However, it may also increase the number of false positives if the performance fluctuates due to factors unrelated to the code changes. Consider monitoring the impact of this change and adjusting the threshold if needed to strike a balance between early detection and reducing false positives.


40-40: Implement a process to review and address performance alerts.

Setting fail-on-alert to false allows the job to complete even if performance regressions are detected, enabling further analysis or manual intervention. However, it's important to implement a process to review and address the alerts generated by the job to ensure that performance regressions are not overlooked. Consider establishing a workflow to regularly monitor the alerts, investigate the causes, and take appropriate actions to maintain the desired level of performance.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b5f3c44 and f687e9e.

Files selected for processing (1)
  • .github/workflows/benchmark.yaml (2 hunks)

.github/workflows/benchmark.yaml Show resolved Hide resolved
This reverts commit b5f3c44. This change, despite using more numpy specific logic, had major negative consequences on overall performance.
@mmcdermott
Copy link
Owner Author

Skipping the subdivision into lists and also not using np.put is apparently the best version of this change.

@mmcdermott mmcdermott merged commit 3f0ed97 into main Sep 12, 2024
8 checks passed
@mmcdermott mmcdermott deleted the 21_split_later branch September 12, 2024 19:00
@coderabbitai coderabbitai bot mentioned this pull request Oct 10, 2024
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.

Tensors should not be split into lists of lists until densification.
2 participants