Skip to content

Commit 59b8d3b

Browse files
committed
removing the try except block in examples
1 parent 109e5c2 commit 59b8d3b

File tree

3 files changed

+21
-40
lines changed

3 files changed

+21
-40
lines changed

examples/distributed_inference/tensor_parallel_rotary_embedding.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
"""
3030
This example covers the rotary embedding in Llama3 model and is derived from https://lightning.ai/lightning-ai/studios/tensor-parallelism-supercharging-large-model-training-with-pytorch-lightning
31-
Command to run with single GPU: mpirun -n 1 --allow-run-as-root python tensor_parallel_rotary_embedding.pyx
31+
Command to run with single GPU: mpirun -n 1 --allow-run-as-root python tensor_parallel_rotary_embedding.py
3232
"""
3333

3434
BATCH = 2
@@ -49,22 +49,11 @@
4949

5050
model = torch.compile(model, backend="torch_tensorrt")
5151

52-
try:
53-
for i in range(15):
54-
# seeding with dp_rank to ensure identical inputs for TP groups
55-
torch.manual_seed(i)
56-
start = time.time()
57-
output = model(x)
58-
end = time.time()
59-
if i == 0:
60-
logger.info(f"Compilation time is {end-start}")
61-
assert (
62-
python_result - output
63-
).std() < 0.01, "Compilation result is not correct."
64-
elif _rank == 0:
65-
logger.info(f"Inference time is {end-start}")
66-
except Exception as e:
67-
logger.error(f"Error: {e}")
68-
raise e
69-
finally:
70-
cleanup_distributed_env()
52+
torch.manual_seed(0)
53+
start = time.time()
54+
output = model(x)
55+
end = time.time()
56+
logger.info(f"Compilation time is {end-start}")
57+
assert (python_result - output).std() < 0.01, "Compilation result is not correct."
58+
59+
cleanup_distributed_env()

examples/distributed_inference/tensor_parallel_simple_example.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,15 @@ def forward(self, x):
103103
dynamic=None,
104104
)
105105

106-
try:
107-
for i in range(10):
108-
# For TP, input needs to be same across all TP ranks.
109-
# Setting the random seed is to mimic the behavior of dataloader.
110-
torch.manual_seed(i)
111-
inp = torch.rand(20, 10, device="cuda")
112-
start = time.time()
113-
output = tp_model(inp)
114-
end = time.time()
115-
if i == 0:
116-
logger.info(f"Compilation time is {end-start}")
117-
assert (
118-
python_result - output
119-
).std() < 0.01, "Compilation result is not correct."
120-
elif _rank == 0:
121-
logger.info(f"Inference time is {end-start}")
122-
finally:
123-
# This cleans up the distributed process group
124-
cleanup_distributed_env()
106+
# For TP, input needs to be same across all TP ranks.
107+
# Setting the random seed is to mimic the behavior of dataloader.
108+
torch.manual_seed(0)
109+
inp = torch.rand(20, 10, device="cuda")
110+
start = time.time()
111+
output = tp_model(inp)
112+
end = time.time()
113+
logger.info(f"Compilation time is {end - start}")
114+
assert (python_result - output).std() < 0.01, "Result is not correct."
115+
116+
# This cleans up the distributed process group
117+
cleanup_distributed_env()

tests/py/dynamo/lowering/test_aten_lowering_passes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ def forward(self, x):
313313
inputs,
314314
min_block_size=1,
315315
pass_through_build_failures=True,
316-
debug=True,
317316
)
318317
optimized_model_results = optimized_model(*inputs)[0].detach().cpu()
319318
torch_model_results = model(*inputs)[0].detach().cpu()

0 commit comments

Comments
 (0)