Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reproducer tests: grab output/error, and use the correct python #1554

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions thunder/tests/test_dynamo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import warnings
import itertools
import os
from subprocess import run
import subprocess
import sys
import torch
import torch.fx
import torch.nn as nn
Expand Down Expand Up @@ -819,12 +820,16 @@ def func(x):
s2 = f"{tmp_path}/graph1_thunder_0.py"
assert os.path.exists(s1)
assert os.path.exists(s2)
cmd = "pytest" if use_pytest_benchmark else "python"
result1 = run([cmd, s1], capture_output=True, text=True)
result2 = run([cmd, s2], capture_output=True, text=True)
cmd = [sys.executable]
if use_pytest_benchmark:
cmd = cmd + ["-m", "pytest"]
cmd1 = cmd + [s1]
cmd2 = cmd + [s2]
result1 = subprocess.run(cmd1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
result2 = subprocess.run(cmd2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)

assert result1.returncode == 0, f"Reproducer {s1} failed with return code {result1.returncode}"
assert result2.returncode == 0, f"Reproducer {s2} failed with return code {result2.returncode}"
assert result1.returncode == 0, f"Reproducer {s1} failed: {result1}"
assert result2.returncode == 0, f"Reproducer {s2} failed: {result2}"


@requiresCUDA
Expand Down Expand Up @@ -852,9 +857,12 @@ def forward(self, x):

s1 = f"{tmp_path}/graph0_thunder_0.py"
assert os.path.exists(s1)
cmd = "pytest" if use_pytest_benchmark else "python"
result1 = run([cmd, s1], capture_output=True, text=True)
assert result1.returncode == 0, f"Reproducer {s1} failed with return code {result1.returncode}"
cmd = [sys.executable]
if use_pytest_benchmark:
cmd = cmd + ["-m", "pytest"]
cmd1 = cmd + [s1]
result1 = subprocess.run(cmd1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
assert result1.returncode == 0, f"Reproducer {s1} failed: {result1}"


def test_deepcopy_graph_module():
Expand Down Expand Up @@ -909,13 +917,16 @@ def func(x):

def check(file_name, cmd):
assert os.path.exists(file_name)
result = run([cmd, file_name], capture_output=True, text=True)
assert result.returncode == 0, f"Reproducer {file_name} failed with return code {result.returncode}"
cmd = cmd + [file_name]
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
assert result.returncode == 0, f"Reproducer {file_name} failed: {result}"

s1 = f"{tmp_path}/graph0_thunder_0.py"
s2 = f"{tmp_path}/graph0_thunder_2.py"
s3 = f"{tmp_path}/graph0_thunder_4.py"
cmd = "pytest" if use_pytest_benchmark else "python"
cmd = [sys.executable]
if use_pytest_benchmark:
cmd = cmd + ["-m", "pytest"]
for fname in [s1, s2, s3]:
check(fname, cmd)

Expand Down
Loading