From 92f3d150c769045c9c9fe555e581ae0579b04da0 Mon Sep 17 00:00:00 2001 From: Aharrypotter Date: Thu, 10 Sep 2026 15:18:00 +0800 Subject: [PATCH] bench: preflight the interpreter, not just the paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit triton normally comes from a PYTHONPATH pointing at a compiler build and flag_gems from a source checkout, so a shell that reaches every correct path can still be the wrong Python. run_pytest.sh checked that the FlagGems directory and benchmark file exist and then handed the run to pytest, where the real problem surfaced per cell as `pytest exit 4` from a conftest ImportError. A multi-round campaign burns every cell that way before anyone reads a log: today's noise-calibration run lost 12 measurement cells and 160 load runs to `ModuleNotFoundError: No module named 'triton'`, each failing in under a second and each looking, from the outside, like a cell that ran. The check names the interpreter it used, since which Python is on PATH is the whole question. Its stderr redirect stays on the child — putting `2>/dev/null` on the preflight call swallows preflight's own `>&2` message and turns a named refusal into a bare exit 3. --- README.md | 7 +++++++ run_pytest.sh | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 86ff2d7..6f70d20 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,13 @@ benchmark 目录,注册 `--level`/`--mode` 的 `conftest.py` 就没被加载 只校验节点的文件那一半;`::test_` 交给 pytest,函数不存在时它自己会清楚地报 `not found: ...`。 +还校验**解释器**——`python -c "import triton, flag_gems"`。triton 通常来自 PYTHONPATH +指向的编译器构建产物、flag_gems 来自源码检出,所以一个能摸到全部正确路径的 shell +仍然可能是错的那个 Python。不查的话,失败以每格一次 `pytest exit 4`(conftest 的 +ImportError)出现,多轮 campaign 会在有人读日志之前把每一格都烧掉——这不是假想, +2026-09-10 的噪声标定实验就这么废了 12 格加 160 次负载 run。报错里带上 +`$(command -v python)`,因为要看的就是"用的到底是哪个解释器"。 + ### 口径核对:出报告前的拒绝 `batch_summary.py --ab` / `--ab-rounds` 在解析任何 latency 之前,先读参与对比的每个 diff --git a/run_pytest.sh b/run_pytest.sh index 43d7c02..dc74f51 100644 --- a/run_pytest.sh +++ b/run_pytest.sh @@ -114,6 +114,12 @@ preflight "FlagGems directory exists: $FLAGGEMS_DIR" test -d "$FLAGGEMS_DIR" # The node's file half; the ::test_ half is left to pytest, which reports a # missing function clearly ("not found: ...") while a missing FILE does not. preflight "benchmark file exists: ${TEST_FILE%%::*}" test -f "${TEST_FILE%%::*}" +# The interpreter, not just the paths. triton and flag_gems normally come from a +# PYTHONPATH pointing at a compiler build and a source checkout, so a shell that +# merely reaches the right files can still be the wrong Python. Without this the +# failure surfaces per cell as `pytest exit 4` from a conftest ImportError, and a +# multi-round campaign burns every cell before anyone reads a log. +preflight "interpreter imports triton + flag_gems ($(command -v python))" sh -c 'python -c "import triton, flag_gems" 2>/dev/null' if [[ -n "$SHAPE_FILE" ]]; then preflight "shape file exists: $SHAPE_FILE" test -f "$SHAPE_FILE" fi