From 8074484190b165b7b4e5ea4def9169fe92d754ff Mon Sep 17 00:00:00 2001 From: Tom Fogal <60981+tfogal@users.noreply.github.com> Date: Fri, 13 Dec 2024 08:11:25 -0800 Subject: [PATCH 1/4] reproducer tests: grab output/error. Had a minor issue on my system and needed the actual output to debug what was going wrong. --- thunder/tests/test_dynamo.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/thunder/tests/test_dynamo.py b/thunder/tests/test_dynamo.py index 8f8feca0ab..c5beb69be6 100644 --- a/thunder/tests/test_dynamo.py +++ b/thunder/tests/test_dynamo.py @@ -2,7 +2,7 @@ import warnings import itertools import os -from subprocess import run +import subprocess import torch import torch.fx import torch.nn as nn @@ -820,11 +820,11 @@ def func(x): 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) + result1 = subprocess.run([cmd, s1], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + result2 = subprocess.run([cmd, s2], 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 @@ -853,8 +853,8 @@ 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}" + result1 = subprocess.run([cmd, s1], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + assert result1.returncode == 0, f"Reproducer {s1} failed: {result1}" def test_deepcopy_graph_module(): @@ -909,8 +909,8 @@ 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}" + result = subprocess.run([cmd, file_name], 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" From 04746207675cf73c9f8ea059987a0f05485d7127 Mon Sep 17 00:00:00 2001 From: Tom Fogal <60981+tfogal@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:55:20 -0800 Subject: [PATCH 2/4] Use sys.executable to resolve python executable. This ensures the python we pass to subprocess.run is the same one as the thing that's running. --- thunder/tests/test_dynamo.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/thunder/tests/test_dynamo.py b/thunder/tests/test_dynamo.py index c5beb69be6..915e188295 100644 --- a/thunder/tests/test_dynamo.py +++ b/thunder/tests/test_dynamo.py @@ -3,6 +3,7 @@ import itertools import os import subprocess +import sys import torch import torch.fx import torch.nn as nn @@ -819,9 +820,13 @@ 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 = subprocess.run([cmd, s1], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) - result2 = subprocess.run([cmd, s2], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 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: {result1}" assert result2.returncode == 0, f"Reproducer {s2} failed: {result2}" @@ -852,8 +857,11 @@ 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 = subprocess.run([cmd, s1], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + 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}" @@ -915,7 +923,9 @@ def check(file_name, cmd): 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) From 77ff13baac4eee9c60a508cf80713d26d8187612 Mon Sep 17 00:00:00 2001 From: Tom Fogal <60981+tfogal@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:46:22 -0800 Subject: [PATCH 3/4] fix CI-found bug --- thunder/tests/test_dynamo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thunder/tests/test_dynamo.py b/thunder/tests/test_dynamo.py index 915e188295..3e3b545e41 100644 --- a/thunder/tests/test_dynamo.py +++ b/thunder/tests/test_dynamo.py @@ -917,7 +917,8 @@ def func(x): def check(file_name, cmd): assert os.path.exists(file_name) - result = subprocess.run([cmd, file_name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + 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" From 665b625f54b319692e96dbe3914e3c69bc04e38d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:48:07 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- thunder/tests/test_dynamo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/thunder/tests/test_dynamo.py b/thunder/tests/test_dynamo.py index 3e3b545e41..4bcd2333f4 100644 --- a/thunder/tests/test_dynamo.py +++ b/thunder/tests/test_dynamo.py @@ -822,7 +822,7 @@ def func(x): assert os.path.exists(s2) cmd = [sys.executable] if use_pytest_benchmark: - cmd = cmd + ["-m", "pytest"] + cmd = cmd + ["-m", "pytest"] cmd1 = cmd + [s1] cmd2 = cmd + [s2] result1 = subprocess.run(cmd1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) @@ -859,7 +859,7 @@ def forward(self, x): assert os.path.exists(s1) cmd = [sys.executable] if use_pytest_benchmark: - cmd = cmd + ["-m", "pytest"] + 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}" @@ -926,7 +926,7 @@ def check(file_name, cmd): s3 = f"{tmp_path}/graph0_thunder_4.py" cmd = [sys.executable] if use_pytest_benchmark: - cmd = cmd + ["-m", "pytest"] + cmd = cmd + ["-m", "pytest"] for fname in [s1, s2, s3]: check(fname, cmd)