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 60 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
@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

@leofang
Copy link
Member

leofang commented Jan 8, 2025

one was an optional suggestion and one was a question.

Oh it's more than that 😛 You need to scroll up and unfold all the hidden comments (GH folds them if too many):

截圖 2025-01-08 上午10 54 24

@ksimpson-work
Copy link
Contributor Author

Thanks fcor pointing that out, and for the very in depth review which helped me find a couple issues as well as general improvements. I believe everything has now been addressed

/ok to test

@ksimpson-work
Copy link
Contributor Author

/ok to test

"""
Check if the given object is a sequence (list or tuple).
"""
return isinstance(obj, (list, tuple))
Copy link
Member

Choose a reason for hiding this comment

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

Q: Couldn't we just use isinstance(obj, Sequence) here?

Copy link
Contributor Author

@ksimpson-work ksimpson-work Jan 11, 2025

Choose a reason for hiding this comment

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

no because a string is a sequence. That's what I originally wanted to do

Copy link
Member

Choose a reason for hiding this comment

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

This was why I left #237 (comment) and #237 (comment) above. str is a nested sequence by our definition, because any of its elements is also a str. If we check isinstance(something, str) first to special case it, the remaining checks can be simplified and not specialized for any known container (list/tuple).

"""
Check if the given object is a nested sequence (list or tuple with atleast one list or tuple element).
"""
return is_list_or_tuple(obj) and any(is_list_or_tuple(elem) for elem in obj)
Copy link
Member

Choose a reason for hiding this comment

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

ditto, also, it should be all:

Suggested change
return is_list_or_tuple(obj) and any(is_list_or_tuple(elem) for elem in obj)
return is_list_or_tuple(obj) and all(is_list_or_tuple(elem) for elem in obj)

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 think perhaps I should take this out of utils and leave it in program if it is too specific, but to handle the case in question it should be any imo, since I would like to support define_macro = ("MY_MACRO", ("MY_OTHER_MACRO", 99))

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