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

Add the options data class to program #237

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

ksimpson-work
Copy link
Contributor

@ksimpson-work ksimpson-work commented Nov 13, 2024

close #221

Add the options class to Program.

This comes with a few side effects, namely: There are some modifications to the tests, and the LinkerOptions class now accepts None for arch (using the current device as a default), for consistency between the program options and linker options

Copy link

copy-pr-bot bot commented Nov 13, 2024

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.

Copy link

@warsawnv warsawnv left a comment

Choose a reason for hiding this comment

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

Just some drive-by observations. Feel free to ignore!

cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
@leofang leofang added P1 Medium priority - Should do cuda.core Everything related to the cuda.core module enhancement Any code-related improvements labels Nov 14, 2024
@leofang leofang added this to the cuda.core beta 2 milestone Nov 14, 2024
@leofang
Copy link
Member

leofang commented Nov 14, 2024

Just some drive-by observations. Feel free to ignore!

Thanks, Berry 🙏 We welcome feedbacks and won't ignore anyone!

@leofang
Copy link
Member

leofang commented Nov 14, 2024

Another TODO: Let's also update the code samples and show the best practice!

@warsawnv
Copy link

Another TODO: Let's also update the code samples and show the best practice!

Is there a way to add these as doctests so that the code samples must always be kept in working order?

@ksimpson-work
Copy link
Contributor Author

@warsawnv Totally. I'm actively working on getting github actions working, and the examples are invoked as part of the testsuite.

@ksimpson-work
Copy link
Contributor Author

/ok to test

@ksimpson-work
Copy link
Contributor Author

Other than the default values for some program options, I believe all the comments and issues have been addressed. Thanks for your feedback @warsawnv and @leofang

cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_utils.py Outdated Show resolved Hide resolved
cuda_core/cuda/core/experimental/_program.py Show resolved Hide resolved
@ksimpson-work
Copy link
Contributor Author

Very good point

@ksimpson-work ksimpson-work force-pushed the ksimpson/add_program_options branch from 03128c8 to 6d789cb Compare November 27, 2024 19:20
@leofang leofang removed the P1 Medium priority - Should do label Nov 28, 2024
@leofang
Copy link
Member

leofang commented Jan 5, 2025

/ok to test

Copy link
Member

@leofang leofang left a comment

Choose a reason for hiding this comment

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

Thanks a lot, Keenan! Very comprehensive changes, appreciate the hard work! We are getting there!

I left a final batch of comments, in two categories:

  1. Formatting related to Sphinx: This may require another local sweep to clean up; my suggestions can't cover all files that are touched
  2. Actual code/behavior change: Only a few places. See my comments below.

cuda_core/cuda/core/experimental/_linker.py Outdated Show resolved Hide resolved
cuda_core/docs/source/release.rst Outdated Show resolved Hide resolved
cuda_core/docs/source/release/0.1.0-notes.rst Outdated Show resolved Hide resolved
cuda_core/docs/source/release/0.1.0-notes.rst Outdated Show resolved Hide resolved
cuda_core/docs/source/release/0.1.1-notes.rst Outdated Show resolved Hide resolved
cuda_core/tests/test_linker.py Outdated Show resolved Hide resolved
Comment on lines +21 to +22
if not culink_backend:
from cuda.bindings import nvjitlink
Copy link
Member

Choose a reason for hiding this comment

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

I may have missed something: Why would culink_backend be None? Isn't it using either nvJitLink or driver API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using it as a boolean flag. So it could be false, but not None in this case.

object_code_a_ptx = Program(kernel_a, "c++").compile("ptx", options=("-rdc=true",))
object_code_b_ptx = Program(device_function_b, "c++").compile("ptx", options=("-rdc=true",))
object_code_c_ptx = Program(device_function_c, "c++").compile("ptx", options=("-rdc=true",))
object_code_a_ptx = Program(kernel_a, "c++", ProgramOptions(relocatable_device_code=True)).compile("ptx")
Copy link
Member

Choose a reason for hiding this comment

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

FYI, in case you find it more pleasant than the present form: Our dataclass options can also be initialized by Python dict (by design), so this should also work:

Suggested change
object_code_a_ptx = Program(kernel_a, "c++", ProgramOptions(relocatable_device_code=True)).compile("ptx")
object_code_a_ptx = Program(kernel_a, "c++", {"relocatable_device_code": True}).compile("ptx")

(not saying we should do it here, I'll leave this up to you to decide)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gotcha. I personally like the non-dictionary version, but thanks for letting me know. I did not know that was a possibility

cuda_core/tests/test_program.py Outdated Show resolved Hide resolved
cuda_core/tests/test_program.py Show resolved Hide resolved
@ksimpson-work
Copy link
Contributor Author

/ok to test

@ksimpson-work
Copy link
Contributor Author

/ok to test

@ksimpson-work
Copy link
Contributor Author

/ok to test

@ksimpson-work
Copy link
Contributor Author

/ok to test

@ksimpson-work
Copy link
Contributor Author

/ok to test

@ksimpson-work
Copy link
Contributor Author

last few comments addressed, tests improved and passing

@ksimpson-work ksimpson-work requested a review from leofang January 6, 2025 21:13
@leofang
Copy link
Member

leofang commented Jan 8, 2025

I still see many review comments above not addressed?

@ksimpson-work
Copy link
Contributor Author

one was an optional suggestion and one was a question. I didn't want to makr as resolved so you had a chance to see my response, but there weren't associated code changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking changes are introduced cuda.core Everything related to the cuda.core module enhancement Any code-related improvements P0 High priority - Must do!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Program.compile() options parameter is not handled properly
3 participants