Skip to content

Instantly share code, notes, and snippets.

@mlazos
Created September 30, 2025 23:15
Show Gist options
  • Select an option

  • Save mlazos/bcf8c946eec4786690a58c0be813447b to your computer and use it in GitHub Desktop.

Select an option

Save mlazos/bcf8c946eec4786690a58c0be813447b to your computer and use it in GitHub Desktop.
def test_stream_enter_exit(self):
def fn(x, y):
s2 = torch.cuda.Stream()
s1 = torch.cuda.Stream()
with s2:
z1 = torch.add(x, y)
with s1:
z = torch.add(x, y)
y = z + 2 + z1
return y
inp = (torch.ones(2, 2) + 1, torch.ones(2, 2))
expected = fn(*inp)
fn_opt = torch.compile(fn, fullgraph=True)
actual = fn_opt(*inp)
self.assertEqual(expected, actual)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment