Upload zeng_dflash3_SpecPilot
Browse filesFiles changed (43)
- .gitattributes+1
- .gitignoreAdded+23
- .pytest_cache/.gitignoreAdded+2
- .pytest_cache/CACHEDIR.TAGAdded+4
- .pytest_cache/README.mdAdded+8
- .pytest_cache/v/cache/lastfailedAdded+1
- .pytest_cache/v/cache/nodeidsAdded+7
- README (1).mdAdded+1
- README.mdAdded+1
- artifacts/baseline_metrics.jsonAdded+18
- artifacts/candidate_plan.jsonAdded+112
- artifacts/data/open_perfectblend_regen_10pct.jsonlAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/data-00000-of-00007.arrowAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/data-00001-of-00007.arrowAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/data-00002-of-00007.arrowAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/data-00003-of-00007.arrowAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/data-00004-of-00007.arrowAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/data-00005-of-00007.arrowAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/data-00006-of-00007.arrowAdded+3
- artifacts/data/open_perfectblend_regen_10pct_prepared/dataset_info.jsonAdded+57
- artifacts/data/open_perfectblend_regen_10pct_prepared/state.jsonAdded+35
- artifacts/data/open_perfectblend_regen_10pct_prepared/token_freq.ptAdded+3
- artifacts/run_dflash3_10pct_5ep.shAdded+186
- artifacts/run_specpilot_8gpu.shAdded+89
- artifacts/specpilot.pyAdded+294
- artifacts/specpilot_results.mdAdded+32
- baseline_metrics (1).jsonAdded+18
- candidate_plan (1).jsonAdded+112
- environment/DockerfileAdded+3
- instruction (1).mdAdded+37
- pro (1).mdAdded+37
- prompt (1).mdAdded+71
- run_dflash3_10pct_5ep (1).shAdded+186
- run_specpilot_8gpu (1).shAdded+89
- solution/eval_specpilot.shAdded+77
- solution/solve.shAdded+7
- specpilot (1).pyAdded+294
- specpilot_results (1).mdAdded+32
- specpilot_state (1).jsonAdded+92
- task (1).tomlAdded+31
- tests/DockerfileAdded+9
- tests/test.shAdded+8
- tests/test_outputs.pyAdded+70
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textartifacts/data/open_perfectblend_regen_10pct.jsonl filter=lfs diff=lfs merge=lfs -text
1234567891011121314151617181920212223# Git.git/
# OS.DS_Store
# Python__pycache__/*.pyc*.egg-info/.venv/.ruff_cache/.mypy_cache/.pytest_cache/
# Nodenode_modules/
# Secrets.env
# Harbordist.tar.gz12# Created by pytest automatically.*1234Signature: 8a477f597d28d172789f06886806bc55# This file is a cache directory tag created by pytest.# For information about cache directory tags, see:# https://bford.info/cachedir/spec.html12345678# pytest cache directory #
This directory contains data from the pytest's cache plugin,which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
**Do not** commit this to version control.
See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.1{}1234567[ "tests/test_outputs.py::test_failed_candidate_is_retried", "tests/test_outputs.py::test_no_credentials_are_written", "tests/test_outputs.py::test_plan_and_report_contract", "tests/test_outputs.py::test_pretrained_runner_does_not_override_decoder_shape", "tests/test_outputs.py::test_task_and_runner_exist"]1# zeng/zeng_dflash3_SpecPilot1# zeng/zeng_dflash3_SpecPilot123456789101112131415161718{ "validation": { "accept_len_epoch": 5.953488872407978, "accept_rate_epoch": 0.4398621302451192, "eal_epoch": 7.1277821658634934, "loss_epoch": 1.2213575182325183, "teacher_forced_selector_acc_epoch": 0.8323225238395741 }, "mt-bench": { "acceptance_length": 2.8897184300341294 }, "humaneval": { "acceptance_length": 3.214498354833655 }, "math500": { "acceptance_length": 3.6829078734979372 }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112[ { "name": "control_selector32", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector24", "selector_top_k": 24, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector48", "selector_top_k": 48, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector_alpha05", "selector_top_k": 32, "selector_loss_alpha": 0.5, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector_alpha20", "selector_top_k": 32, "selector_loss_alpha": 2.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "dpace_alpha03", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.3, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "dpace_alpha07", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.7, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "anchors512", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 512, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "anchors1024", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 1024, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "lr4e4", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0004, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "lr8e4", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0008, "epochs": 5, "dataset_fraction": 0.1 }]123version https://git-lfs.github.com/spec/v1oid sha256:68b1187b79ecdd52ea20b1afd801d8b3eabfd8afbed2f278bc17b2302b27e6b6size 2848479622123version https://git-lfs.github.com/spec/v1oid sha256:7f33c0651836c0b3ddb599fccc985bdcd1c5ae2edfa53446a245bbb8d333890csize 475022848123version https://git-lfs.github.com/spec/v1oid sha256:43492d5cfa04e6cbab93da23ee9e9471e7fc0d949d8fa0d4c895a3e3bb94b2e2size 474234032123version https://git-lfs.github.com/spec/v1oid sha256:9445fa242065df161c09f794aa27361514070366190a07af12b80093a156e0c3size 483145504123version https://git-lfs.github.com/spec/v1oid sha256:47171312482531a04595d5a7a24e665d79718c8bfbe9d3f56fc4dd49e11ca43fsize 478348976123version https://git-lfs.github.com/spec/v1oid sha256:a9f5a3066a66d204cc4b4ca07e15c12b6590b0cd62cd832c7df4bd1cca0a8c9fsize 471813280123version https://git-lfs.github.com/spec/v1oid sha256:d6721766ca44dede446d95bac33e560126521b7114d5bab73e2abb43fc406f12size 475741896123version https://git-lfs.github.com/spec/v1oid sha256:22d68c40a4a111f5da9d77aa08bac90dde72954d6d24888644a0d46ae291e138size 477451480123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657{ "builder_name": "json", "citation": "", "config_name": "default", "dataset_name": "json", "dataset_size": 4353520596, "description": "", "download_size": 2848479622, "features": { "input_ids": { "feature": { "dtype": "int64", "_type": "Value" }, "_type": "List" }, "loss_mask": { "feature": { "dtype": "int64", "_type": "Value" }, "_type": "List" }, "seq_len": { "dtype": "int64", "_type": "Value" } }, "homepage": "", "license": "", "size_in_bytes": 7202000218, "splits": { "train": { "name": "train", "num_bytes": 4353520596, "num_examples": 184268, "shard_lengths": [ 22189, 21790, 21717, 21718, 21852, 21558, 21606, 21615, 10223 ], "dataset_name": "json" } }, "version": { "version_str": "0.0.0", "major": 0, "minor": 0, "patch": 0 }}1234567891011121314151617181920212223242526272829303132333435{ "_data_files": [ { "filename": "data-00000-of-00007.arrow" }, { "filename": "data-00001-of-00007.arrow" }, { "filename": "data-00002-of-00007.arrow" }, { "filename": "data-00003-of-00007.arrow" }, { "filename": "data-00004-of-00007.arrow" }, { "filename": "data-00005-of-00007.arrow" }, { "filename": "data-00006-of-00007.arrow" } ], "_fingerprint": "8d3604c7f9fce460", "_format_columns": [ "input_ids", "loss_mask", "seq_len" ], "_format_kwargs": {}, "_format_type": "torch", "_output_all_columns": false, "_split": null}123version https://git-lfs.github.com/spec/v1oid sha256:f9f2744f1b690d055cef82202881f3c7d64c5fdfa619c8d54a13d6c78eab3514size 572543123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186#!/usr/bin/env bashset -euo pipefail
TASK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"ARTIFACT_ROOT="$TASK_ROOT/artifacts"
SPEC_REPO="${SPEC_REPO:-/high_perf_store3/world-model/weixiaobao/zlj/speculators-main}"SPEC_PYTHON="${SPEC_PYTHON:-/high_perf_store3/world-model/weixiaobao/yzj/speculators/.venv/bin/python}"VLLM_PYTHON="${VLLM_PYTHON:-/high_perf_store3/world-model/weixiaobao/yzj/vllm_env/bin/python}"MODEL="${MODEL:-$SPEC_REPO/Qwen3-8B}"SOURCE_DATASET="${SOURCE_DATASET:-$SPEC_REPO/experimental/outputs/open_perfectblend_regen/open_perfectblend_regen.jsonl}"DATASET="${DATASET:-$ARTIFACT_ROOT/data/open_perfectblend_regen_10pct.jsonl}"PREPARED_DIR="${PREPARED_DIR:-$ARTIFACT_ROOT/data/open_perfectblend_regen_10pct_prepared}"RUN_DIR="${RUN_DIR:-$ARTIFACT_ROOT/dflash3_candidate}"BASELINE_CHECKPOINT="${BASELINE_CHECKPOINT:-$SPEC_REPO/experimental/outputs/train/dflash2_qwen3_8b_redhat_recipe_max_anchor_768_block_16_ep2_plus4/checkpoints/5}"
SELECTOR_TOP_K="${SELECTOR_TOP_K:-32}"SELECTOR_LOSS_ALPHA="${SELECTOR_LOSS_ALPHA:-1.0}"DPACE_ALPHA="${DPACE_ALPHA:-0.5}"MAX_ANCHORS="${MAX_ANCHORS:-768}"LR="${LR:-6e-4}"SEED="${SEED:-42}"BLOCK_SIZE="${BLOCK_SIZE:-16}"VLLM_GPUS="${VLLM_GPUS:-0,1,2,3}"TRAIN_GPUS="${TRAIN_GPUS:-4,5,6,7}"EVAL_GPUS="${EVAL_GPUS:-0,1,2,3}"NUM_VLLM_GPUS="${NUM_VLLM_GPUS:-4}"NUM_TRAIN_GPUS="${NUM_TRAIN_GPUS:-4}"NUM_EVAL_GPUS="${NUM_EVAL_GPUS:-4}"VLLM_PORT="${VLLM_PORT:-5513}"EVAL_PORT="${EVAL_PORT:-8513}"RUN_TRAIN="${RUN_TRAIN:-1}"RUN_EVAL="${RUN_EVAL:-1}"
SAVE_PATH="$RUN_DIR/checkpoints"HIDDEN_STATES="$RUN_DIR/hidden_states"VLLM_LOG="$RUN_DIR/vllm.log"
if [[ ! -d "$SPEC_REPO" || ! -x "$SPEC_PYTHON" || ! -x "$VLLM_PYTHON" ]]; then echo "Missing SPEC_REPO, SPEC_PYTHON, or VLLM_PYTHON; candidate was not executed." >&2 exit 3fi
mkdir -p "$RUN_DIR" "$ARTIFACT_ROOT/data"if [[ ! -f "$DATASET" ]]; then if [[ ! -f "$SOURCE_DATASET" ]]; then echo "Missing source dataset: $SOURCE_DATASET" >&2 exit 3 fi awk 'NR % 10 == 1' "$SOURCE_DATASET" > "$DATASET"fi
export HF_HUB_OFFLINE=1export TRANSFORMERS_OFFLINE=1export VLLM_USE_FLASHINFER_SAMPLER=0export OMP_NUM_THREADS="${OMP_NUM_THREADS:-4}"
if ! compgen -G "$PREPARED_DIR/*.arrow" >/dev/null; then "$SPEC_PYTHON" -m speculators prepare-data \ --model "$MODEL" \ --data "$DATASET" \ --output "$PREPARED_DIR" \ --seq-length 4096 \ --seed "$SEED"fi
if [[ "$RUN_TRAIN" != 1 ]]; then echo "Prepared data at $PREPARED_DIR" exit 0fi
IFS=',' read -r -a train_devices <<< "$TRAIN_GPUS"IFS=',' read -r -a vllm_devices <<< "$VLLM_GPUS"[[ ${#train_devices[@]} -eq "$NUM_TRAIN_GPUS" ]] || { echo "TRAIN_GPUS count does not match NUM_TRAIN_GPUS" >&2 exit 2}[[ ${#vllm_devices[@]} -eq "$NUM_VLLM_GPUS" ]] || { echo "VLLM_GPUS count does not match NUM_VLLM_GPUS" >&2 exit 2}for train_gpu in "${train_devices[@]}"; do for vllm_gpu in "${vllm_devices[@]}"; do [[ "$train_gpu" != "$vllm_gpu" ]] || { echo "Training and verifier GPU lists overlap: $train_gpu" >&2 exit 2 } donedone
CUDA_VISIBLE_DEVICES="$VLLM_GPUS" \"$VLLM_PYTHON" "$SPEC_REPO/scripts/launch_vllm.py" "$MODEL" \ --target-layer-ids 2 10 18 26 34 \ --hidden-states-path "$HIDDEN_STATES" \ --provenance-dir "$RUN_DIR" -- \ --host 127.0.0.1 \ --port "$VLLM_PORT" \ --data-parallel-size "$NUM_VLLM_GPUS" \ --tensor-parallel-size 1 \ --gpu-memory-utilization "${VLLM_GPU_MEMORY_UTILIZATION:-0.85}" \ --max-model-len 16385 \ --max-num-seqs 16 \ > "$VLLM_LOG" 2>&1 &VLLM_PID=$!cleanup() { kill "$VLLM_PID" 2>/dev/null || true wait "$VLLM_PID" 2>/dev/null || true if [[ -n "${INIT_DIR:-}" && -d "$INIT_DIR" ]]; then rm -rf -- "$INIT_DIR" fi}trap cleanup EXIT
ready=0for _ in $(seq 1 300); do if curl -sf "http://127.0.0.1:${VLLM_PORT}/health" >/dev/null 2>&1; then ready=1 break fi if ! kill -0 "$VLLM_PID" 2>/dev/null; then tail -n 200 "$VLLM_LOG" >&2 || true exit 1 fi sleep 2done[[ "$ready" == 1 ]] || { echo "Timed out waiting for verifier service." >&2 exit 1}
INIT_ARGS=()if [[ -f "$BASELINE_CHECKPOINT/model.safetensors" && -f "$BASELINE_CHECKPOINT/config.json" ]]; then INIT_DIR="$(mktemp -d "${TMPDIR:-/tmp}/specpilot-init.XXXXXXXX")" cp "$BASELINE_CHECKPOINT/config.json" "$INIT_DIR/config.json" [[ -f "$BASELINE_CHECKPOINT/config.py" ]] && cp "$BASELINE_CHECKPOINT/config.py" "$INIT_DIR/config.py" ln -sf "$BASELINE_CHECKPOINT/model.safetensors" "$INIT_DIR/model.safetensors" sed -i "s/\"selector_top_k\": 16/\"selector_top_k\": $SELECTOR_TOP_K/" "$INIT_DIR/config.json" sed -i "s/default=16/default=$SELECTOR_TOP_K/" "$INIT_DIR/config.py" 2>/dev/null || true INIT_ARGS=(--from-pretrained "$INIT_DIR")fi
CUDA_VISIBLE_DEVICES="$TRAIN_GPUS" \"$SPEC_PYTHON" -m torch.distributed.run --standalone \ --nproc_per_node "$NUM_TRAIN_GPUS" -m speculators.train \ --verifier-name-or-path "$MODEL" \ "${INIT_ARGS[@]}" \ --data-path "$PREPARED_DIR" \ --vllm-endpoint "http://127.0.0.1:${VLLM_PORT}/v1" \ --hidden-states-path "$HIDDEN_STATES" \ --save-path "$SAVE_PATH" \ --epochs 5 \ --seed "$SEED" \ --lr "$LR" \ --optimizer muon \ --weight-decay 0.01 \ --scheduler-type cosine \ --hidden-states-dtype bfloat16 \ --total-seq-len 4096 \ --speculator-type dflash2 \ --target-layer-ids 2 10 18 26 34 \ --block-size "$BLOCK_SIZE" \ --max-anchors "$MAX_ANCHORS" \ --loss-fn ce \ --per-position-loss-weight dpace \ --dpace-alpha "$DPACE_ALPHA" \ --conv-kernel-size 2 \ --conv-group-size 16 \ --selector-rank 256 \ --selector-top-k "$SELECTOR_TOP_K" \ --selector-loss-alpha "$SELECTOR_LOSS_ALPHA" \ --muon-lr 0.003 \ --muon-momentum 0.95 \ --muon-weight-decay 0.1 \ --muon-ns-steps 5 \ --on-missing generate
if [[ "$RUN_EVAL" == 1 ]]; then cleanup trap - EXIT DFLASH3_OUTPUT_DIR="$RUN_DIR" \ DFLASH3_CHECKPOINT="${DFLASH3_CHECKPOINT:-$SAVE_PATH/4}" \ EVAL_GPUS="$EVAL_GPUS" \ NUM_EVAL_GPUS="$NUM_EVAL_GPUS" \ PORT="$EVAL_PORT" \ bash "$TASK_ROOT/solution/eval_specpilot.sh"fi1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889#!/usr/bin/env bashset -u -o pipefail
TASK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"ARTIFACT_ROOT="$TASK_ROOT/artifacts"STATE="$ARTIFACT_ROOT/specpilot_state.json"PLAN="$ARTIFACT_ROOT/candidate_plan.json"REPORT="$TASK_ROOT/specpilot_results.md"ARTIFACT_REPORT="$ARTIFACT_ROOT/specpilot_results.md"BASELINE="$ARTIFACT_ROOT/baseline_metrics.json"BASE_RUNNER="$ARTIFACT_ROOT/run_dflash3_10pct_5ep.sh"CONTROLLER="$ARTIFACT_ROOT/specpilot.py"RUN_ROOT="${SPECPILOT_RUN_ROOT:-$ARTIFACT_ROOT/specpilot_runs}"TRIALS="${SPECPILOT_TRIALS:-3}"RUN_SPECPILOT="${RUN_SPECPILOT:-0}"
if [[ "$RUN_SPECPILOT" != 1 ]]; then echo "Set RUN_SPECPILOT=1 to execute the GPU search loop." >&2 exit 2fi[[ "$TRIALS" =~ ^[1-9][0-9]*$ ]] || { echo "SPECPILOT_TRIALS must be a positive integer." >&2 exit 2}
mkdir -p "$RUN_ROOT"python3 "$CONTROLLER" init --state "$STATE" --plan "$PLAN" --run-root "$RUN_ROOT"
completed=0while (( completed < TRIALS )); do candidate_line="$(python3 "$CONTROLLER" next --state "$STATE" --plan "$PLAN" 2>/dev/null)" rc=$? if [[ "$rc" != 0 || -z "$candidate_line" ]]; then echo "No untried candidate remains." break fi IFS=$'\t' read -r name selector_top_k selector_loss_alpha dpace_alpha max_anchors lr <<< "$candidate_line" candidate_dir="$RUN_ROOT/$name" mkdir -p "$candidate_dir" printf '%s\n' "Running $name: k=$selector_top_k selector_alpha=$selector_loss_alpha dpace=$dpace_alpha anchors=$max_anchors lr=$lr"
RUN_DIR="$candidate_dir" \ SELECTOR_TOP_K="$selector_top_k" \ SELECTOR_LOSS_ALPHA="$selector_loss_alpha" \ DPACE_ALPHA="$dpace_alpha" \ MAX_ANCHORS="$max_anchors" \ LR="$lr" \ VLLM_GPUS="${VLLM_GPUS:-0,1,2,3}" \ TRAIN_GPUS="${TRAIN_GPUS:-4,5,6,7}" \ EVAL_GPUS="${EVAL_GPUS:-0,1,2,3}" \ NUM_VLLM_GPUS="${NUM_VLLM_GPUS:-4}" \ NUM_TRAIN_GPUS="${NUM_TRAIN_GPUS:-4}" \ NUM_EVAL_GPUS="${NUM_EVAL_GPUS:-4}" \ RUN_TRAIN=1 \ RUN_EVAL=1 \ bash "$BASE_RUNNER" >> "$candidate_dir/run.log" 2>&1 run_rc=$? printf '%s\n' "{\"exit_code\": $run_rc}" > "$candidate_dir/runtime.json"
if [[ "$run_rc" == 0 ]]; then status="complete" else status="runtime_failed" fi python3 "$CONTROLLER" record \ --state "$STATE" \ --plan "$PLAN" \ --name "$name" \ --candidate-dir "$candidate_dir" \ --status "$status" python3 "$CONTROLLER" render \ --state "$STATE" \ --baseline "$BASELINE" \ --report "$REPORT" cp "$REPORT" "$ARTIFACT_REPORT" if [[ "$run_rc" != 0 ]]; then echo "Candidate $name failed (exit $run_rc); see $candidate_dir/run.log" >&2 exit "$run_rc" fi completed=$((completed + 1))done
python3 "$CONTROLLER" render \ --state "$STATE" \ --baseline "$BASELINE" \ --report "$REPORT"cp "$REPORT" "$ARTIFACT_REPORT"echo "SpecPilot state: $STATE"echo "SpecPilot report: $REPORT"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294#!/usr/bin/env python3"""Small dependency-free controller for the SpecPilot candidate tournament."""
from __future__ import annotations
import argparseimport jsonfrom pathlib import Pathfrom typing import Any
BENCHMARKS = ("mt-bench", "humaneval", "math500")NEIGHBORS = { "selector_top_k": (16, 24, 32, 48, 64), "selector_loss_alpha": (0.5, 1.0, 1.5, 2.0), "dpace_alpha": (0.3, 0.5, 0.7, 0.9), "max_anchors": (512, 768, 1024, 1536), "lr": (0.0004, 0.0006, 0.0008),}
def load_json(path: Path, default: Any) -> Any: if not path.is_file(): return default return json.loads(path.read_text())
def save_json(path: Path, value: Any) -> None: path.parent.mkdir(parents=True, exist_ok=True) path.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n")
def numeric_checkpoints(root: Path) -> list[Path]: result = [] for path in root.glob("checkpoints/*"): if path.is_dir() and path.name.isdigit(): result.append(path) return sorted(result, key=lambda path: int(path.name))
def metric_value(path: Path, key: str) -> float | None: data = load_json(path, {}) value = data.get(key) return float(value) if isinstance(value, (int, float)) else None
def read_result(candidate_dir: Path) -> dict[str, Any]: checkpoints = numeric_checkpoints(candidate_dir) validation = {} if checkpoints: validation = load_json(checkpoints[-1] / "val_metrics.json", {}) benchmark_values = { name: metric_value( candidate_dir / "eval_epoch5" / f"{name}.json", "acceptance_length" ) for name in BENCHMARKS } accepted = validation.get("accept_len_epoch") accepted = float(accepted) if isinstance(accepted, (int, float)) else None values = [value for value in benchmark_values.values() if value is not None] mean_benchmark = sum(values) / len(values) if len(values) == 3 else None score = ( accepted * 100.0 + mean_benchmark if accepted is not None and mean_benchmark is not None else None ) runtime = load_json(candidate_dir / "runtime.json", {}) return { "validation": validation, "benchmarks": benchmark_values, "validation_accept_len": accepted, "mean_benchmark_acceptance": mean_benchmark, "score": score, "checkpoint": str(checkpoints[-1]) if checkpoints else None, "exit_code": runtime.get("exit_code"), }
def candidate_key(candidate: dict[str, Any]) -> tuple[Any, ...]: return tuple(candidate.get(name) for name in NEIGHBORS)
def propose_neighbors(best: dict[str, Any], tried: set[tuple[Any, ...]]) -> list[dict[str, Any]]: proposals = [] for field, values in NEIGHBORS.items(): current = best.get(field) for value in values: if value == current: continue candidate = dict(best) candidate[field] = value candidate["name"] = f"adaptive_{field}_{str(value).replace('.', 'p')}" candidate["epochs"] = 5 candidate["dataset_fraction"] = 0.1 if candidate_key(candidate) not in tried: proposals.append(candidate) return proposals
def load_state(path: Path) -> dict[str, Any]: return load_json(path, {"version": 1, "history": [], "active": None})
def all_candidates(plan_path: Path, state: dict[str, Any]) -> list[dict[str, Any]]: plan = load_json(plan_path, []) candidates = list(plan) history = state.get("history", []) tried = {candidate_key(item["config"]) for item in history if "config" in item} completed = [item for item in history if item.get("result", {}).get("score") is not None] if completed: best = max(completed, key=lambda item: item["result"]["score"])["config"] candidates.extend(propose_neighbors(best, tried | {candidate_key(c) for c in candidates})) unique = [] seen = set() for candidate in candidates: key = candidate_key(candidate) if key not in seen: seen.add(key) unique.append(candidate) return unique
def cmd_init(args: argparse.Namespace) -> None: state = load_state(args.state) state.setdefault("version", 1) state.setdefault("history", []) state["plan"] = str(args.plan) state["run_root"] = str(args.run_root) save_json(args.state, state)
def cmd_next(args: argparse.Namespace) -> None: state = load_state(args.state) history = state.get("history", []) latest_by_name = {} for item in history: latest_by_name[item.get("name")] = item terminal_names = set() for name, item in latest_by_name.items(): result = item.get("result", {}) status = result.get("status") if status != "runtime_failed": terminal_names.add(name) candidates = all_candidates(args.plan, state) for candidate in candidates: if candidate["name"] not in terminal_names: fields = ( candidate["name"], str(candidate["selector_top_k"]), str(candidate["selector_loss_alpha"]), str(candidate["dpace_alpha"]), str(candidate["max_anchors"]), str(candidate["lr"]), ) print("\t".join(fields)) return raise SystemExit(1)
def cmd_record(args: argparse.Namespace) -> None: state = load_state(args.state) history = state.setdefault("history", []) candidates = all_candidates(args.plan, state) config = next((item for item in candidates if item["name"] == args.name), None) if config is None: raise SystemExit(f"candidate not found: {args.name}") result = read_result(args.candidate_dir) result["status"] = args.status previous = next( (item for item in reversed(history) if item.get("name") == args.name), None, ) attempts = int(previous.get("attempts", 1)) + 1 if previous else 1 entry = { "name": args.name, "config": config, "result": result, "attempts": attempts, } history[:] = [item for item in history if item.get("name") != args.name] history.append(entry) state["active"] = None save_json(args.state, state)
def cmd_render(args: argparse.Namespace) -> None: state = load_state(args.state) baseline = load_json(args.baseline, {}) lines = [ "# SpecPilot Experiment Results", "", f"Status: **{'complete' if any(item.get('result', {}).get('score') is not None for item in state.get('history', [])) else 'partial' if state.get('history') else 'pending'}**", "", "This report is generated by the resumable SpecPilot controller.", "", "## Baseline", "", "| Metric | DFlash2 baseline |", "|---|---:|", f"| Validation accepted length | {baseline.get('validation', {}).get('accept_len_epoch', 'pending')} |", f"| MT-Bench acceptance length | {baseline.get('mt-bench', {}).get('acceptance_length', 'pending')} |", f"| HumanEval acceptance length | {baseline.get('humaneval', {}).get('acceptance_length', 'pending')} |", f"| MATH500 acceptance length | {baseline.get('math500', {}).get('acceptance_length', 'pending')} |", "", "## Candidate history", "", "| Candidate | Status | Config | Validation accepted length | Mean benchmark acceptance | Score |", "|---|---|---|---:|---:|---:|", ] completed = [] for item in state.get("history", []): result = item.get("result", {}) config = item.get("config", {}) config_text = ( f"k={config.get('selector_top_k')}, " f"sel_alpha={config.get('selector_loss_alpha')}, " f"dpace={config.get('dpace_alpha')}, " f"anchors={config.get('max_anchors')}, lr={config.get('lr')}" ) def fmt(value: Any) -> str: return "pending" if value is None else f"{float(value):.4f}" lines.append( f"| {item.get('name')} | {result.get('status', 'unknown')} (attempt {item.get('attempts', 1)}) | " f"{config_text} | {fmt(result.get('validation_accept_len'))} | " f"{fmt(result.get('mean_benchmark_acceptance'))} | " f"{fmt(result.get('score'))} |" ) if result.get("score") is not None: completed.append(item) lines.extend( [ "", "## Best candidate", "", ] ) if completed: best = max(completed, key=lambda item: item["result"]["score"]) lines.append( f"`{best['name']}` with score " f"`{best['result']['score']:.4f}` and checkpoint " f"`{best['result'].get('checkpoint')}`." ) else: lines.append("No candidate has complete validation and benchmark metrics.") lines.extend( [ "", "## Limitations", "", "Failures and missing runtime dependencies are recorded as pending " "metrics; no metric is fabricated.", "", f"State file: `{args.state}`", ] ) args.report.write_text("\n".join(lines) + "\n")
def main() -> None: parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest="command", required=True)
init = subparsers.add_parser("init") init.add_argument("--state", type=Path, required=True) init.add_argument("--plan", type=Path, required=True) init.add_argument("--run-root", type=Path, required=True) init.set_defaults(func=cmd_init)
next_parser = subparsers.add_parser("next") next_parser.add_argument("--state", type=Path, required=True) next_parser.add_argument("--plan", type=Path, required=True) next_parser.set_defaults(func=cmd_next)
record = subparsers.add_parser("record") record.add_argument("--state", type=Path, required=True) record.add_argument("--plan", type=Path, required=True) record.add_argument("--name", required=True) record.add_argument("--candidate-dir", type=Path, required=True) record.add_argument("--status", required=True) record.set_defaults(func=cmd_record)
render = subparsers.add_parser("render") render.add_argument("--state", type=Path, required=True) render.add_argument("--baseline", type=Path, required=True) render.add_argument("--report", type=Path, required=True) render.set_defaults(func=cmd_render)
args = parser.parse_args() args.func(args)
if __name__ == "__main__": main()1234567891011121314151617181920212223242526272829303132# SpecPilot Experiment Results
Status: **partial**
This report is generated by the resumable SpecPilot controller.
## Baseline
| Metric | DFlash2 baseline ||---|---:|| Validation accepted length | 5.953488872407978 || MT-Bench acceptance length | 2.8897184300341294 || HumanEval acceptance length | 3.214498354833655 || MATH500 acceptance length | 3.6829078734979372 |
## Candidate history
| Candidate | Status | Config | Validation accepted length | Mean benchmark acceptance | Score ||---|---|---|---:|---:|---:|| control_selector32 | complete (attempt 2) | k=32, sel_alpha=1.0, dpace=0.5, anchors=768, lr=0.0006 | pending | 2.9236 | pending || selector24 | complete (attempt 2) | k=24, sel_alpha=1.0, dpace=0.5, anchors=768, lr=0.0006 | pending | 2.8950 | pending || selector48 | complete (attempt 2) | k=48, sel_alpha=1.0, dpace=0.5, anchors=768, lr=0.0006 | pending | 2.9378 | pending |
## Best candidate
No candidate has complete validation and benchmark metrics.
## Limitations
Failures and missing runtime dependencies are recorded as pending metrics; no metric is fabricated.
State file: `/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot/artifacts/specpilot_state.json`123456789101112131415161718{ "validation": { "accept_len_epoch": 5.953488872407978, "accept_rate_epoch": 0.4398621302451192, "eal_epoch": 7.1277821658634934, "loss_epoch": 1.2213575182325183, "teacher_forced_selector_acc_epoch": 0.8323225238395741 }, "mt-bench": { "acceptance_length": 2.8897184300341294 }, "humaneval": { "acceptance_length": 3.214498354833655 }, "math500": { "acceptance_length": 3.6829078734979372 }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112[ { "name": "control_selector32", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector24", "selector_top_k": 24, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector48", "selector_top_k": 48, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector_alpha05", "selector_top_k": 32, "selector_loss_alpha": 0.5, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "selector_alpha20", "selector_top_k": 32, "selector_loss_alpha": 2.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "dpace_alpha03", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.3, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "dpace_alpha07", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.7, "max_anchors": 768, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "anchors512", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 512, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "anchors1024", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 1024, "lr": 0.0006, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "lr4e4", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0004, "epochs": 5, "dataset_fraction": 0.1 }, { "name": "lr8e4", "selector_top_k": 32, "selector_loss_alpha": 1.0, "dpace_alpha": 0.5, "max_anchors": 768, "lr": 0.0008, "epochs": 5, "dataset_fraction": 0.1 }]123FROM ubuntu:24.04
WORKDIR /app12345678910111213141516171819202122232425262728293031323334353637# SpecPilot Task Contract
This task is an autonomous hyperparameter tournament around the suppliedDFlash2 Qwen3-8B recipe. It is a recipe search, not a claim that a new servingarchitecture has been implemented.
## Fixed conditions
- deterministic source subset: every tenth JSONL record- total training epochs per candidate: 5- seed: 42- total sequence length: 4096- target layers: 2, 10, 18, 26, 34- speculator type: `dflash2`- block size: 16- convolution kernel/group: 2/16- selector rank: 256- optimizer: Muon- base learning rate: `6e-4`- D-PACE loss and cross entropy- verifier GPUs: 0,1,2,3- training GPUs: 4,5,6,7
The control candidate is selector top-k 32, selector loss alpha 1.0,D-PACE alpha 0.5, max anchors 768, and learning rate `6e-4`. Candidatevariants change one of these five values. The controller may propose localneighbors around the best completed candidate after the seed plan is exhausted.
## Outputs
- `artifacts/specpilot_state.json`: resumable controller state- `artifacts/specpilot_results.md`: candidate table and limitations- `artifacts/specpilot_runs/<candidate>/`: isolated run output- `artifacts/data/open_perfectblend_regen_10pct.jsonl`: deterministic subset
No metric is considered valid unless it is read from a candidate checkpoint orfrom the acceptance evaluator output.12345678910111213141516171819202122232425262728293031323334353637# SpecPilot Optimization Directions
## Control
The control is the existing DFlash3 recipe with selector top-k 32, 10% data,and 5 epochs. It establishes the local comparison point for the tournament.
## Controlled search
The first candidates vary one parameter at a time:
| Direction | Values | Expected signal ||---|---|---|| Selector width | 24, 48 | unary recall and accepted length || Selector supervision | alpha 0.5, 2.0 | selector accuracy and acceptance || D-PACE smoothing | alpha 0.3, 0.7 | later-position accuracy || Anchor budget | 512, 1024 | quality versus training cost || Learning rate | `4e-4`, `8e-4` | convergence stability |
After the seed candidates, SpecPilot proposes one-variable neighbors aroundthe best scored candidate while avoiding configurations already tried.
## Selection rule
Primary score: validation `accept_len_epoch`.
Secondary score: arithmetic mean of MT-Bench, HumanEval, and MATH500`acceptance_length`.
The report keeps both components and does not hide missing or failed metrics.All candidates use isolated output directories and can be resumed.
## Runtime caution
The Qwen3-8B verifier may require substantial free memory. A failed vLLMstartup or missing external checkpoint is recorded as a limitation and is notconverted into a synthetic score.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071# DFlash3 SpecPilot
Build and run an autonomous, reproducible DFlash2-compatible optimization loopfor the Qwen3-8B speculative draft model. The task is intended to run on an8-GPU host.
The upstream reference recipe is:
- training: `/high_perf_store3/world-model/weixiaobao/zlj/speculators-main/examples/train/dflash2_qwen3_8b_redhat_train_max_anchors_768_block_16.sh`- evaluation: `/high_perf_store3/world-model/weixiaobao/zlj/speculators-main/examples/evaluate/eval_dflash2_qwen3_8b_redhat_other_model_v2_max_anchor_762_block_16.sh`- controlled runner: `/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3/artifacts/run_dflash3_10pct_5ep.sh`
Do not store, print, or commit credentials. OpenAI credentials are injectedexternally by Harbor.
## Required behavior
1. Use the deterministic 10% subset of `open_perfectblend_regen.jsonl`.2. Train every candidate for exactly 5 total epochs.3. Use GPUs `0,1,2,3` for the verifier/vLLM service and GPUs `4,5,6,7` for speculator training. Reuse GPUs `0,1,2,3` for acceptance evaluation.4. Keep the DFlash2-compatible architecture, target layers, block size 16, seed 42, optimizer, loss, and sequence length fixed unless a controlled candidate explicitly changes one search variable.5. Search only supported training flags. The initial controlled candidates are selector top-k, selector loss alpha, D-PACE alpha, max anchors, and learning rate. Change one variable at a time relative to the control.6. After each candidate, read validation metrics and acceptance metrics. Score candidates using the validation accepted length as the primary metric and the mean MT-Bench, HumanEval, and MATH500 acceptance length as the secondary metric.7. Persist state after every candidate so an interrupted run can resume without losing completed results. Never overwrite another candidate's output.8. Write the full experiment history, candidate configurations, failures, unavailable-runtime limitations, and the best candidate to `specpilot_results.md` in the task root and mirror it under `artifacts/`.
The executable loop is:
```bashRUN_SPECPILOT=1 \SPECPILOT_TRIALS=3 \bash artifacts/run_specpilot_8gpu.sh```
Set `SPECPILOT_TRIALS` higher to continue the search. The loop is resumable:completed candidates in `artifacts/specpilot_state.json` are skipped. Therunner does not fabricate metrics when a GPU, checkpoint, dataset, or externalevaluation dependency is unavailable.
The Harbor launch command is:
```bashconda activate jyh-uni-agent-harborexport OPENAI_API_KEY='<NEW_OPENAI_API_KEY>'harbor run \ --path /high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot \ --agent codex \ --model openai/gpt-6-sol \ --job-name specpilot-h3 \ --yes```
The key above is a placeholder. Never paste a live key into this repository orinto the command history.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186#!/usr/bin/env bashset -euo pipefail
TASK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"ARTIFACT_ROOT="$TASK_ROOT/artifacts"
SPEC_REPO="${SPEC_REPO:-/high_perf_store3/world-model/weixiaobao/zlj/speculators-main}"SPEC_PYTHON="${SPEC_PYTHON:-/high_perf_store3/world-model/weixiaobao/yzj/speculators/.venv/bin/python}"VLLM_PYTHON="${VLLM_PYTHON:-/high_perf_store3/world-model/weixiaobao/yzj/vllm_env/bin/python}"MODEL="${MODEL:-$SPEC_REPO/Qwen3-8B}"SOURCE_DATASET="${SOURCE_DATASET:-$SPEC_REPO/experimental/outputs/open_perfectblend_regen/open_perfectblend_regen.jsonl}"DATASET="${DATASET:-$ARTIFACT_ROOT/data/open_perfectblend_regen_10pct.jsonl}"PREPARED_DIR="${PREPARED_DIR:-$ARTIFACT_ROOT/data/open_perfectblend_regen_10pct_prepared}"RUN_DIR="${RUN_DIR:-$ARTIFACT_ROOT/dflash3_candidate}"BASELINE_CHECKPOINT="${BASELINE_CHECKPOINT:-$SPEC_REPO/experimental/outputs/train/dflash2_qwen3_8b_redhat_recipe_max_anchor_768_block_16_ep2_plus4/checkpoints/5}"
SELECTOR_TOP_K="${SELECTOR_TOP_K:-32}"SELECTOR_LOSS_ALPHA="${SELECTOR_LOSS_ALPHA:-1.0}"DPACE_ALPHA="${DPACE_ALPHA:-0.5}"MAX_ANCHORS="${MAX_ANCHORS:-768}"LR="${LR:-6e-4}"SEED="${SEED:-42}"BLOCK_SIZE="${BLOCK_SIZE:-16}"VLLM_GPUS="${VLLM_GPUS:-0,1,2,3}"TRAIN_GPUS="${TRAIN_GPUS:-4,5,6,7}"EVAL_GPUS="${EVAL_GPUS:-0,1,2,3}"NUM_VLLM_GPUS="${NUM_VLLM_GPUS:-4}"NUM_TRAIN_GPUS="${NUM_TRAIN_GPUS:-4}"NUM_EVAL_GPUS="${NUM_EVAL_GPUS:-4}"VLLM_PORT="${VLLM_PORT:-5513}"EVAL_PORT="${EVAL_PORT:-8513}"RUN_TRAIN="${RUN_TRAIN:-1}"RUN_EVAL="${RUN_EVAL:-1}"
SAVE_PATH="$RUN_DIR/checkpoints"HIDDEN_STATES="$RUN_DIR/hidden_states"VLLM_LOG="$RUN_DIR/vllm.log"
if [[ ! -d "$SPEC_REPO" || ! -x "$SPEC_PYTHON" || ! -x "$VLLM_PYTHON" ]]; then echo "Missing SPEC_REPO, SPEC_PYTHON, or VLLM_PYTHON; candidate was not executed." >&2 exit 3fi
mkdir -p "$RUN_DIR" "$ARTIFACT_ROOT/data"if [[ ! -f "$DATASET" ]]; then if [[ ! -f "$SOURCE_DATASET" ]]; then echo "Missing source dataset: $SOURCE_DATASET" >&2 exit 3 fi awk 'NR % 10 == 1' "$SOURCE_DATASET" > "$DATASET"fi
export HF_HUB_OFFLINE=1export TRANSFORMERS_OFFLINE=1export VLLM_USE_FLASHINFER_SAMPLER=0export OMP_NUM_THREADS="${OMP_NUM_THREADS:-4}"
if ! compgen -G "$PREPARED_DIR/*.arrow" >/dev/null; then "$SPEC_PYTHON" -m speculators prepare-data \ --model "$MODEL" \ --data "$DATASET" \ --output "$PREPARED_DIR" \ --seq-length 4096 \ --seed "$SEED"fi
if [[ "$RUN_TRAIN" != 1 ]]; then echo "Prepared data at $PREPARED_DIR" exit 0fi
IFS=',' read -r -a train_devices <<< "$TRAIN_GPUS"IFS=',' read -r -a vllm_devices <<< "$VLLM_GPUS"[[ ${#train_devices[@]} -eq "$NUM_TRAIN_GPUS" ]] || { echo "TRAIN_GPUS count does not match NUM_TRAIN_GPUS" >&2 exit 2}[[ ${#vllm_devices[@]} -eq "$NUM_VLLM_GPUS" ]] || { echo "VLLM_GPUS count does not match NUM_VLLM_GPUS" >&2 exit 2}for train_gpu in "${train_devices[@]}"; do for vllm_gpu in "${vllm_devices[@]}"; do [[ "$train_gpu" != "$vllm_gpu" ]] || { echo "Training and verifier GPU lists overlap: $train_gpu" >&2 exit 2 } donedone
CUDA_VISIBLE_DEVICES="$VLLM_GPUS" \"$VLLM_PYTHON" "$SPEC_REPO/scripts/launch_vllm.py" "$MODEL" \ --target-layer-ids 2 10 18 26 34 \ --hidden-states-path "$HIDDEN_STATES" \ --provenance-dir "$RUN_DIR" -- \ --host 127.0.0.1 \ --port "$VLLM_PORT" \ --data-parallel-size "$NUM_VLLM_GPUS" \ --tensor-parallel-size 1 \ --gpu-memory-utilization "${VLLM_GPU_MEMORY_UTILIZATION:-0.85}" \ --max-model-len 16385 \ --max-num-seqs 16 \ > "$VLLM_LOG" 2>&1 &VLLM_PID=$!cleanup() { kill "$VLLM_PID" 2>/dev/null || true wait "$VLLM_PID" 2>/dev/null || true if [[ -n "${INIT_DIR:-}" && -d "$INIT_DIR" ]]; then rm -rf -- "$INIT_DIR" fi}trap cleanup EXIT
ready=0for _ in $(seq 1 300); do if curl -sf "http://127.0.0.1:${VLLM_PORT}/health" >/dev/null 2>&1; then ready=1 break fi if ! kill -0 "$VLLM_PID" 2>/dev/null; then tail -n 200 "$VLLM_LOG" >&2 || true exit 1 fi sleep 2done[[ "$ready" == 1 ]] || { echo "Timed out waiting for verifier service." >&2 exit 1}
INIT_ARGS=()if [[ -f "$BASELINE_CHECKPOINT/model.safetensors" && -f "$BASELINE_CHECKPOINT/config.json" ]]; then INIT_DIR="$(mktemp -d "${TMPDIR:-/tmp}/specpilot-init.XXXXXXXX")" cp "$BASELINE_CHECKPOINT/config.json" "$INIT_DIR/config.json" [[ -f "$BASELINE_CHECKPOINT/config.py" ]] && cp "$BASELINE_CHECKPOINT/config.py" "$INIT_DIR/config.py" ln -sf "$BASELINE_CHECKPOINT/model.safetensors" "$INIT_DIR/model.safetensors" sed -i "s/\"selector_top_k\": 16/\"selector_top_k\": $SELECTOR_TOP_K/" "$INIT_DIR/config.json" sed -i "s/default=16/default=$SELECTOR_TOP_K/" "$INIT_DIR/config.py" 2>/dev/null || true INIT_ARGS=(--from-pretrained "$INIT_DIR")fi
CUDA_VISIBLE_DEVICES="$TRAIN_GPUS" \"$SPEC_PYTHON" -m torch.distributed.run --standalone \ --nproc_per_node "$NUM_TRAIN_GPUS" -m speculators.train \ --verifier-name-or-path "$MODEL" \ "${INIT_ARGS[@]}" \ --data-path "$PREPARED_DIR" \ --vllm-endpoint "http://127.0.0.1:${VLLM_PORT}/v1" \ --hidden-states-path "$HIDDEN_STATES" \ --save-path "$SAVE_PATH" \ --epochs 5 \ --seed "$SEED" \ --lr "$LR" \ --optimizer muon \ --weight-decay 0.01 \ --scheduler-type cosine \ --hidden-states-dtype bfloat16 \ --total-seq-len 4096 \ --speculator-type dflash2 \ --target-layer-ids 2 10 18 26 34 \ --block-size "$BLOCK_SIZE" \ --max-anchors "$MAX_ANCHORS" \ --loss-fn ce \ --per-position-loss-weight dpace \ --dpace-alpha "$DPACE_ALPHA" \ --conv-kernel-size 2 \ --conv-group-size 16 \ --selector-rank 256 \ --selector-top-k "$SELECTOR_TOP_K" \ --selector-loss-alpha "$SELECTOR_LOSS_ALPHA" \ --muon-lr 0.003 \ --muon-momentum 0.95 \ --muon-weight-decay 0.1 \ --muon-ns-steps 5 \ --on-missing generate
if [[ "$RUN_EVAL" == 1 ]]; then cleanup trap - EXIT DFLASH3_OUTPUT_DIR="$RUN_DIR" \ DFLASH3_CHECKPOINT="${DFLASH3_CHECKPOINT:-$SAVE_PATH/4}" \ EVAL_GPUS="$EVAL_GPUS" \ NUM_EVAL_GPUS="$NUM_EVAL_GPUS" \ PORT="$EVAL_PORT" \ bash "$TASK_ROOT/solution/eval_specpilot.sh"fi1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889#!/usr/bin/env bashset -u -o pipefail
TASK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"ARTIFACT_ROOT="$TASK_ROOT/artifacts"STATE="$ARTIFACT_ROOT/specpilot_state.json"PLAN="$ARTIFACT_ROOT/candidate_plan.json"REPORT="$TASK_ROOT/specpilot_results.md"ARTIFACT_REPORT="$ARTIFACT_ROOT/specpilot_results.md"BASELINE="$ARTIFACT_ROOT/baseline_metrics.json"BASE_RUNNER="$ARTIFACT_ROOT/run_dflash3_10pct_5ep.sh"CONTROLLER="$ARTIFACT_ROOT/specpilot.py"RUN_ROOT="${SPECPILOT_RUN_ROOT:-$ARTIFACT_ROOT/specpilot_runs}"TRIALS="${SPECPILOT_TRIALS:-3}"RUN_SPECPILOT="${RUN_SPECPILOT:-0}"
if [[ "$RUN_SPECPILOT" != 1 ]]; then echo "Set RUN_SPECPILOT=1 to execute the GPU search loop." >&2 exit 2fi[[ "$TRIALS" =~ ^[1-9][0-9]*$ ]] || { echo "SPECPILOT_TRIALS must be a positive integer." >&2 exit 2}
mkdir -p "$RUN_ROOT"python3 "$CONTROLLER" init --state "$STATE" --plan "$PLAN" --run-root "$RUN_ROOT"
completed=0while (( completed < TRIALS )); do candidate_line="$(python3 "$CONTROLLER" next --state "$STATE" --plan "$PLAN" 2>/dev/null)" rc=$? if [[ "$rc" != 0 || -z "$candidate_line" ]]; then echo "No untried candidate remains." break fi IFS=$'\t' read -r name selector_top_k selector_loss_alpha dpace_alpha max_anchors lr <<< "$candidate_line" candidate_dir="$RUN_ROOT/$name" mkdir -p "$candidate_dir" printf '%s\n' "Running $name: k=$selector_top_k selector_alpha=$selector_loss_alpha dpace=$dpace_alpha anchors=$max_anchors lr=$lr"
RUN_DIR="$candidate_dir" \ SELECTOR_TOP_K="$selector_top_k" \ SELECTOR_LOSS_ALPHA="$selector_loss_alpha" \ DPACE_ALPHA="$dpace_alpha" \ MAX_ANCHORS="$max_anchors" \ LR="$lr" \ VLLM_GPUS="${VLLM_GPUS:-0,1,2,3}" \ TRAIN_GPUS="${TRAIN_GPUS:-4,5,6,7}" \ EVAL_GPUS="${EVAL_GPUS:-0,1,2,3}" \ NUM_VLLM_GPUS="${NUM_VLLM_GPUS:-4}" \ NUM_TRAIN_GPUS="${NUM_TRAIN_GPUS:-4}" \ NUM_EVAL_GPUS="${NUM_EVAL_GPUS:-4}" \ RUN_TRAIN=1 \ RUN_EVAL=1 \ bash "$BASE_RUNNER" >> "$candidate_dir/run.log" 2>&1 run_rc=$? printf '%s\n' "{\"exit_code\": $run_rc}" > "$candidate_dir/runtime.json"
if [[ "$run_rc" == 0 ]]; then status="complete" else status="runtime_failed" fi python3 "$CONTROLLER" record \ --state "$STATE" \ --plan "$PLAN" \ --name "$name" \ --candidate-dir "$candidate_dir" \ --status "$status" python3 "$CONTROLLER" render \ --state "$STATE" \ --baseline "$BASELINE" \ --report "$REPORT" cp "$REPORT" "$ARTIFACT_REPORT" if [[ "$run_rc" != 0 ]]; then echo "Candidate $name failed (exit $run_rc); see $candidate_dir/run.log" >&2 exit "$run_rc" fi completed=$((completed + 1))done
python3 "$CONTROLLER" render \ --state "$STATE" \ --baseline "$BASELINE" \ --report "$REPORT"cp "$REPORT" "$ARTIFACT_REPORT"echo "SpecPilot state: $STATE"echo "SpecPilot report: $REPORT"1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677#!/usr/bin/env bashset -euo pipefail
TASK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"SPEC_REPO="${SPEC_REPO:-/high_perf_store3/world-model/weixiaobao/zlj/speculators-main}"VLLM_PYTHON="${VLLM_PYTHON:-/high_perf_store3/world-model/weixiaobao/yzj/vllm_env/bin/python}"MODEL="${MODEL:-$SPEC_REPO/Qwen3-8B}"OUTPUT_DIR="${DFLASH3_OUTPUT_DIR:?DFLASH3_OUTPUT_DIR is required}"CHECKPOINT="${DFLASH3_CHECKPOINT:?DFLASH3_CHECKPOINT is required}"EVAL_DATASETS="${EVAL_DATASETS:-/high_perf_store3/world-model/weixiaobao/yzj/DeepSpec/eval_datasets}"EVAL_GPUS="${EVAL_GPUS:-0,1,2,3}"NUM_EVAL_GPUS="${NUM_EVAL_GPUS:-4}"PORT="${PORT:-8513}"OUT="$OUTPUT_DIR/eval_epoch5"LOG="$OUTPUT_DIR/eval_logs"
[[ -d "$MODEL" ]] || { echo "Target model is missing: $MODEL" >&2; exit 3; }[[ -d "$CHECKPOINT" ]] || { echo "Checkpoint is missing: $CHECKPOINT" >&2; exit 3; }mkdir -p "$OUT" "$LOG"IFS=',' read -r -a eval_devices <<< "$EVAL_GPUS"[[ ${#eval_devices[@]} -eq "$NUM_EVAL_GPUS" ]] || { echo "EVAL_GPUS count does not match NUM_EVAL_GPUS" >&2 exit 2}
export HF_HUB_OFFLINE=1export TRANSFORMERS_OFFLINE=1export VLLM_USE_FLASHINFER_SAMPLER=0
CUDA_VISIBLE_DEVICES="$EVAL_GPUS" \"$VLLM_PYTHON" "$SPEC_REPO/scripts/launch_vllm.py" eval "$MODEL" \ --spec-model "$CHECKPOINT" \ --spec-tokens 7 \ --provenance-dir "$OUT" -- \ --host 127.0.0.1 \ --port "$PORT" \ --tensor-parallel-size 1 \ --data-parallel-size "$NUM_EVAL_GPUS" \ --gpu-memory-utilization "${EVAL_GPU_MEMORY_UTILIZATION:-0.7}" \ --max-model-len 4096 \ --trust-remote-code \ --seed 0 \ --max-num-seqs 64 \ > "$LOG/serve.log" 2>&1 &PID=$!cleanup() { kill "$PID" 2>/dev/null || true wait "$PID" 2>/dev/null || true}trap cleanup EXIT
ready=0for _ in $(seq 1 300); do if curl -sf "http://127.0.0.1:${PORT}/health" >/dev/null 2>&1; then ready=1 break fi if ! kill -0 "$PID" 2>/dev/null; then tail -n 200 "$LOG/serve.log" >&2 || true exit 1 fi sleep 2done[[ "$ready" == 1 ]] || { echo "Timed out waiting for evaluation service." >&2; exit 1; }
for task in mt-bench:80 humaneval:120 math500:120; do name="${task%%:*}" limit="${task##*:}" "$VLLM_PYTHON" "$SPEC_REPO/experimental/scripts/eval/eval_acceptance.py" \ --base-url "http://127.0.0.1:${PORT}" \ --data "$EVAL_DATASETS/$name.jsonl" \ --limit "$limit" \ --max-tokens 512 \ --temperature 0 \ --concurrency 24 \ --out "$OUT/$name.json"done1234567#!/usr/bin/env bashset -euo pipefail
TASK_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"RUN_SPECPILOT="${RUN_SPECPILOT:-1}" \SPECPILOT_TRIALS="${SPECPILOT_TRIALS:-3}" \bash "$TASK_ROOT/artifacts/run_specpilot_8gpu.sh"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294#!/usr/bin/env python3"""Small dependency-free controller for the SpecPilot candidate tournament."""
from __future__ import annotations
import argparseimport jsonfrom pathlib import Pathfrom typing import Any
BENCHMARKS = ("mt-bench", "humaneval", "math500")NEIGHBORS = { "selector_top_k": (16, 24, 32, 48, 64), "selector_loss_alpha": (0.5, 1.0, 1.5, 2.0), "dpace_alpha": (0.3, 0.5, 0.7, 0.9), "max_anchors": (512, 768, 1024, 1536), "lr": (0.0004, 0.0006, 0.0008),}
def load_json(path: Path, default: Any) -> Any: if not path.is_file(): return default return json.loads(path.read_text())
def save_json(path: Path, value: Any) -> None: path.parent.mkdir(parents=True, exist_ok=True) path.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n")
def numeric_checkpoints(root: Path) -> list[Path]: result = [] for path in root.glob("checkpoints/*"): if path.is_dir() and path.name.isdigit(): result.append(path) return sorted(result, key=lambda path: int(path.name))
def metric_value(path: Path, key: str) -> float | None: data = load_json(path, {}) value = data.get(key) return float(value) if isinstance(value, (int, float)) else None
def read_result(candidate_dir: Path) -> dict[str, Any]: checkpoints = numeric_checkpoints(candidate_dir) validation = {} if checkpoints: validation = load_json(checkpoints[-1] / "val_metrics.json", {}) benchmark_values = { name: metric_value( candidate_dir / "eval_epoch5" / f"{name}.json", "acceptance_length" ) for name in BENCHMARKS } accepted = validation.get("accept_len_epoch") accepted = float(accepted) if isinstance(accepted, (int, float)) else None values = [value for value in benchmark_values.values() if value is not None] mean_benchmark = sum(values) / len(values) if len(values) == 3 else None score = ( accepted * 100.0 + mean_benchmark if accepted is not None and mean_benchmark is not None else None ) runtime = load_json(candidate_dir / "runtime.json", {}) return { "validation": validation, "benchmarks": benchmark_values, "validation_accept_len": accepted, "mean_benchmark_acceptance": mean_benchmark, "score": score, "checkpoint": str(checkpoints[-1]) if checkpoints else None, "exit_code": runtime.get("exit_code"), }
def candidate_key(candidate: dict[str, Any]) -> tuple[Any, ...]: return tuple(candidate.get(name) for name in NEIGHBORS)
def propose_neighbors(best: dict[str, Any], tried: set[tuple[Any, ...]]) -> list[dict[str, Any]]: proposals = [] for field, values in NEIGHBORS.items(): current = best.get(field) for value in values: if value == current: continue candidate = dict(best) candidate[field] = value candidate["name"] = f"adaptive_{field}_{str(value).replace('.', 'p')}" candidate["epochs"] = 5 candidate["dataset_fraction"] = 0.1 if candidate_key(candidate) not in tried: proposals.append(candidate) return proposals
def load_state(path: Path) -> dict[str, Any]: return load_json(path, {"version": 1, "history": [], "active": None})
def all_candidates(plan_path: Path, state: dict[str, Any]) -> list[dict[str, Any]]: plan = load_json(plan_path, []) candidates = list(plan) history = state.get("history", []) tried = {candidate_key(item["config"]) for item in history if "config" in item} completed = [item for item in history if item.get("result", {}).get("score") is not None] if completed: best = max(completed, key=lambda item: item["result"]["score"])["config"] candidates.extend(propose_neighbors(best, tried | {candidate_key(c) for c in candidates})) unique = [] seen = set() for candidate in candidates: key = candidate_key(candidate) if key not in seen: seen.add(key) unique.append(candidate) return unique
def cmd_init(args: argparse.Namespace) -> None: state = load_state(args.state) state.setdefault("version", 1) state.setdefault("history", []) state["plan"] = str(args.plan) state["run_root"] = str(args.run_root) save_json(args.state, state)
def cmd_next(args: argparse.Namespace) -> None: state = load_state(args.state) history = state.get("history", []) latest_by_name = {} for item in history: latest_by_name[item.get("name")] = item terminal_names = set() for name, item in latest_by_name.items(): result = item.get("result", {}) status = result.get("status") if status != "runtime_failed": terminal_names.add(name) candidates = all_candidates(args.plan, state) for candidate in candidates: if candidate["name"] not in terminal_names: fields = ( candidate["name"], str(candidate["selector_top_k"]), str(candidate["selector_loss_alpha"]), str(candidate["dpace_alpha"]), str(candidate["max_anchors"]), str(candidate["lr"]), ) print("\t".join(fields)) return raise SystemExit(1)
def cmd_record(args: argparse.Namespace) -> None: state = load_state(args.state) history = state.setdefault("history", []) candidates = all_candidates(args.plan, state) config = next((item for item in candidates if item["name"] == args.name), None) if config is None: raise SystemExit(f"candidate not found: {args.name}") result = read_result(args.candidate_dir) result["status"] = args.status previous = next( (item for item in reversed(history) if item.get("name") == args.name), None, ) attempts = int(previous.get("attempts", 1)) + 1 if previous else 1 entry = { "name": args.name, "config": config, "result": result, "attempts": attempts, } history[:] = [item for item in history if item.get("name") != args.name] history.append(entry) state["active"] = None save_json(args.state, state)
def cmd_render(args: argparse.Namespace) -> None: state = load_state(args.state) baseline = load_json(args.baseline, {}) lines = [ "# SpecPilot Experiment Results", "", f"Status: **{'complete' if any(item.get('result', {}).get('score') is not None for item in state.get('history', [])) else 'partial' if state.get('history') else 'pending'}**", "", "This report is generated by the resumable SpecPilot controller.", "", "## Baseline", "", "| Metric | DFlash2 baseline |", "|---|---:|", f"| Validation accepted length | {baseline.get('validation', {}).get('accept_len_epoch', 'pending')} |", f"| MT-Bench acceptance length | {baseline.get('mt-bench', {}).get('acceptance_length', 'pending')} |", f"| HumanEval acceptance length | {baseline.get('humaneval', {}).get('acceptance_length', 'pending')} |", f"| MATH500 acceptance length | {baseline.get('math500', {}).get('acceptance_length', 'pending')} |", "", "## Candidate history", "", "| Candidate | Status | Config | Validation accepted length | Mean benchmark acceptance | Score |", "|---|---|---|---:|---:|---:|", ] completed = [] for item in state.get("history", []): result = item.get("result", {}) config = item.get("config", {}) config_text = ( f"k={config.get('selector_top_k')}, " f"sel_alpha={config.get('selector_loss_alpha')}, " f"dpace={config.get('dpace_alpha')}, " f"anchors={config.get('max_anchors')}, lr={config.get('lr')}" ) def fmt(value: Any) -> str: return "pending" if value is None else f"{float(value):.4f}" lines.append( f"| {item.get('name')} | {result.get('status', 'unknown')} (attempt {item.get('attempts', 1)}) | " f"{config_text} | {fmt(result.get('validation_accept_len'))} | " f"{fmt(result.get('mean_benchmark_acceptance'))} | " f"{fmt(result.get('score'))} |" ) if result.get("score") is not None: completed.append(item) lines.extend( [ "", "## Best candidate", "", ] ) if completed: best = max(completed, key=lambda item: item["result"]["score"]) lines.append( f"`{best['name']}` with score " f"`{best['result']['score']:.4f}` and checkpoint " f"`{best['result'].get('checkpoint')}`." ) else: lines.append("No candidate has complete validation and benchmark metrics.") lines.extend( [ "", "## Limitations", "", "Failures and missing runtime dependencies are recorded as pending " "metrics; no metric is fabricated.", "", f"State file: `{args.state}`", ] ) args.report.write_text("\n".join(lines) + "\n")
def main() -> None: parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest="command", required=True)
init = subparsers.add_parser("init") init.add_argument("--state", type=Path, required=True) init.add_argument("--plan", type=Path, required=True) init.add_argument("--run-root", type=Path, required=True) init.set_defaults(func=cmd_init)
next_parser = subparsers.add_parser("next") next_parser.add_argument("--state", type=Path, required=True) next_parser.add_argument("--plan", type=Path, required=True) next_parser.set_defaults(func=cmd_next)
record = subparsers.add_parser("record") record.add_argument("--state", type=Path, required=True) record.add_argument("--plan", type=Path, required=True) record.add_argument("--name", required=True) record.add_argument("--candidate-dir", type=Path, required=True) record.add_argument("--status", required=True) record.set_defaults(func=cmd_record)
render = subparsers.add_parser("render") render.add_argument("--state", type=Path, required=True) render.add_argument("--baseline", type=Path, required=True) render.add_argument("--report", type=Path, required=True) render.set_defaults(func=cmd_render)
args = parser.parse_args() args.func(args)
if __name__ == "__main__": main()1234567891011121314151617181920212223242526272829303132# SpecPilot Experiment Results
Status: **partial**
This report is generated by the resumable SpecPilot controller.
## Baseline
| Metric | DFlash2 baseline ||---|---:|| Validation accepted length | 5.953488872407978 || MT-Bench acceptance length | 2.8897184300341294 || HumanEval acceptance length | 3.214498354833655 || MATH500 acceptance length | 3.6829078734979372 |
## Candidate history
| Candidate | Status | Config | Validation accepted length | Mean benchmark acceptance | Score ||---|---|---|---:|---:|---:|| control_selector32 | complete (attempt 2) | k=32, sel_alpha=1.0, dpace=0.5, anchors=768, lr=0.0006 | pending | 2.9236 | pending || selector24 | complete (attempt 2) | k=24, sel_alpha=1.0, dpace=0.5, anchors=768, lr=0.0006 | pending | 2.8950 | pending || selector48 | complete (attempt 2) | k=48, sel_alpha=1.0, dpace=0.5, anchors=768, lr=0.0006 | pending | 2.9378 | pending |
## Best candidate
No candidate has complete validation and benchmark metrics.
## Limitations
Failures and missing runtime dependencies are recorded as pending metrics; no metric is fabricated.
State file: `/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot/artifacts/specpilot_state.json`1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192{ "active": null, "history": [ { "attempts": 2, "config": { "dataset_fraction": 0.1, "dpace_alpha": 0.5, "epochs": 5, "lr": 0.0006, "max_anchors": 768, "name": "control_selector32", "selector_loss_alpha": 1.0, "selector_top_k": 32 }, "name": "control_selector32", "result": { "benchmarks": { "humaneval": 2.866517628429044, "math500": 3.316424990566546, "mt-bench": 2.5879422659343465 }, "checkpoint": "/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot/artifacts/specpilot_runs/control_selector32/checkpoints/4", "exit_code": 0, "mean_benchmark_acceptance": 2.9236282949766452, "score": null, "status": "complete", "validation": {}, "validation_accept_len": null } }, { "attempts": 2, "config": { "dataset_fraction": 0.1, "dpace_alpha": 0.5, "epochs": 5, "lr": 0.0006, "max_anchors": 768, "name": "selector24", "selector_loss_alpha": 1.0, "selector_top_k": 24 }, "name": "selector24", "result": { "benchmarks": { "humaneval": 2.821145293659163, "math500": 3.306981740064447, "mt-bench": 2.5568949195329758 }, "checkpoint": "/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot/artifacts/specpilot_runs/selector24/checkpoints/4", "exit_code": 0, "mean_benchmark_acceptance": 2.8950073177521953, "score": null, "status": "complete", "validation": {}, "validation_accept_len": null } }, { "attempts": 2, "config": { "dataset_fraction": 0.1, "dpace_alpha": 0.5, "epochs": 5, "lr": 0.0006, "max_anchors": 768, "name": "selector48", "selector_loss_alpha": 1.0, "selector_top_k": 48 }, "name": "selector48", "result": { "benchmarks": { "humaneval": 2.892793385323687, "math500": 3.3227407607229567, "mt-bench": 2.5977639272633812 }, "checkpoint": "/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot/artifacts/specpilot_runs/selector48/checkpoints/4", "exit_code": 0, "mean_benchmark_acceptance": 2.937766024436675, "score": null, "status": "complete", "validation": {}, "validation_accept_len": null } } ], "plan": "/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot/artifacts/candidate_plan.json", "run_root": "/high_perf_store3/world-model/weixiaobao/zlj/zeng_dflash3_SpecPilot/artifacts/specpilot_runs", "version": 1}12345678910111213141516171819202122232425262728293031schema_version = "1.4"artifacts = []
[task]name = "dflash3/specpilot"version = "1.0.0"description = "Autonomous controlled search for DFlash3-compatible Qwen3-8B draft models."authors = []keywords = ["dflash", "speculative-decoding", "specpilot", "self-evolution"]
[metadata]
[verifier]timeout_sec = 600.0environment_mode = "separate"collect = []
[verifier.env]
[agent]timeout_sec = 600.0
[environment]network_mode = "public"build_timeout_sec = 600.0os = "linux"mcp_servers = []
[environment.env]
[solution.env]123456789FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:0.9.7 /uv /usr/local/bin/uv
RUN uv pip install --system pytest==8.4.1 pytest-json-ctrf==0.3.5
WORKDIR /app
COPY . /tests/12345678#!/usr/bin/env bashset -euo pipefail
if pytest --ctrf /logs/verifier/ctrf.json /tests/test_outputs.py -rA; then echo 1 > /logs/verifier/reward.txtelse echo 0 > /logs/verifier/reward.txtfi12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970"""Static Harbor checks for the SpecPilot deliverables."""
import jsonimport subprocessimport sysfrom pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_task_and_runner_exist(): assert (ROOT / "task.toml").is_file() assert (ROOT / "prompt.md").is_file() runner = ROOT / "artifacts" / "run_specpilot_8gpu.sh" base_runner = ROOT / "artifacts" / "run_dflash3_10pct_5ep.sh" assert runner.is_file() and base_runner.is_file() text = runner.read_text() base_text = base_runner.read_text() for needle in ("0,1,2,3", "4,5,6,7", "SPECPILOT_TRIALS", "specpilot_state.json"): assert needle in text for needle in ("--epochs 5", "--block-size \"$BLOCK_SIZE\"", "--max-anchors"): assert needle in base_text assert "--selector-top-k \"$SELECTOR_TOP_K\"" in base_text assert "--seed \"$SEED\"" in base_text
def test_plan_and_report_contract(): plan = json.loads((ROOT / "artifacts" / "candidate_plan.json").read_text()) assert len(plan) >= 3 assert all(candidate["epochs"] == 5 for candidate in plan) assert all(candidate["dataset_fraction"] == 0.1 for candidate in plan) report = (ROOT / "artifacts" / "specpilot_results.md").read_text() assert "SpecPilot Experiment Results" in report assert "DFlash2 baseline" in report assert "pending" in report
def test_no_credentials_are_written(): paths = [ROOT / "prompt.md", ROOT / "instruction.md", ROOT / "pro.md", ROOT / "task.toml", ROOT / "README.md"] paths += list((ROOT / "artifacts").glob("*.py")) paths += list((ROOT / "artifacts").glob("*.sh")) paths += list((ROOT / "solution").glob("*.sh")) for path in paths: if path.is_file(): text = path.read_text(errors="ignore") assert "OPENAI_API_KEY=\"sk-" not in text assert "sk-" not in text.replace("<NEW_OPENAI_API_KEY>", "")
def test_pretrained_runner_does_not_override_decoder_shape(): text = (ROOT / "artifacts/run_dflash3_10pct_5ep.sh").read_text() assert '--from-pretrained' in text assert '--num-layers' not in text
def test_failed_candidate_is_retried(tmp_path): state = tmp_path / "state.json" state.write_text(json.dumps({"version": 1, "history": [{ "name": "control_selector32", "config": json.loads((ROOT / "artifacts/candidate_plan.json").read_text())[0], "result": {"status": "runtime_failed"}, }]})) result = subprocess.run( [sys.executable, str(ROOT / "artifacts/specpilot.py"), "next", "--state", str(state), "--plan", str(ROOT / "artifacts/candidate_plan.json")], check=True, capture_output=True, text=True, ) assert result.stdout.startswith("control_selector32\t").gitattributes+1
.gitignoreAdded+23
.pytest_cache/.gitignoreAdded+2
.pytest_cache/CACHEDIR.TAGAdded+4
.pytest_cache/README.mdAdded+8
.pytest_cache/v/cache/lastfailedAdded+1
.pytest_cache/v/cache/nodeidsAdded+7
README (1).mdAdded+1
README.mdAdded+1
artifacts/baseline_metrics.jsonAdded+18
artifacts/candidate_plan.jsonAdded+112
artifacts/data/open_perfectblend_regen_10pct.jsonlAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/data-00000-of-00007.arrowAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/data-00001-of-00007.arrowAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/data-00002-of-00007.arrowAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/data-00003-of-00007.arrowAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/data-00004-of-00007.arrowAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/data-00005-of-00007.arrowAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/data-00006-of-00007.arrowAdded+3
artifacts/data/open_perfectblend_regen_10pct_prepared/dataset_info.jsonAdded+57
artifacts/data/open_perfectblend_regen_10pct_prepared/state.jsonAdded+35
artifacts/data/open_perfectblend_regen_10pct_prepared/token_freq.ptAdded+3
artifacts/run_dflash3_10pct_5ep.shAdded+186
artifacts/run_specpilot_8gpu.shAdded+89
artifacts/specpilot.pyAdded+294
artifacts/specpilot_results.mdAdded+32
baseline_metrics (1).jsonAdded+18
candidate_plan (1).jsonAdded+112
environment/DockerfileAdded+3
instruction (1).mdAdded+37
pro (1).mdAdded+37
prompt (1).mdAdded+71
run_dflash3_10pct_5ep (1).shAdded+186
run_specpilot_8gpu (1).shAdded+89
solution/eval_specpilot.shAdded+77
solution/solve.shAdded+7
specpilot (1).pyAdded+294
specpilot_results (1).mdAdded+32
specpilot_state (1).jsonAdded+92
task (1).tomlAdded+31
tests/DockerfileAdded+9
tests/test.shAdded+8
tests/test_outputs.pyAdded+70