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

Adding a dependency on PyTorch #57

Open
sogartar opened this issue Dec 11, 2024 · 5 comments
Open

Adding a dependency on PyTorch #57

sogartar opened this issue Dec 11, 2024 · 5 comments
Labels
question Further information is requested

Comments

@sogartar
Copy link

Is it acceptable that some tests have a dependency on PyTorch? There is the problem that NumPy does not have support for bfloat16.
Now I mostly want this to convert a blfoat16 IREE buffer view to float32.
You may want to operate on bfloat16 tensors without conversion.

@ScottTodd
Copy link
Member

Yes, though I would prefer for such tests to be scoped to a pytorch_ folder, like how onnx tests are in the onnx_ folders. See also #17 for setting up tests, with some sample code ideas.

If you just want utilities for working with data types, I'd prefer to not take a dependency on a full ML framework just for that.

@ScottTodd ScottTodd added the question Further information is requested label Dec 11, 2024
@ScottTodd
Copy link
Member

Also depending on what you want, you can follow a similar pattern to the onnx op tests. Those depend on onnx for test case generation, writing out .bin files with inputs and expected outputs so the generated tests can be run using standard IREE tools with no framework dependency.

@rsuderman
Copy link
Contributor

Its not firm but I would recommend sticking to numpy if possible. We can pretty easily convert bfloat16 to float32 just by bit extending and shifting. The main justification is that the CI time is dominated by pytorch installation if we include it.

@sogartar
Copy link
Author

@ScottTodd, thank you for the suggestion. The comparison function I want to use is the cosine similarity per token of the returned features from a text encoder. An element-wise closeness comparison would not be good enough.

The other option is to have a second IREE module to compute the cosine similarity that would return float32. This does not seem right to me to use an IREE module to test IREE's execution of a module.

We can pretty easily convert bfloat16 to float32 just by bit extending and shifting.

@rsuderman, I assume we can achieve this with NumPy by treating the value as int. I will write this function then.

@sogartar
Copy link
Author

sogartar commented Dec 11, 2024

I opened an issue regarding the possibility of interop between the IREE Python bindings and dtypes from ml_dtypes.

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

No branches or pull requests

3 participants