Skip to content

Commit ea5307f

Browse files
Harden estimator CI runtime checks
Add the local estimate submit helper to Result Server Tests path filters so estimator shell coverage runs when that helper changes. Require GPU estimator section packages and tests to use Python 3.11 or newer, while keeping Result Server docs scoped to Python 3.12+ portal/runtime requirements. Signed-off-by: Yoshifumi Nakamura <nakamura@riken.jp>
1 parent 9a467c5 commit ea5307f

7 files changed

Lines changed: 122 additions & 19 deletions

File tree

.github/workflows/result-server-tests.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
- "scripts/tests/test_result_profile_data.sh"
1717
- "scripts/tests/test_send_estimate_artifacts.sh"
1818
- "scripts/tests/test_send_results_profile_data.sh"
19+
- "scripts/test_estimate_submit.sh"
1920
- "programs/genesis/estimate.sh"
2021
- "programs/qws/estimate.sh"
2122
- "programs/qws/fixtures/gpu_kernel_mlp_v15_pred.csv"
@@ -41,6 +42,7 @@ on:
4142
- "scripts/tests/test_result_profile_data.sh"
4243
- "scripts/tests/test_send_estimate_artifacts.sh"
4344
- "scripts/tests/test_send_results_profile_data.sh"
45+
- "scripts/test_estimate_submit.sh"
4446
- "programs/genesis/estimate.sh"
4547
- "programs/qws/estimate.sh"
4648
- "programs/qws/fixtures/gpu_kernel_mlp_v15_pred.csv"
@@ -97,6 +99,18 @@ jobs:
9799
jq --version
98100
command -v python3
99101
python3 --version
102+
estimation_python=""
103+
for candidate in python3.12 python3.11 python3; do
104+
if command -v "$candidate" >/dev/null 2>&1; then
105+
estimation_python=$(command -v "$candidate")
106+
break
107+
fi
108+
done
109+
test -n "$estimation_python"
110+
"$estimation_python" - <<'PY'
111+
import sys
112+
raise SystemExit(0 if sys.version_info >= (3, 11) else 1)
113+
PY
100114
101115
- name: Run profiler, profile-data, and estimation shell tests
102116
run: |

docs/guides/add-estimation-package.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ PerfTools 本体は BenchKit に vendoring せず、実行時に次の環境変
102102

103103
```bash
104104
export BK_GPU_MLP_PERFTOOLS_ROOT=/path/to/PerfTools
105-
export BK_GPU_MLP_PYTHON=python3
105+
export BK_GPU_MLP_PYTHON=python3.11
106106
# LightGBM package だけを明示したい場合
107107
export BK_GPU_LIGHTGBM_PERFTOOLS_ROOT=/path/to/PerfTools
108-
export BK_GPU_LIGHTGBM_PYTHON=python3
108+
export BK_GPU_LIGHTGBM_PYTHON=python3.11
109109
```
110110

111111
section artifact は PerfTools 側の static GPU spec sheet から作られた prepared CSV を想定します。
@@ -142,7 +142,9 @@ export BK_GPU_MLP_PERFTOOLS_REF=main
142142

143143
`perftools` smoke mode は GitHub から PerfTools を取得するため、推定 runner/container には `git` と外部接続が必要です。
144144
Python とライブラリは、選択した PerfTools モデル側の要件に合わせます。
145+
Result Server/portal の runtime は Python 3.12 以上ですが、GPU estimator runner は外部推定ツールの runtime です。
145146
MLP package には Python 3.11 以上と numpy/pandas/torch、LightGBM package には Python 3.11 以上と numpy/pandas/lightgbm/pyyaml、さらに LightGBM 実行用の `libgomp` が必要です。
147+
`python3` が 3.10 など古い環境では、`BK_GPU_MLP_PYTHON``BK_GPU_LIGHTGBM_PYTHON` に 3.11 以上の interpreter を明示してください。
146148
実運用では smoke mode ではなく、推定 runner/container に PerfTools checkout を用意し、section artifact として実アプリ由来の prepared input CSV を渡してください。
147149

148150
## 5. metadata に持たせるもの

docs/guides/developer-reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ Typical requirements include:
229229
- Bash and standard shell tooling
230230
- GitLab CI runner support
231231
- site-specific scheduler/runtime support
232-
- Python 3.12 or later for result shaping, estimation support, and portal components
232+
- Python 3.12 or later for result shaping and portal components
233233
- Flask-related Python packages for `result_server`
234+
- package-specific runtimes for external estimation tools
234235
- optional profiler tools depending on system support
235236

236237
For local portal work, see the route, template, and utility layout under `result_server/`.

scripts/estimation/section_packages/gpu_kernel_lightgbm_v10.sh

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bk_section_package_metadata_gpu_kernel_lightgbm_v10() {
3333
"neither section artifact nor BK_GPU_LIGHTGBM_INPUT_CSV/BK_GPU_LIGHTGBM_PREDICTION_CSV is available",
3434
"padata artifact mode is requested but the archive has no Nsight Compute raw CSV",
3535
"PerfTools checkout is not available when running the external predictor",
36-
"Python runtime for CSV parsing or external inference is not available",
36+
"Python 3.11+ runtime for CSV parsing or external inference is not available",
3737
"prediction CSV does not contain a recognized execution-time column"
3838
]
3939
}
@@ -98,6 +98,29 @@ _bk_gpu_lightgbm_python_exists() {
9898
command -v "$python_bin" >/dev/null 2>&1
9999
}
100100

101+
_bk_gpu_lightgbm_default_python() {
102+
local candidate
103+
104+
for candidate in python3.12 python3.11 python3 python; do
105+
if command -v "$candidate" >/dev/null 2>&1; then
106+
printf '%s\n' "$candidate"
107+
return 0
108+
fi
109+
done
110+
111+
printf '%s\n' "python3"
112+
}
113+
114+
_bk_gpu_lightgbm_python_compatible() {
115+
local python_bin="$1"
116+
117+
_bk_gpu_lightgbm_python_exists "$python_bin" || return 1
118+
"$python_bin" - <<'PY' >/dev/null 2>&1
119+
import sys
120+
raise SystemExit(0 if sys.version_info >= (3, 11) else 1)
121+
PY
122+
}
123+
101124
_bk_gpu_lightgbm_abs_path() {
102125
local path="$1"
103126
local dir
@@ -239,7 +262,7 @@ bk_section_package_check_applicability_gpu_kernel_lightgbm_v10() {
239262
local ncu_archive
240263
local root
241264
local predictor
242-
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-python3}}"
265+
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-$(_bk_gpu_lightgbm_default_python)}}"
243266
local missing=()
244267

245268
if [[ "$item_kind" != "section" ]]; then
@@ -256,6 +279,8 @@ EOF
256279

257280
if ! _bk_gpu_lightgbm_python_exists "$python_bin"; then
258281
missing+=("\"python:${python_bin}\"")
282+
elif ! _bk_gpu_lightgbm_python_compatible "$python_bin"; then
283+
missing+=("\"python>=3.11:${python_bin}\"")
259284
fi
260285

261286
if [[ -n "$prediction_csv" ]]; then
@@ -297,7 +322,7 @@ _bk_gpu_lightgbm_parse_prediction_csv() {
297322
local prediction_csv="$1"
298323
local package_name="$2"
299324
local model_version="$3"
300-
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-python3}}"
325+
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-$(_bk_gpu_lightgbm_default_python)}}"
301326

302327
"$python_bin" - "$prediction_csv" "$package_name" "$model_version" <<'PY'
303328
import csv
@@ -427,7 +452,7 @@ _bk_gpu_lightgbm_prepare_input_from_ncu() {
427452
local _section_name="$2"
428453
local output_dir="$3"
429454
local slug="$4"
430-
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-python3}}"
455+
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-$(_bk_gpu_lightgbm_default_python)}}"
431456
local source_gpu="${BK_GPU_LIGHTGBM_SOURCE_GPU:-${BK_GPU_MLP_SOURCE_GPU:-H100}}"
432457
local prepared_csv="${output_dir}/${slug}_lightgbm_input.csv"
433458
local script_path="scripts/estimation/prepare_gpu_lightgbm_ncu_input.py"
@@ -458,7 +483,7 @@ _bk_gpu_lightgbm_run_predictor() {
458483
local input_csv_abs
459484
local prediction_csv_abs
460485
local prediction_log_abs
461-
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-python3}}"
486+
local python_bin="${BK_GPU_LIGHTGBM_PYTHON:-${BK_GPU_MLP_PYTHON:-$(_bk_gpu_lightgbm_default_python)}}"
462487
local source_gpu="${BK_GPU_LIGHTGBM_SOURCE_GPU:-${BK_GPU_MLP_SOURCE_GPU:-H100}}"
463488
local target_gpu="${BK_GPU_LIGHTGBM_TARGET_GPU:-${BK_GPU_MLP_TARGET_GPU:-A100}}"
464489
local slug

scripts/estimation/section_packages/gpu_kernel_mlp_v15.sh

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bk_section_package_metadata_gpu_kernel_mlp_v15() {
3333
"neither section artifact nor BK_GPU_MLP_INPUT_CSV/BK_GPU_MLP_PREDICTION_CSV is available",
3434
"padata artifact mode is requested but the archive has no Nsight Compute raw CSV",
3535
"PerfTools checkout is not available when running the external predictor",
36-
"Python runtime for CSV parsing or external inference is not available",
36+
"Python 3.11+ runtime for CSV parsing or external inference is not available",
3737
"prediction CSV does not contain a recognized execution-time column"
3838
]
3939
}
@@ -85,6 +85,29 @@ _bk_gpu_mlp_python_exists() {
8585
command -v "$python_bin" >/dev/null 2>&1
8686
}
8787

88+
_bk_gpu_mlp_default_python() {
89+
local candidate
90+
91+
for candidate in python3.12 python3.11 python3 python; do
92+
if command -v "$candidate" >/dev/null 2>&1; then
93+
printf '%s\n' "$candidate"
94+
return 0
95+
fi
96+
done
97+
98+
printf '%s\n' "python3"
99+
}
100+
101+
_bk_gpu_mlp_python_compatible() {
102+
local python_bin="$1"
103+
104+
_bk_gpu_mlp_python_exists "$python_bin" || return 1
105+
"$python_bin" - <<'PY' >/dev/null 2>&1
106+
import sys
107+
raise SystemExit(0 if sys.version_info >= (3, 11) else 1)
108+
PY
109+
}
110+
88111
_bk_gpu_mlp_abs_existing_path() {
89112
local path="$1"
90113
local dir
@@ -226,7 +249,7 @@ bk_section_package_check_applicability_gpu_kernel_mlp_v15() {
226249
local ncu_archive
227250
local root
228251
local predictor
229-
local python_bin="${BK_GPU_MLP_PYTHON:-python3}"
252+
local python_bin="${BK_GPU_MLP_PYTHON:-$(_bk_gpu_mlp_default_python)}"
230253
local missing=()
231254

232255
if [[ "$item_kind" != "section" ]]; then
@@ -243,6 +266,8 @@ EOF
243266

244267
if ! _bk_gpu_mlp_python_exists "$python_bin"; then
245268
missing+=("\"python:${python_bin}\"")
269+
elif ! _bk_gpu_mlp_python_compatible "$python_bin"; then
270+
missing+=("\"python>=3.11:${python_bin}\"")
246271
fi
247272

248273
if [[ -n "$prediction_csv" ]]; then
@@ -284,7 +309,7 @@ _bk_gpu_mlp_parse_prediction_csv() {
284309
local prediction_csv="$1"
285310
local package_name="$2"
286311
local model_version="$3"
287-
local python_bin="${BK_GPU_MLP_PYTHON:-python3}"
312+
local python_bin="${BK_GPU_MLP_PYTHON:-$(_bk_gpu_mlp_default_python)}"
288313

289314
"$python_bin" - "$prediction_csv" "$package_name" "$model_version" <<'PY'
290315
import csv
@@ -417,7 +442,7 @@ _bk_gpu_mlp_prepare_input_from_ncu() {
417442
local root="$3"
418443
local output_dir="$4"
419444
local slug="$5"
420-
local python_bin="${BK_GPU_MLP_PYTHON:-python3}"
445+
local python_bin="${BK_GPU_MLP_PYTHON:-$(_bk_gpu_mlp_default_python)}"
421446
local source_gpu="${BK_GPU_MLP_SOURCE_GPU:-${BK_GPU_MLP_SRC_GPU:-H100}}"
422447
local kernel_count="${BK_GPU_MLP_KERNEL_COUNT:-20}"
423448
local prepared_csv="${output_dir}/${slug}_input.csv"
@@ -450,7 +475,7 @@ _bk_gpu_mlp_run_predictor() {
450475
local input_csv_abs
451476
local prediction_csv_abs
452477
local prediction_log_abs
453-
local python_bin="${BK_GPU_MLP_PYTHON:-python3}"
478+
local python_bin="${BK_GPU_MLP_PYTHON:-$(_bk_gpu_mlp_default_python)}"
454479
local slug
455480

456481
root=$(_bk_gpu_mlp_perftools_root)

scripts/tests/test_estimation_gpu_kernel_lightgbm_v10.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,26 @@ if ! command -v jq >/dev/null 2>&1; then
1111
echo "jq not found; skipping gpu_kernel_lightgbm_v10 estimation test"
1212
exit 0
1313
fi
14-
if ! command -v python3 >/dev/null 2>&1; then
15-
echo "python3 not found; skipping gpu_kernel_lightgbm_v10 estimation test"
14+
15+
PYTHON_BIN="${BK_TEST_ESTIMATION_PYTHON:-}"
16+
if [[ -z "$PYTHON_BIN" ]]; then
17+
for candidate in python3.12 python3.11 python3; do
18+
if command -v "$candidate" >/dev/null 2>&1; then
19+
PYTHON_BIN=$(command -v "$candidate")
20+
break
21+
fi
22+
done
23+
fi
24+
if [[ -z "$PYTHON_BIN" ]]; then
25+
echo "Python 3.11+ not found; skipping gpu_kernel_lightgbm_v10 estimation test"
26+
exit 0
27+
fi
28+
if ! "$PYTHON_BIN" - <<'PY' >/dev/null 2>&1
29+
import sys
30+
raise SystemExit(0 if sys.version_info >= (3, 11) else 1)
31+
PY
32+
then
33+
echo "Python 3.11+ not found; skipping gpu_kernel_lightgbm_v10 estimation test"
1634
exit 0
1735
fi
1836

@@ -48,7 +66,7 @@ source scripts/estimation/common.sh
4866
source scripts/estimation/packages/instrumented_app_sections_dummy.sh
4967

5068
export BK_GPU_LIGHTGBM_ARTIFACT_MODE="prediction"
51-
export BK_GPU_LIGHTGBM_PYTHON="python3"
69+
export BK_GPU_LIGHTGBM_PYTHON="$PYTHON_BIN"
5270

5371
transformed=$(bk_top_level_transform_breakdown "$(cat "${TMP_DIR}/breakdown.json")" "1" "1" "1" "identity" "identity")
5472
popd >/dev/null

scripts/tests/test_estimation_gpu_kernel_mlp_v15.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,26 @@ if ! command -v jq >/dev/null 2>&1; then
1212
echo "jq not found; skipping gpu_kernel_mlp_v15 estimation test"
1313
exit 0
1414
fi
15-
if ! command -v python3 >/dev/null 2>&1; then
16-
echo "python3 not found; skipping gpu_kernel_mlp_v15 estimation test"
15+
16+
PYTHON_BIN="${BK_TEST_ESTIMATION_PYTHON:-}"
17+
if [[ -z "$PYTHON_BIN" ]]; then
18+
for candidate in python3.12 python3.11 python3; do
19+
if command -v "$candidate" >/dev/null 2>&1; then
20+
PYTHON_BIN=$(command -v "$candidate")
21+
break
22+
fi
23+
done
24+
fi
25+
if [[ -z "$PYTHON_BIN" ]]; then
26+
echo "Python 3.11+ not found; skipping gpu_kernel_mlp_v15 estimation test"
27+
exit 0
28+
fi
29+
if ! "$PYTHON_BIN" - <<'PY' >/dev/null 2>&1
30+
import sys
31+
raise SystemExit(0 if sys.version_info >= (3, 11) else 1)
32+
PY
33+
then
34+
echo "Python 3.11+ not found; skipping gpu_kernel_mlp_v15 estimation test"
1735
exit 0
1836
fi
1937
if [[ ! -f "$PREDICTION_FIXTURE" ]]; then
@@ -47,7 +65,7 @@ source scripts/estimation/common.sh
4765
source scripts/estimation/packages/instrumented_app_sections_dummy.sh
4866

4967
export BK_GPU_MLP_ARTIFACT_MODE="prediction"
50-
export BK_GPU_MLP_PYTHON="python3"
68+
export BK_GPU_MLP_PYTHON="$PYTHON_BIN"
5169

5270
transformed=$(bk_top_level_transform_breakdown "$(cat "${TMP_DIR}/breakdown.json")" "1" "1" "1" "identity" "identity")
5371
popd >/dev/null

0 commit comments

Comments
 (0)