Skip to content

Commit 6cb0c5f

Browse files
committed
And do profiling
Signed-off-by: Edward Z. Yang <ezyang@meta.com> ghstack-source-id: 8385a47 ghstack-comment-id: 3354518075 Pull-Request: #177
1 parent eccf987 commit 6cb0c5f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test_aot_eager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ def test_aot_eager_bitwise_equivalent(llama3_debug_model):
5353
x = torch.randint(0, vocab_size, (batch_size, seqlen), device="cuda")
5454
torch.manual_seed(3999)
5555
r1 = llama3_debug_model(x)
56-
grads1 = torch.autograd.grad(r1.sum(), llama3_debug_model.parameters())
56+
with torch.profiler.profile(with_stack=True) as prof1:
57+
grads1 = torch.autograd.grad(r1.sum(), llama3_debug_model.parameters())
58+
prof1.export_chrome_trace("/tmp/profile/prof1.json")
5759
torch.manual_seed(3999)
5860
r2 = torch.compile(backend="aot_eager")(llama3_debug_model)(x)
59-
grads2 = torch.autograd.grad(r2.sum(), llama3_debug_model.parameters())
61+
with torch.profiler.profile() as prof2:
62+
grads2 = torch.autograd.grad(r2.sum(), llama3_debug_model.parameters())
63+
from torch.fx.traceback import populate_stack_traces_to_kineto_trace
64+
prof2.export_chrome_trace("/tmp/profile/prof2.json")
65+
populate_stack_traces_to_kineto_trace("/tmp/profile/prof2.json")
6066
assert torch.equal(r1, r2) # bitwise equal
6167
for g1, g2 in zip(grads1, grads2):
6268
assert torch.equal(g1, g2)

0 commit comments

Comments
 (0)