Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support reconstructing CUDA event object within Dynamo graph (#133635)
Summary: `torch.cuda.Event` objects are different from `torch.cuda.Stream` in that events are not pooled, meaning we can't look up a previously created CUDA event object by ID. This prevents CUDA event object created outside of the Dynamo graph from being used within the graph (since Dynamo needs a way to emit a `call_function` line in the graph that does the retrieval of the event object for downstream op use). This PR adds a simple object pool within Dynamo utility, to support looking up CUDA event object by ID from within the Dynamo graph. After this PR, if a user creates a CUDA event object outside of the graph and use that event within the graph, the behavior will exactly match eager. Test commands: - `pytest -rA test/dynamo/test_ctx_manager.py::CtxManagerTests::test_cuda_event_created_outside_of_graph` - `pytest -rA test/dynamo/test_ctx_manager.py::CtxManagerTests::test_cuda_event_across_graph_break` X-link: pytorch/pytorch#133635 Approved by: https://github.com/yifuwang ghstack dependencies: #133532, #133531, #133636 Reviewed By: jeanschmidt Differential Revision: D61432589 Pulled By: yf225 fbshipit-source-id: 6d168c84d80b8f086b90b6a506e7778e66b0d80e
- Loading branch information