Repository navigation
Conversation
While we figure out the random plan, I want to initially disable support for random operations. This is because there is an ambiguity in what randomness means. For example, ``` tensor = torch.zeros(B0, 1) vmap(lambda t: t.normal_())(tensor) ``` in the above example, should `tensor[0]` and `tensor[1]` be equal (i.e., use the same random seed), or should they be different? The mechanism for disabling random support is as follows: - we register a batching rule that throws an error - for any future (out-of-place) random operations, the fallback path will probably catch them and throw an error. I want to disable random factory functions as well, but I haven't figured out how to do that yet. (e.g., torch.rand, torch.randn). That will come next. Test Plan: - `pytest test/test_vmap.py -v -k "Operators"` [ghstack-poisoned]
While we figure out the random plan, I want to initially disable support for random operations. This is because there is an ambiguity in what randomness means. For example, ``` tensor = torch.zeros(B0, 1) vmap(lambda t: t.normal_())(tensor) ``` in the above example, should `tensor[0]` and `tensor[1]` be equal (i.e., use the same random seed), or should they be different? The mechanism for disabling random support is as follows: - we register a batching rule that throws an error - for any future (out-of-place) random operations, the fallback path will probably catch them and throw an error. I want to disable random factory functions as well, but I haven't figured out how to do that yet. (e.g., torch.rand, torch.randn). That will come next. Test Plan: - `pytest test/test_vmap.py -v -k "Operators"` ghstack-source-id: 5867be5 Pull Request resolved: #42324
| schema.arguments().begin(), | ||
| schema.arguments().end(), | ||
| [] (const Argument& arg) { | ||
| // Check for Generator or Optional<Generator>. |
There was a problem hiding this comment.
If someone ever adds list of generators I will eat my shoe.
| template <typename... Args> Tensor& unsupportedRandomOp_(Args... args) { | ||
| TORCH_CHECK(false, "vmap: We do not yet support random operations. Please ", | ||
| "perform random operations outside of vmap as a workaround"); | ||
| } |
There was a problem hiding this comment.
You could do this with marginally less boilerplate by making another magical unsupported boxed kernel, similar to the named tensor not supported kernel. Then it wouldn't be necessary to get the correct type instantiations below. Up to you.
There was a problem hiding this comment.
I'll add that as a follow-up item to investigate. Getting the correct type instantiations is annoying (and potentially fragile if someone updates the schema) so the magical unsupported kernel sounds nice.
| B0 = 2 | ||
| random_ops = [ | ||
| # out-of-place | ||
| (torch.bernoulli, (torch.rand(B0, 1),)), |
There was a problem hiding this comment.
an op database would indeed solve a lot of my testing problems
…ons" While we figure out the random plan, I want to initially disable support for random operations. This is because there is an ambiguity in what randomness means. For example, ``` tensor = torch.zeros(B0, 1) vmap(lambda t: t.normal_())(tensor) ``` in the above example, should `tensor[0]` and `tensor[1]` be equal (i.e., use the same random seed), or should they be different? The mechanism for disabling random support is as follows: - we register a batching rule that throws an error - for any future (out-of-place) random operations, the fallback path will probably catch them and throw an error. I want to disable random factory functions as well, but I haven't figured out how to do that yet. (e.g., torch.rand, torch.randn). That will come next. Test Plan: - `pytest test/test_vmap.py -v -k "Operators"` Differential Revision: [D22846274](https://our.internmc.facebook.com/intern/diff/D22846274) [ghstack-poisoned]
While we figure out the random plan, I want to initially disable support for random operations. This is because there is an ambiguity in what randomness means. For example, ``` tensor = torch.zeros(B0, 1) vmap(lambda t: t.normal_())(tensor) ``` in the above example, should `tensor[0]` and `tensor[1]` be equal (i.e., use the same random seed), or should they be different? The mechanism for disabling random support is as follows: - we register a batching rule that throws an error - for any future (out-of-place) random operations, the fallback path will probably catch them and throw an error. I want to disable random factory functions as well, but I haven't figured out how to do that yet. (e.g., torch.rand, torch.randn). That will come next. Test Plan: - `pytest test/test_vmap.py -v -k "Operators"` ghstack-source-id: 3bf24d9 Pull Request resolved: #42324
…ons" While we figure out the random plan, I want to initially disable support for random operations. This is because there is an ambiguity in what randomness means. For example, ``` tensor = torch.zeros(B0, 1) vmap(lambda t: t.normal_())(tensor) ``` in the above example, should `tensor[0]` and `tensor[1]` be equal (i.e., use the same random seed), or should they be different? The mechanism for disabling random support is as follows: - we register a batching rule that throws an error - for any future (out-of-place) random operations, the fallback path will probably catch them and throw an error. I want to disable random factory functions as well, but I haven't figured out how to do that yet. (e.g., torch.rand, torch.randn). That will come next. Test Plan: - `pytest test/test_vmap.py -v -k "Operators"` Differential Revision: [D22846274](https://our.internmc.facebook.com/intern/diff/D22846274) [ghstack-poisoned]
…ons" While we figure out the random plan, I want to initially disable support for random operations. This is because there is an ambiguity in what randomness means. For example, ``` tensor = torch.zeros(B0, 1) vmap(lambda t: t.normal_())(tensor) ``` in the above example, should `tensor[0]` and `tensor[1]` be equal (i.e., use the same random seed), or should they be different? The mechanism for disabling random support is as follows: - we register a batching rule that throws an error - for any future (out-of-place) random operations, the fallback path will probably catch them and throw an error. I want to disable random factory functions as well, but I haven't figured out how to do that yet. (e.g., torch.rand, torch.randn). That will come next. Test Plan: - `pytest test/test_vmap.py -v -k "Operators"` Differential Revision: [D22846274](https://our.internmc.facebook.com/intern/diff/D22846274) [ghstack-poisoned]
While we figure out the random plan, I want to initially disable support for random operations. This is because there is an ambiguity in what randomness means. For example, ``` tensor = torch.zeros(B0, 1) vmap(lambda t: t.normal_())(tensor) ``` in the above example, should `tensor[0]` and `tensor[1]` be equal (i.e., use the same random seed), or should they be different? The mechanism for disabling random support is as follows: - we register a batching rule that throws an error - for any future (out-of-place) random operations, the fallback path will probably catch them and throw an error. I want to disable random factory functions as well, but I haven't figured out how to do that yet. (e.g., torch.rand, torch.randn). That will come next. Test Plan: - `pytest test/test_vmap.py -v -k "Operators"` ghstack-source-id: 1f3bebd Pull Request resolved: #42324
|
I'm going to hold off on landing this until I figure out #42324 (comment). There's a case where this PR doesn't cover and a dispatcher-approach would (we also want to ban random operations for regular tensors (non-BatchedTensors) inside vmap!) |
|
#42617 supercedes this. |
Stack from ghstack:
While we figure out the random plan, I want to initially disable
support for random operations. This is because there is an ambiguity in
what randomness means. For example,
in the above example, should
tensor[0]andtensor[1]be equal (i.e.,use the same random seed), or should they be different?
The mechanism for disabling random support is as follows:
will probably catch them and throw an error.
I want to disable random factory functions as well, but I haven't
figured out how to do that yet. (e.g., torch.rand, torch.randn). That
will come next.
Test Plan:
pytest test/test_vmap.py -v -k "Operators"Differential Revision: D22846274