-
Notifications
You must be signed in to change notification settings - Fork 60
Create nvfuser_next extension #4156
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
Conversation
Review updated until commit 2266039 Description
Changes walkthrough 📝
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Context? How is this related to the existing python api in csrc? |
TL;DR: Direct bindings API maps directly to CPP Fusion objects. It doesn't rely on the I've been working on a prototype for direct bindings. #4077 This PR is the first to start integrating the changes into main. Full design doc: https://docs.google.com/document/d/1ftdNKu952EFmLANa36g0IrVaqAJ0eLKzgJESkQFnuVI/edit?usp=sharing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I am suggesting that we modify this to appear as we would want it for a new Python API. Therefore, there should not be a reference to "direct" in the code as a user would not care. The main changes I am suggesting is to change the direct from |
23b5223
to
ccad78d
Compare
!test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Should we also add a python test file to verify the import would work?
codegen_internal | ||
Python::Module | ||
) | ||
install(TARGETS nvfuser_next DESTINATION lib) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my nitpick on this PR is that, we would want to avoid duplicate the code that's shared between the two pybind module.
I'm also leaning towards moving this down to the ./python/CMakeLists.txt
.
But we don't have to do that in this PR. We can leave that as a follow up clean PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you want to move to .python/CMakeLists.txt
?
Build engineer is on the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just simply for logic separation.
If I'm adding another python module. I don't need to see the entire build files for nvfuser core lib.
ext_modules=[ | ||
Extension(name="nvfuser._C", sources=[]), | ||
Extension(name="nvfuser_next._C_NEXT", sources=[]), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 I like how clean & easy the setup part is.
pytorch_lib_dir = os.path.join(os.path.dirname(torch.__file__), "lib") | ||
if pytorch_lib_dir not in sys.path: | ||
sys.path.append(pytorch_lib_dir) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naive question. Are we expecting people to import both nvfuser and nvfuser_next?
The way things are imported makes me worried about name conflicts.
i.e. should we assert on not seeing nvfuser in sys.modules
when importing nvfuser_next?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we expecting people to import both nvfuser and nvfuser_next?
No.
should we assert on not seeing nvfuser in sys.modules when importing nvfuser_next?
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jjsjann123 I added assertions to nvfuser/__init__.py
and nvfuser_next/__init__.py
and python tests to check for the conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
!test |
I created |
This PR creates a new Pybind11 extension for the direct bindings API. The bindings does not have any functionality.
Key Build Details:
PYTHON_NEXT_EXTENSION=_C_NEXT
.libnvfuser_next.so
nvfuser_next
.