-
Notifications
You must be signed in to change notification settings - Fork 59
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
Task outputting Torch.Tensor now errors (reports having no out attribute) #767
Comments
@wilke0818 - the following change seems sufficient for this test to pass (together with the register_serializer). @pydra.mark.task
@pydra.mark.annotate({"return": {"out": torch.Tensor}})
def pydra_task(test_input: torch.Tensor) -> torch.Tensor:
"""Task function for Pydra workflow to run."""
return test_input + 2 some more info, which seems to indicate how using without annotate: In [41]: foo = pydra_task()
In [42]: foo.output_spec
Out[42]: SpecInfo(name='Tensor', fields=[('_is_param', <class 'bool'>)], bases=(<class 'pydra.engine.specs.BaseSpec'>,)) with annotate: In [46]: foo = pydra_task()
In [47]: foo.output_spec
Out[47]: SpecInfo(name='Output', fields=[('out', <class 'torch.Tensor'>)], bases=(<class 'pydra.engine.specs.BaseSpec'>,)) in comparison using In [48]: import pydra
...: import torch
...:
...:
...: @pydra.mark.task
...: def pydra_task(test_input: np.array) -> np.array:
...: """Task function for Pydra workflow to run."""
...: return test_input + 2
...:
In [49]: foo = pydra_task()
In [50]: foo.output_spec
Out[50]: SpecInfo(name='Output', fields=[('out', <built-in function array>)], bases=(<class 'pydra.engine.specs.BaseSpec'>,)) |
this code chunk is the reason why it behaves differently for numpy and torch: Line 175 in d674840
the @tclose - why do we assume that any object with annotations provides a meaningful signature for outputs? was there something you came across that provided this? |
@tclose - this was the original commit: 7265a37 if you don't remember why, i can try a hack before the new syntax is merged. one of our packages ran into this issue, which is why @wilke0818 posted this. there is a workaround for the moment, but looking forward to the new syntax, hopefully we can get it merged soon. |
No sorry, I can't remember my thinking behind that one. Looks like I was just re-enabling something I thought would work after the refactor to use FileFormats. I am just working through the unittests for my PR now, so hoping to have a prototype ready to check out soon, so if you have a short term fix that sounds like a good idea |
What version of Pydra are you using?
0.25.0
Of importance (we believe): this issue comes from upgrading torch to 2.6.0
What were you trying to do?
Use Pydra with torch.Tensors in tasks (splitting list of tensors to functions that input and output individual tensors).
What did you expect will happen?
Test to pass.
What actually happened?
Test no longer passes and errors with:
AttributeError: Task 'test_task_task' has no output attribute 'out', available: '_is_param', 'all_'
Example code:
Expected: Pass the test
Actual:
Note: based on #761 this code might be needed for the test to pass:
The text was updated successfully, but these errors were encountered: