-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Bug]: Pytorch RunInference PredictionResult is a Dict #22240
Comments
.take-issue |
Subtask of #22117 |
#22979 got created as an accidental duplicate. I'm closing that one, but copying over the description since I think it has some extra additional context: Originally documented here in our RunInference Troubleshooting section: For some models, the PredictionResults output might not include the correct predictions in the inferences field. This issue occurs when you use a model whose inferences return a dictionary that maps keys to predictions and other metadata. An example return type is The RunInference API currently expects outputs to be an To work with the current RunInference implementation, you can create a wrapper class that overrides the model(input) call. In PyTorch, for example, your wrapper would override the forward() function and return an output with the appropriate format of |
Thanks @damccorm! We should also remove (or at least clarify) the section on this issue from our Troubleshooting guide. I had intended to make this comment in the PR yesterday, but forgot, and just remembered. 😄 |
That's a good callout - I'll reopen here. Since this fix won't be released for ~2 months (it missed the 2.42 cut), we should probably hold off on doing that until then. |
#23152 will close this once its merged (after the 2.43 release) |
What happened?
The return value of the
forward
call for many models is a dictionary with the predictions along with more metadata. i.e.Dict[str, Tensor]
. However, RunInference currently expects outputs to be anIterable[Any]
. i.e.Iterable[Tensor]
orIterable[Dict[str, Tensor]]
. So when RunInference zips the inputs with the predictions, the predictions iterate over the dictionary keys instead of the batch elements. So we end up with only the key name and actual prediction Tensors are discarded. This results in an unusablePredictionResult
.The PredictionResult challenge is a known quirk due to the current design/implementation of RunInference. We have a sample that does something similar by creating a wrapper class. We should support both tensors and dictionary of tensors. Currently, it only works for the former, and that is baked into the logic. We should figure out how to natively support results that are a dict type.
Issue Priority
Priority: 2
Issue Component
Component: sdk-py-core
The text was updated successfully, but these errors were encountered: