Skip to content

Commit 3171769

Browse files
authored
Restore Cadence test comments, fix CUDA and pybindings follow-ups, and consolidate HUD reporting (#25989)
### Summary The Cadence uint8 tests for fully connected, linear, and matmul still describe a negated multiplier. Restore the three comments from #25953 that were overwritten when the kernel registry change landed in #24935. Bring the CUDA INT4 test fix from #24096 to `main`. Inductor can append a suffix to a generated kernel name. The test now finds that definition and checks that its autotune decorator contains exactly one configuration. Restore the Buck header namespace for the extension macro updated in #23939. This lets callers in other Buck packages use the same `executorch/extension/pybindings/...` includes as `pybindings.cpp`. Finish the HUD reporting cleanup from #24992. Linux CMake gets the reporter from the root pytest configuration. The standalone Cortex-M jobs added in #25798 use a separate pytest configuration, so they load the same reporting hook explicitly and retain their report names and seeding. This removes the shell helper and its dedicated tests. Authored with assistance from OpenAI Codex. ### Test plan ```bash python -m pytest -q .ci/scripts/tests/test_{torchci_*,cortex_m_reporting,coreml_markers}.py ``` All 190 tests passed. The Cortex-M test ran each workflow command against a smoke suite and checked the report prefix, repo-relative test ID, and selected target. Verified that the three Cadence files match #25953, exercised the CUDA source assertion with suffixed and unsuffixed names and failing inputs, and checked all three Buck header paths against the C++ includes. The GPU test and a full Buck build were not run locally.
1 parent 1ed2990 commit 3171769

14 files changed

Lines changed: 128 additions & 331 deletions

File tree

‎.ci/scripts/tests/test_cortex_m_reporting.py‎

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
ROOT = Path(__file__).resolve().parents[3]
1919
CONFIG = "backends/arm/test/pytest.ini"
2020
SUITE = "backends/cortex_m/test"
21-
HELPER = ".ci/scripts/torchci-report-args.sh"
2221

2322

2423
@unittest.skipUnless(
25-
sys.platform == "linux" and shutil.which("bash"),
26-
"Cortex-M reporting uses Linux Bash",
24+
os.name == "posix" and shutil.which("bash"), "Cortex-M workflows use Bash"
2725
)
2826
class CortexMReportingTest(unittest.TestCase):
2927
def test_workflows_keep_the_arm_config_and_repo_relative_test_ids(self):
@@ -34,10 +32,19 @@ def test_workflows_keep_the_arm_config_and_repo_relative_test_ids(self):
3432
)
3533
with tempfile.TemporaryDirectory() as directory:
3634
repo = Path(directory)
37-
for name in (CONFIG, HELPER):
35+
for name in (CONFIG, "tools/__init__.py", "tools/pytest_torchci.py"):
3836
target = repo / name
3937
target.parent.mkdir(parents=True, exist_ok=True)
4038
shutil.copyfile(ROOT / name, target)
39+
torchci = repo / "torch/testing/_internal/torchci"
40+
torchci.mkdir(parents=True)
41+
(repo / "torch/__init__.py").touch()
42+
(torchci / "report.py").write_text("SCHEMA_VERSION = '1.0'\n")
43+
(torchci / "plugin.py").write_text(
44+
"from pathlib import Path\n"
45+
"def pytest_sessionstart(session):\n"
46+
" Path(session.config.option.torchci_report_prefix).touch()\n"
47+
)
4148
# Widening confcutdir would also load ExecuTorch's root seed hook.
4249
(repo / "conftest.py").write_text(
4350
"raise RuntimeError('root hook loaded')\n"
@@ -60,30 +67,30 @@ def test_workflows_keep_the_arm_config_and_repo_relative_test_ids(self):
6067
" assert target == os.environ['EXPECTED_TARGET']\n"
6168
)
6269
env = dict(
63-
os.environ, PYTEST_DISABLE_PLUGIN_AUTOLOAD="1", PYTHON=sys.executable
70+
os.environ,
71+
PATH=os.pathsep.join(
72+
(str(Path(sys.executable).parent), os.environ["PATH"])
73+
),
74+
PYTEST_DISABLE_PLUGIN_AUTOLOAD="1",
75+
PYTEST_ADDOPTS="-v",
76+
RUNNER_TEST_RUN_REPORTS_DIR=str(repo),
77+
JOB_ID="1",
78+
GITHUB_REPOSITORY="pytorch/executorch",
6479
)
65-
for name in (
66-
"PYTEST_ADDOPTS",
67-
"PYTEST_PLUGINS",
68-
"RUNNER_TEST_RUN_REPORTS_DIR",
69-
):
70-
env.pop(name, None)
80+
env.pop("PYTEST_PLUGINS", None)
7181
for workflow, job, target in jobs:
7282
with self.subTest(target=target):
7383
path = ROOT / ".github/workflows" / workflow
7484
inputs = yaml.safe_load(path.read_text(encoding="utf-8"))["jobs"][
7585
job
7686
]["with"]
7787
self.assertIs(inputs["upload-test-run-reports"], True)
78-
tail = inputs["script"].split(f"source {HELPER} ", 1)[1]
79-
tail = tail.replace("${{ matrix.target }}", target)
88+
script = inputs["script"]
89+
command = script[script.index("TORCHCI_REPORT_NAME=") :].replace(
90+
"${{ matrix.target }}", target
91+
)
8092
result = subprocess.run(
81-
[
82-
"bash",
83-
"-eu",
84-
"-c",
85-
f'pytest() {{ "$PYTHON" -m pytest -v "$@"; }}\nsource {HELPER} {tail}',
86-
],
93+
["bash", "-eu", "-c", command],
8794
cwd=repo,
8895
env=dict(env, EXPECTED_TARGET=target),
8996
capture_output=True,
@@ -96,3 +103,9 @@ def test_workflows_keep_the_arm_config_and_repo_relative_test_ids(self):
96103
self.assertIn(
97104
f"{SUITE}/ops/test_smoke.py::test_target PASSED", result.stdout
98105
)
106+
prefix = (
107+
"cortex-m"
108+
if workflow == "pull.yml"
109+
else f"cortex-m-ops-{target}"
110+
)
111+
self.assertTrue((repo / prefix).is_file(), result.stdout)

‎.ci/scripts/tests/test_torchci_conftest.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def configure(env, config=None, **stubs):
7676
with contextlib.ExitStack() as stack:
7777
stack.enter_context(mock.patch.dict(sys.modules, stub_modules(**stubs)))
7878
stack.enter_context(mock.patch.dict(os.environ, env, clear=True))
79+
stack.enter_context(mock.patch.object(sys, "path", [str(ROOT), *sys.path]))
80+
sys.modules.pop("tools", None)
81+
sys.modules.pop("tools.pytest_torchci", None)
7982
spec.loader.exec_module(module)
8083
module.pytest_configure(config)
8184
return module, config

‎.ci/scripts/tests/test_torchci_report_args.py‎

Lines changed: 0 additions & 188 deletions
This file was deleted.

‎.ci/scripts/torchci-report-args.sh‎

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎.ci/scripts/unittest-linux-cmake.sh‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ fi
3131

3232
bash .ci/scripts/tests/vulkan/test_vulkan_cmake_package.sh
3333

34-
source .ci/scripts/torchci-report-args.sh unittest-linux-cmake
35-
3634
source .ci/scripts/setup-hf-cache.sh
3735

3836
# Run pytest with coverage
39-
pytest -n auto --cov=./ --cov-report=xml \
40-
${TORCHCI_REPORT_ARGS[@]+"${TORCHCI_REPORT_ARGS[@]}"}
37+
pytest -n auto --cov=./ --cov-report=xml
4138
# Run gtest
4239
LLVM_PROFDATA=llvm-profdata-12 LLVM_COV=llvm-cov-12 \
4340
test/run_oss_cpp_tests.sh

‎.github/workflows/_test_cortex_m_ops.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ jobs:
6060
# op set, implementation tests check FVP numerics. Both are parametrized
6161
# over --cortex-m-target, so a future target-dependent lowering change is
6262
# caught here. (cortex-m55 runs on pull via the full-suite job.)
63-
source .ci/scripts/torchci-report-args.sh cortex-m-ops-${{ matrix.target }}
64-
pytest ${TORCHCI_REPORT_ARGS[@]+"${TORCHCI_REPORT_ARGS[@]}"} --rootdir=. \
63+
TORCHCI_REPORT_NAME=cortex-m-ops-${{ matrix.target }} \
64+
python -m pytest -p tools.pytest_torchci --rootdir=. \
6565
-c backends/arm/test/pytest.ini \
6666
backends/cortex_m/test/ops \
6767
--cortex-m-target=${{ matrix.target }}

‎.github/workflows/pull.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ jobs:
907907
backends/cortex_m/test/build_test_runner.sh
908908
909909
# Use repo-relative report identities without loading the root seed hook.
910-
source .ci/scripts/torchci-report-args.sh cortex-m
911-
pytest ${TORCHCI_REPORT_ARGS[@]+"${TORCHCI_REPORT_ARGS[@]}"} --rootdir=. \
910+
TORCHCI_REPORT_NAME=cortex-m \
911+
python -m pytest -p tools.pytest_torchci --rootdir=. \
912912
-c backends/arm/test/pytest.ini backends/cortex_m/test
913913
914914
android:

‎backends/cadence/generic/operators/tests/test_op_quantized_fully_connected.cpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ TEST_F(
116116
EXPECT_TENSOR_EQ(out_pc, out_pt);
117117
}
118118

119-
// The uint8 typed entry, on the first row of the linear test's input.
120-
// Expected values are aot/ref_implementations.py's with the multiplier negated,
121-
// for the reason test_op_quantized_linear.cpp gives.
119+
// The uint8 typed entry, on the first row of the linear test's input, with
120+
// the scale test_op_quantized_linear.cpp works out.
122121
TEST_F(GenericQuantizedFullyConnectedPerChannelTest, Asym8uPerTensor) {
123122
TensorFactory<ScalarType::Byte> tf_uint8;
124123
TensorFactory<ScalarType::Int> tf_int32;

‎backends/cadence/generic/operators/tests/test_op_quantized_linear.cpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ TEST_F(GenericQuantizedLinearPerChannelTest, LengthOneMatchesPerTensor) {
143143

144144
// The uint8 typed entry. The kernel computes -out_multiplier / (1 << 31), and
145145
// 1 << 31 is INT_MIN, so the scale is +out_multiplier / 2^31, as
146-
// quantize_tensor_multiplier produces. aot/ref_implementations.py computes
147-
// -out_multiplier / 2^31, so the expected values come from it with the
148-
// multiplier negated: (src - 128) @ (weight - 128)^T + bias =
146+
// quantize_tensor_multiplier produces and aot/ref_implementations.py
147+
// computes: (src - 128) @ (weight - 128)^T + bias =
149148
// [[-3, 80], [-4, 0]], times 1/4, plus 100.
150149
TEST_F(GenericQuantizedLinearPerChannelTest, Asym8uPerTensor) {
151150
TensorFactory<ScalarType::Byte> tf_uint8;

0 commit comments

Comments
 (0)