Skip to content

Commit b9437d6

Browse files
HP_trials=20
GPU threshold at 105 regions
1 parent 9a9b3a4 commit b9437d6

6 files changed

Lines changed: 53 additions & 14 deletions

File tree

cybench/runs/slurm/benchmark_submit_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from cybench.config import DATASETS, PATH_DATA_DIR
1313

1414
# Countries with at least this many regions use the gpu SLURM partition for torch/TabPFN.
15-
DEFAULT_GPU_REGION_THRESHOLD = 50
15+
DEFAULT_GPU_REGION_THRESHOLD = 105
1616

1717
_BATCH_RE = re.compile(
1818
r"^baselines_(?P<country>[A-Za-z]{2})_(?P<batch_hz>eos|mid|qtr|early)_v(?P<version>\d+)$"

cybench/runs/slurm/orchestrate_benchmark_complete.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Options:
3939
--dry-run With --submit: no sbatch
4040
--cpu Force torch/TabPFN group to CPU partition
4141
--force-gpu Use gpu partition even when regions < threshold
42-
--region-threshold N gpu when country has >= N regions (default: 50)
42+
--region-threshold N gpu when country has >= N regions (default: 105)
4343
4444
Examples:
4545
orchestrate_benchmark_complete.sh --country DE --horizons eos mid --list

cybench/runs/slurm/orchestrate_benchmark_submit.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#
1313
set -euo pipefail
1414

15+
export HP_TRIALS="${HP_TRIALS:-20}"
16+
1517
usage() {
1618
cat <<'EOF'
1719
Usage: orchestrate_benchmark_submit.sh [options]
@@ -28,7 +30,7 @@ Options:
2830
--dry-run Print submit_benchmark.sh commands without sbatch
2931
--countries CC ... Limit to these countries (default: all with data on disk)
3032
--horizon H ... eos | mid | qtr | early (alias early-season; repeatable)
31-
--region-threshold N gpu partition when country has >= N regions (default: 50)
33+
--region-threshold N gpu partition when country has >= N regions (default: 105)
3234
--version N Batch version suffix (default: 3)
3335
--phase MODE screening | walk_forward | all (default: all)
3436
--repetitions N Walk-forward seeds 42..42+N-1 (passed to submit_benchmark.sh)
@@ -41,7 +43,7 @@ Options:
4143
--data-dir DIR Override cybench/data
4244
4345
Environment:
44-
HP_TRIALS Optuna trials in screening (default: 100)
46+
HP_TRIALS Optuna trials in screening (default: 20)
4547
WF_REPETITIONS Default for --repetitions when omitted (default: 1)
4648
4749
Examples:
@@ -71,7 +73,7 @@ FORCE=false
7173
ALL_COUNTRIES=false
7274
PHASE_MODE="all"
7375
VERSION=3
74-
REGION_THRESHOLD=50
76+
REGION_THRESHOLD=105
7577
MAX_BATCHES=0
7678
MANIFEST_ROOT="${SLURM_DIR}/manifests"
7779
DATA_DIR=""

cybench/runs/slurm/slurm_common.sh

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ configure_parallelism() {
354354
configure_hpo_extras() {
355355
local -n _extra=$1
356356
if [[ "${HP_SEARCH}" == "yes" ]]; then
357-
_extra+=(+hp_search=bayesian hp_search.n_trials="${HP_TRIALS:-100}")
357+
_extra+=(+hp_search=bayesian hp_search.n_trials="${HP_TRIALS:-20}")
358358
_extra+=(
359359
"hp_search.storage.url=sqlite:///${TMPDIR:-/tmp}/optuna_${SLURM_JOB_ID}_${SLURM_ARRAY_TASK_ID}.db"
360360
)
@@ -482,13 +482,35 @@ plan_walk_forward_seeds() {
482482
}
483483

484484
# Single-seed walk-forward task (GPU manifest with 8th column). Sets WF_RUN_DIR, WF_START_SEED, WF_RUN_REPS=1.
485-
# Returns 0 run, 1 skip (seed present), 2 error (seed>base without run dir).
485+
# Returns 0 run, 1 skip (seed present), 2 error (timed out waiting for base-seed run dir).
486486
plan_walk_forward_single_seed() {
487487
local crop=$1 country=$2 model_slug=$3 seed=$4
488488
local base=${WF_BASE_SEED:-42}
489489
local run_dir=""
490+
local wait_secs=${WF_SEED_WAIT_SECS:-7200}
491+
local interval=${WF_SEED_WAIT_INTERVAL:-30}
492+
local elapsed=0
493+
494+
# Parallel per-seed arrays may start seed 43+ before seed ${base} creates the run dir.
495+
while true; do
496+
run_dir=$(find_latest_walk_forward_run_dir "${crop}" "${country}" "${model_slug}")
497+
if [[ -n "${run_dir}" && -d "${run_dir}" ]]; then
498+
break
499+
fi
500+
if [[ "${seed}" == "${base}" ]]; then
501+
break
502+
fi
503+
if [[ "${elapsed}" -eq 0 ]]; then
504+
echo "[WAIT] Seed ${seed} waiting for walk-forward run dir (seed ${base})..." >&2
505+
fi
506+
if [[ "${elapsed}" -ge "${wait_secs}" ]]; then
507+
echo "[ERROR] Seed ${seed} timed out after ${wait_secs}s waiting for walk-forward run (seed ${base})" >&2
508+
return 2
509+
fi
510+
sleep "${interval}"
511+
elapsed=$((elapsed + interval))
512+
done
490513

491-
run_dir=$(find_latest_walk_forward_run_dir "${crop}" "${country}" "${model_slug}")
492514
if [[ -n "${run_dir}" && -d "${run_dir}" ]]; then
493515
local -a existing=()
494516
mapfile -t existing < <(discover_run_seeds_py "${run_dir}")
@@ -500,9 +522,6 @@ plan_walk_forward_single_seed() {
500522
fi
501523
done
502524
WF_RUN_DIR="$(cd "${run_dir}" && pwd)"
503-
elif [[ "${seed}" != "${base}" ]]; then
504-
echo "[ERROR] Seed ${seed} requires existing walk-forward run (run seed ${base} first)" >&2
505-
return 2
506525
else
507526
WF_RUN_DIR=""
508527
fi

cybench/runs/slurm/walk_forward.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ WF_START_SEED="${WF_BASE_SEED}"
5252
WF_RUN_REPS="${WF_REPETITIONS}"
5353

5454
if [[ -n "${WF_SEED:-}" ]]; then
55-
if ! plan_walk_forward_single_seed "${CROP}" "${COUNTRY}" "${MODEL}" "${WF_SEED}"; then
56-
exit 0
57-
fi
55+
plan_walk_forward_single_seed "${CROP}" "${COUNTRY}" "${MODEL}" "${WF_SEED}"
56+
wf_plan_rc=$?
57+
case "${wf_plan_rc}" in
58+
0) ;;
59+
1) exit 0 ;; # seed already present
60+
*) exit 1 ;; # timeout / planning error — do not mask as success
61+
esac
5862
elif ! plan_walk_forward_seeds "${CROP}" "${COUNTRY}" "${MODEL}"; then
5963
exit 0
6064
fi

tests/runs/test_benchmark_submit_lib.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ def test_resolve_batch_dir_and_parse_batch_name(tmp_path: Path):
8282
assert note is not None
8383

8484

85+
def test_gpu_region_threshold_default_routes_fr_to_cpu(tmp_path: Path, monkeypatch):
86+
from cybench.runs.slurm import benchmark_submit_lib as lib
87+
88+
assert lib.DEFAULT_GPU_REGION_THRESHOLD == 105
89+
90+
def _fake_count(country: str, data_dir=None) -> int:
91+
return {"FR": 100, "IT": 105, "DE": 200}[country.upper()]
92+
93+
monkeypatch.setattr(lib, "count_regions", _fake_count)
94+
assert lib.gpu_partition_for_country("FR")[0] is False
95+
assert lib.gpu_partition_for_country("IT")[0] is True
96+
assert lib.gpu_partition_for_country("DE")[0] is True
97+
98+
8599
def test_expand_all_country_targets():
86100
from cybench.runs.slurm.benchmark_completion_lib import expand_all_country_targets
87101

0 commit comments

Comments
 (0)