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

Support for NestedTensors #185

Open
jaanli opened this issue Mar 5, 2024 · 3 comments
Open

Support for NestedTensors #185

jaanli opened this issue Mar 5, 2024 · 3 comments
Labels
feature New feature question User queries

Comments

@jaanli
Copy link

jaanli commented Mar 5, 2024

Currently NestedTensors give errors (examples - https://pytorch.org/tutorials/prototype/nestedtensor.html and https://pytorch.org/docs/stable/nested.html)

File <@beartype(models.transformer.Attention.forward) at 0x7f7ac394d430>:23, in forward(__beartype_object_221882800, __beartype_get_violation, __beartype_conf, __beartype_object_140169208358272, __beartype_object_140169211732352, __beartype_func, *args, **kwargs)
...
RuntimeError: Internal error: NestedTensorImpl doesn't support sizes. Please file an issue.

Just an idea, could be helpful for more folks! :) this library has already saved me from many bugs btw 🙏

@patrick-kidger
Copy link
Owner

Thank you for your kind words!

Honestly, I'm not sure how nested tensors would work with something like jaxtyping. They don't have rectangular shapes, after all. Do you have a suggestion?

@jaanli
Copy link
Author

jaanli commented Mar 6, 2024

Currently the library supports a wildcard operator (e.g. Float[Tensor, "*batch seqlen"]) to denote variable-length dimensions.

NestedTensors have "ragged" dimension-like analogs.

I don't think support is necessary at this point, but if a library like Nested Tensors from PyTorch ends up popular perhaps a similar wildcard like ~ could be used to indicate ragged dimensions?

@patrick-kidger
Copy link
Owner

Probably something like the existing _ may suffice, indicating a dimension that isn't checked.
IIUC nested tensors can be nested inside themselves though, so practically speaking I think you end up entirely forfeiting any notion of an 'overall array shape'.

@patrick-kidger patrick-kidger added feature New feature question User queries labels Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature question User queries
Projects
None yet
Development

No branches or pull requests

2 participants