fix: Allow model to output torch.tensor#2234
Merged
Merged
Conversation
Adressed aspects of #941 # further problems 1) Unsqueeze not in array API spec, we should use expand_dims, but torch does not implement this (pytorch/pytorch#56774). We can use reshape instead. 2) What to do with torch.functional? We would have to reimplent these to make it work. We have a few cases of torch.compile. Which are called every time the function is called. They seem to have been added by @orionw, do we expect that these speed this up (they are compiled every time the function is called)
Samoed
reviewed
Mar 4, 2025
Samoed
reviewed
Mar 4, 2025
Contributor
Author
|
@orionw would love your opinion here on the compiled functions. This would, e.g., allow us to e.g. replace
which allow for both torch tensor and numpy arrays |
Contributor
|
I am not sure why they are compiled every time, they should be compiled once. I added it because on tasks with lots to normalize it was about a 10x speedup. We can remove it for simplicity, but is is much much faster. |
Contributor
Author
|
Hmm, that is good to know. I will keep it, at least for now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adressed aspects of #941 by allowing model.encode to return a torch.tensor.
Also does a lot of fixes to array typing.
further problems
expand_dimspytorch/pytorch#56774). We can use reshape instead.We have a few cases of torch.compile. Which are called every time the function is called. They seem to have been added by @orionw, do we expect that these speed this up (they are compiled every time the function is called)
Code Quality
make lintto maintain consistent style.Documentation
Testing
make test-with-coverage.make testormake test-with-coverageto ensure no existing functionality is broken.