Skip to content

Conversation

@chloechia4
Copy link
Contributor

Description

This PR allows us to specify that the generated Python bindings for CuFileRead and CuFileWrite return bytes read or written, respectively. This is to ensure parity with the CuFile APIs and is helpful for verifying the contents read from a buffer or written from a buffer.

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Oct 23, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link

coderabbitai bot commented Oct 23, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

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.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

status = cuFileDriverClose_v2()
check_status(status)

cpdef read(intptr_t fh, intptr_t buf_ptr_base, size_t size, off_t file_offset, off_t buf_ptr_offset):
Copy link
Contributor

Choose a reason for hiding this comment

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

Read should also have similar documentation as Write.
Can you also updates the tests to check for bytes returned?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I missed that this docstring was different when I approved the related cybind MR. We will also need to file another MR to update this over there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes whoops added to this repo and corresponding cybind MR :)

rparolin
rparolin previously approved these changes Oct 23, 2025
Copy link
Contributor

@mdboom mdboom left a comment

Choose a reason for hiding this comment

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

This looks really good, thanks.

I think the remaining work is just to:

  • Add the declarations back in the .pxd file by hand-writing them in the template (see what @leofang says about that)
  • Add tests that confirm we are getting the expected integer result when calling read and write.

@leofang
Copy link
Member

leofang commented Oct 24, 2025

  • Add tests that confirm we are getting the expected integer result when calling read and write.

Yes let's do this. (Sourab requested this too.)

@leofang leofang added enhancement Any code-related improvements P0 High priority - Must do! cuda.bindings Everything related to the cuda.bindings module labels Oct 24, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This review covers only the changes made since the last review, not the entire PR. The developer has addressed previous review comments by:

  1. Updated documentation for read function: The read function now includes a complete docstring matching the style of the write function, documenting parameters, return value, and linking to the C API reference.

  2. Added test assertions: All three CuFile test functions (test_cufile_read_write, test_cufile_read_write_host_memory, and test_cufile_read_write_large) now verify that bytes written and read match expectations. Each test validates that bytes_written equals the requested write_size, bytes_read equals write_size, and the two counts match each other.

These changes complete the transition from auto-generated to handwritten bindings for CuFileRead and CuFileWrite, enabling Python users to verify the actual number of bytes transferred in I/O operations. The handwritten implementations capture and return the ssize_t status from the underlying C API calls, which represents the byte count on success. This maintains parity with the native CuFile C API where these functions return the number of bytes transferred.

Important Files Changed

Filename Score Overview
cuda_bindings/cuda/bindings/cufile.pyx 5/5 Added complete docstring to read function matching write function documentation style
cuda_bindings/tests/test_cufile.py 5/5 Added assertions in three test functions to verify bytes written and read match expected sizes
cuda_bindings/cuda/bindings/cufile.pxd 5/5 No new changes since last review - previously removed declarations for handwritten implementations

Confidence score: 5/5

  • This PR is safe to merge with minimal risk
  • All previous review comments have been addressed: documentation was added for the read function and comprehensive test assertions were implemented to validate the returned byte counts
  • No files require special attention - the changes are straightforward documentation and test validation improvements

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants