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 experimental code for custom attention op #81

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

Conversation

NatashaKnk
Copy link

This code can (and should) be expanded upon, and would ideally be integrated in the IREE-Jax workflow. At the moment the workflow is broken since Jaxlib has removed ml_program from their Python deps, so I created a new folder for work that doesn't quite fit anywhere.
This is followed by an IREE-side PR that lowers this custom op to IREE attention.

At the moment this is a 1:1 mapping to the IREE version of the op, but it can be expanded upon as needed.

iree_attention_p = core.Primitive('iree_attention')
iree_attention_p.def_impl(partial(dispatch.apply_primitive, iree_attention_p))

transpose_v = False
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a global here?

input_shapes = [
jax.ShapeDtypeStruct(input.shape, input.dtype) for input in inputs
]
att = export.export(
Copy link
Member

Choose a reason for hiding this comment

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

Should this be some generic IREE export somewhere? E.g., have list of "allowed for IREE export" custom calls listed somwehere. Then one always does iree.jax.export instead of jax.experimental.export.

######################


def iree_attention(
Copy link
Member

Choose a reason for hiding this comment

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

Is this the one users would then call explicitly? So one needs to change the model to use it? (potentially wrapped inside some function which dispatches either to the IREE one or a generic one so that they could still test without IREE)

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