|
Download auto-impl/src/posttrainbench/README.md from Jerry999/RSIChallenge: direct link, hf CLI and curl.
- Browser
- Download file 7.89 kB
-
https://huggingface.co/datasets/Jerry999/RSIChallenge/resolve/main/auto-impl/src/posttrainbench/README.md
- Command line
-
hf download hf://datasets/Jerry999/RSIChallenge/auto-impl/src/posttrainbench/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Jerry999/RSIChallenge/resolve/main/auto-impl/src/posttrainbench/README.md
7.89 kB
| # posttrainbench | |
| Portable runner for [PostTrainBench](https://github.com/aisa-group/PostTrainBench): a CLI agent | |
| (e.g. Codex driven by an OpenAI model) gets a base LLM, a benchmark and a time budget on one GPU, | |
| and must post-train the model. The score is the benchmark result of the model it leaves behind. | |
| Upstream only runs on its authors' HTCondor cluster. This package replaces that launcher | |
| (`src/run_task.sh` + `src/commit_utils/`) and nothing else: prompt, agents, tasks, evaluation | |
| scripts and the container definition are used unmodified from the pinned submodule | |
| `third_party/PostTrainBench`, so results stay comparable with the official leaderboard. | |
| ## Requirements | |
| - Linux with an NVIDIA GPU (official setting: one H100 80 GB per run) and internet access | |
| - [Apptainer](https://apptainer.org/docs/admin/main/installation.html) >= 1.1; unprivileged | |
| installs work, no root or Docker needed | |
| - Python >= 3.10, no packages needed (everything else lives in the container); `uv` is optional | |
| - ~100 GB on a fast local disk for `PTB_DATA_DIR`: image 12 GB, ~4-8 GB per base model, and the | |
| agent's checkpoints during a run | |
| ## Setup | |
| All commands run from the repository root (`auto-impl/`). | |
| ```bash | |
| git clone --recurse-submodules <this repo> && cd auto-impl # or, in an existing clone: | |
| git submodule update --init # fetch upstream PostTrainBench | |
| cp .env.example .env # then set HF_TOKEN and PTB_DATA_DIR | |
| uv run ptb setup --full-cache --models Qwen/Qwen3-1.7B-Base --tasks gsm8k | |
| ``` | |
| `setup` is idempotent: it builds the container images (12 GB and ~25 min each, once per machine), | |
| prefills the shared HF cache and fetches the benchmark test sets for the agent's decontamination | |
| checker. Without `uv`, use `PYTHONPATH=src python -m posttrainbench` instead of `uv run ptb`. | |
| By default it builds the two images upstream uses for a claude-opus-5 cell: `opus_5` for the agent | |
| and `vllm_debug` for evaluation. `--containers` picks others from upstream `containers/*.def`. | |
| `--full-cache` downloads upstream's working set -- 14 models and 382 dataset splits, a few hundred | |
| GB over several hours. It is what lets the agent sandbox run with no network at all, so it is not | |
| optional here. Each image build downloads ~20 GB; if either fails on a network error, rerun the | |
| same command. `google/gemma-3-4b-pt`, `google/gemma-3-4b-it`, `Idavidrein/gpqa` and the `gpqamain` | |
| test data are gated on HuggingFace and need `HF_TOKEN`. | |
| ## Run | |
| ```bash | |
| # Sanity check of image + GPU + evaluation, no credentials needed (~10 min): | |
| uv run ptb eval --task gsm8k --model Qwen/Qwen3-1.7B-Base --limit 20 --out-dir data/baselines/gsm8k_qwen3-1.7b | |
| # Official setting: 10 h agent run followed by the full evaluation. | |
| uv run ptb run --task gsm8k --model Qwen/Qwen3-1.7B-Base --agent-model claude-opus-5 | |
| # Cheap end-to-end smoke test. | |
| uv run ptb run --task gsm8k --model Qwen/Qwen3-1.7B-Base --agent-model claude-opus-5 --hours 1 | |
| ``` | |
| One `ptb run` is one (task, base model) cell and needs one GPU, selected via | |
| `CUDA_VISIBLE_DEVICES` if the machine has several. Sweeps are left to whatever the machine | |
| offers, e.g. `sbatch --gres=gpu:1 --time=12:00:00 --wrap "uv run ptb run ..."` or a shell loop. | |
| Tasks: `aime2025 arenahardwriting bfcl gpqamain gsm8k healthbench humaneval`. | |
| Base models: `Qwen/Qwen3-1.7B-Base Qwen/Qwen3-4B-Base HuggingFaceTB/SmolLM3-3B-Base google/gemma-3-4b-pt`. | |
| `--agent` selects any scaffold in upstream `agents/` (default `claude_non_api`; `claude_non_api_max` | |
| raises the reasoning effort), and `--container` the image it runs in. | |
| The local `codex_sdk` scaffold drives Codex through the TypeScript SDK instead of invoking the CLI | |
| directly. `scripts/ptb_codex_sdk_setup.sh` installs the pinned SDK on shared storage, | |
| `scripts/ptb_codex_sdk_probe.sbatch` verifies its gateway path, and | |
| `scripts/ptb_codex_sdk_sweep.sh` submits the separate 28-cell run1 sweep. That sweep sets | |
| `PTB_RESULTS_DIR` to a Codex-specific root, so it cannot overwrite Claude results. | |
| ## Output | |
| `$PTB_DATA_DIR/results/<agent>_<agent-model>_<hours>h/<task>_<model>_<timestamp>/` (upstream's layout, | |
| so upstream's `scripts/` for aggregation work on it): | |
| | File | Content | | |
| |---|---| | |
| | `metrics.json` | final benchmark score | | |
| | `final_model/` | the model the agent submitted | | |
| | `task/` | the agent's workspace (code, data, logs; checkpoints removed) | | |
| | `prompt.txt` | the exact prompt given to the agent | | |
| | `solve_out.txt` | raw trajectory: the agent CLI's timestamped JSON event stream, written live | | |
| | `solve_parsed.txt` | human-readable rendering of the trajectory | | |
| | `agent_home/` | rest of the agent's home, incl. the CLI's own session records (`.codex/sessions/`) | | |
| | `time_taken.txt`, `final_eval_<n>.txt` | agent wall-clock time, evaluation logs | | |
| Trajectories are written to the run directory while the agent runs, so a crash or a killed job | |
| loses nothing: whatever was not yet post-processed is still in `<run dir>/sandbox/home/ben/`. | |
| `*_sanitized.*` copies have the API keys redacted; share those, not the raw files. | |
| Before spending a 10 h budget on a new machine or agent model, do the 1 h smoke test and look at | |
| `solve_out.txt` and `agent_home/`. If `PTB_DATA_DIR` is node-local or gets purged, copy | |
| `results/` to persistent storage after each run (checkpoints are already removed, so it is small | |
| apart from `final_model/`). | |
| ## Code | |
| | Module | Role | | |
| |---|---| | |
| | `config.py` | paths and `.env`; all machine-specific settings | | |
| | `sandbox.py` | isolated container execution; the only place that knows Apptainer | | |
| | `provision.py` | `ptb setup` | | |
| | `solve.py` | agent phase | | |
| | `evaluate.py` | evaluation phase, with upstream's retry protocol | | |
| | `cli.py` | `ptb` command | | |
| ## Differences from upstream | |
| Identical: prompt (except the internet line below), agent scaffold and CLI flags, container | |
| recipes and package versions, which container each phase uses, the prefilled HF cache, sandbox | |
| isolation, which credentials the agent sees, time limit (+5 min grace), `evaluate.py` with its | |
| arguments, the evaluation retry protocol, checkpoint cleanup, results layout. Different: | |
| - **No internet in the agent sandbox.** Upstream's prompt promises unrestricted access; this | |
| runner gives the agent an empty network namespace and rewrites that one prompt line to describe | |
| what it actually has (`solve.py:OFFLINE_LINE`). The point is a controlled, reproducible | |
| environment: everything the agent should need is in the image (`trl`, `peft`, `accelerate`, | |
| `datasets`, `lm-eval`, ...) and in the prefilled cache. The cost is that upstream's rule 7, which | |
| lets the agent install extra packages, cannot be honoured. | |
| - The agent CLI reaches its model through a local shim rather than the vendor's endpoint | |
| (`scripts/x2p_anthropic_shim.py`), and `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` / | |
| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` are set because that gateway rejects the beta headers. | |
| The `*_non_api` scaffolds get a placeholder `oauth_token`, since the gateway, not the token, | |
| authenticates the request. | |
| - The reward-hacking judges (`src/judges/`) are not run; they need a ChatGPT-subscription login | |
| rather than an API key. `metrics.json` is therefore the raw score: upstream replaces the score | |
| of runs its judges flag (contamination, disallowed models or API use). Traces and workspaces | |
| are kept, so runs can be judged later. | |
| - Upstream's H100 check is skipped (only "a GPU is visible" is asserted), while the prompt still | |
| tells the agent it has an H100. No difference on an H100. | |
| - Upstream kills all GPU processes on the node before evaluating; this runner does not. It expects | |
| the scheduler to hand it a dedicated GPU instead. | |
| - Images are built with `apptainer build --fakeroot --ignore-subuid` (`PTB_BUILD_FLAGS` overrides), | |
| which unprivileged builds inside a containerized job need. The definitions are unmodified. | |