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 attention example in tracing test #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

harsh-nod
Copy link
Contributor

This PR adds an FP8 attention kernel to the
tracing test to validate that it traces correctly.

This PR adds an FP8 attention kernel to the
tracing test to validate that it traces correctly.
Copy link
Contributor

@martin-luecke martin-luecke left a comment

Choose a reason for hiding this comment

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

This is a good demonstrator for how attention could look in TKW.

This needs more iteration and requires features we do not yet support like tuple unpacking.
I think we do not need to have an end-to-end flow as prerequisite to add this tracing test, but we should at least rebase to use the Python operators we have and have a rough plan for supporting the assignments here through expansion + scheduling.

Let's for now convert this to a draft PR

Comment on lines +45 to +46
def div(lhs: "Register", rhs: "Register") -> "Register":
...
Copy link
Contributor

Choose a reason for hiding this comment

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

The predeclarations here do not have CustomOps associated with them
We should map the div here to the Python operator like here. The branch needs to be rebased for that

Comment on lines +354 to +357
# CHECK-NEXT: unknown: sub
# CHECK-NEXT: unknown: sub_1
# CHECK-NEXT: unknown: mul
# CHECK-NEXT: unknown: add
Copy link
Contributor

Choose a reason for hiding this comment

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

These will become proper sub, mul and add after rebasing on main

Comment on lines +320 to +322
# CHECK-NEXT: unknown: getitem
# CHECK-NEXT: unknown: getitem_1
# CHECK-NEXT: unknown: getitem_2
Copy link
Contributor

Choose a reason for hiding this comment

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

These getitem nodes stem from the tuple unpacking here: final_sum, _, final_output = repeat
We should think about how we want to handle these. I think for now it might make sense to intercept tracing for getitem on a CustomOp and emit a getResult op instead.
At least that makes sense in this case where the results of the reduction are accessed. I don't think we want to support this unpacking for general nodes so we should add further checks on when this is valid.

Anyway, I like the syntax you have here. Feels Pythonic to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants