-
Notifications
You must be signed in to change notification settings - Fork 112
Passing arguments through iron.jit decorator #2213
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
I like this! |
programming_examples/basic/vector_vector_add/vector_vector_add.py
Outdated
Show resolved
Hide resolved
programming_examples/basic/vector_vector_add/vector_vector_add_placed.py
Outdated
Show resolved
Hide resolved
I don't think this will work, unfortunately. The operator Lines 83 to 103 in d291a69
|
I like the |
You mean because of the |
Particularly for the device, I think it's best if we do things like: @iron.jit
def kernel()
device = iron.get_current_device()
iron.set_device(device) Or via contexts: @iron.jit
def kernel()
device = iron.get_current_device()
with iron.device('npu'):
kernel() But it's likely we will need to pass more arguments to the kernel that we can't set as globals. We could possibly start adding annotations (e.g., I think it's best if we just meet and discuss to keep the momentum going. |
Sounds good to me |
I can see us controlling not just which device, but how many tiles to use etc. Which I think makes it equivalent to what numba does with kernel invocation (https://numba.readthedocs.io/en/stable/cuda/kernels.html). But I'd like us to think what's appropriate for our devices, not how the GPU world converged around CUDA. |
7dacfb7
to
f6b8e2a
Compare
programming_examples/basic/vector_vector_add/vector_vector_add.py
Outdated
Show resolved
Hide resolved
programming_examples/basic/vector_vector_add/vector_vector_add.py
Outdated
Show resolved
Hide resolved
programming_examples/basic/vector_vector_add/vector_vector_add_placed.py
Outdated
Show resolved
Hide resolved
programming_examples/basic/vector_vector_add/vector_vector_add_placed.py
Outdated
Show resolved
Hide resolved
I like the syntax of I also like your |
Here's how numba does it: https://numba.pydata.org/numba-doc/dev/roc/examples.html Triton: https://triton-lang.org/main/getting-started/tutorials/03-matrix-multiplication.html#sphx-glr-getting-started-tutorials-03-matrix-multiplication-py (I think they infer the device from the inputs). In triton, functions with |
Here's the separation I have in my head:
The distinction between 2 and 3 is that 2 has to do with the code that follows (think of C++ strong typing) whereas 3 is more on where and how that code will be called. |
6ad02a4
to
e69c83e
Compare
I added a |
|
😄 5737615 |
This is looking awesome, thanks Yiannis for the improvements. And thanks for fixing the tensor random initialization bug too. I suggest adding one comment on why the column id is 0 in the code for the readers (I didn't know about that). Other than that, the PR is looking great. |
programming_examples/basic/vector_vector_add/vector_vector_add_placed.py
Show resolved
Hide resolved
Agreed! |
dev = NPU2() | ||
|
||
# Define tensor types | ||
# Define tensor shape | ||
data_height = 3 |
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.
This is something I haven't yet figured out. The tensors are 1D, yet they are described as 2D here, and I don't have a mechanism to pass additional arguments.
This is something we discussed today with @SamuelBayliss and @erwei-xilinx for a different use-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.
I think the pointer is the only thing that really matters. My understanding is that the tensor shape is only used for a verifier, checking whether the wrap-and-stride access pattern goes out of bound. The amount of data being copied is coded in TensorAccessPattern
's sizes.
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.
Still, we lack the mechanism to pass this information in. Another example would be if you have a function that can generate vector-add or vector-sub using one extra argument. It can't be part of the arguments, since those are supposed to be tensors only. How do we pass that in?
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
758cd3e
to
14fd5ff
Compare
Co-authored-by: Muhammad Awad <112003944+mawad-amd@users.noreply.github.com>
Co-authored-by: Yiannis Papadopoulos <Yiannis.Papadopoulos@amd.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Muhammad Awad <112003944+mawad-amd@users.noreply.github.com>
What's the comment here? 0 implies runtime figures out placement? @jgmelber |
I thought column_id was removed? |
It did, I'm just asking if an additional comment is needed. |
I don't think so |
programming_examples/basic/vector_vector_add/vector_vector_add_placed.py
Show resolved
Hide resolved
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.
Thanks, Yiannis!
This PR allows to pass arguments through the
iron.jit
decorator to the called function.Closes #2211