{
 "id": "harness-adapters/Qwen3.8-27B",
 "path": "AsyncGRPOTrainer/harness-adapters/Qwen3.8-27B",
 "trainers": [
  "AsyncGRPOTrainer"
 ],
 "project": "harness-adapters",
 "name": "Qwen3.8-27B",
 "org": "Qwen",
 "avatar": "https://cdn-avatars.huggingface.co/v1/production/uploads/6215ca5692c0ecfba9186921/hrRM50-6XcdWgg2AKpENG.jpeg",
 "hub_url": "https://huggingface.co/collections/harness-hub/qwen38-27b-harness-adapters-6afaa929267f8340ded09791",
 "meta": {
  "title": "Qwen3.8-27B harness adapters",
  "project": "harness-adapters",
  "trainer": "AsyncGRPOTrainer",
  "model_id": "Qwen/Qwen3.8-27B",
  "description": "One LoRA adapter per agent harness (pi, hermes, opencode) on Qwen3.8-27B, trained with async GRPO on agentic coding and terminal tasks (scale800 + TermGrade), one job per harness, thinking off.",
  "tags": [
   "lora",
   "agentic-rl",
   "harbor",
   "safeagents",
   "multi-harness"
  ],
  "harnesses": [
   "pi",
   "hermes",
   "opencode"
  ],
  "date_added": "2026-11-13"
 },
 "hardware": {
  "local": "2 GPUs per harness, H200 or B200 class (untested)",
  "hf_jobs": "h200x2 per harness (untested)"
 },
 "datasets": {
  "train": [
   "harness-hub/scale800-harbor@56c7f75d01f70859ec1354e97866e32a175c1a40",
   "harness-hub/termgrade-train-harbor"
  ],
  "eval": {
   "sbp-hard51": "harness-hub/swebench-pro-v2-hard51-harbor",
   "tb21-20pct": "harborframework/terminal-bench-2.1@3e235dff6880252a587fa479c09bcb1e16edf2eb, 18 tasks",
   "s800-heldout": "harness-hub/scale800-heldout-harbor (the repositories left out of training), 1800 s and 50 steps as in training",
   "automationbench": "Zapier AutomationBench, 10 tasks per domain (60), as the base eval"
  }
 },
 "hyperparameters": {
  "lora_r": 32,
  "lora_target_modules": [
   "q_proj",
   "k_proj",
   "v_proj",
   "o_proj",
   "gate_proj",
   "up_proj",
   "down_proj"
  ],
  "learning_rate": 2e-05,
  "num_generations": 8,
  "gradient_accumulation_steps": 16,
  "max_staleness": 16,
  "temperature": 0.8,
  "max_completion_length": 16384,
  "max_model_len": 65536,
  "token_budget": 65536,
  "agent_step_limit": 50,
  "agent_timeout_s": 1800,
  "max_inflight": 64,
  "tool_efficiency_weight": 0.1,
  "max_steps": 1000,
  "save_steps": 10,
  "thinking": false
 },
 "vllm": {
  "tool_call_parser": "qwen3_xml",
  "reasoning_parser": "qwen3",
  "extra_args": [
   "--language-model-only",
   "--enable-prefix-caching",
   "--mamba-cache-mode align"
  ]
 },
 "trl": {
  "fork": "younesbelkada/trl@e498acc637084cffff14deb09ccdc423a766adb2 (async-grpo-shared-vllm)",
  "upstream_base": "d115286bc5aef8d346e8510bfe312803c7881c4a",
  "patch": "trl.patch"
 },
 "scripts": {
  "train": {
   "hf_jobs": "train_hf_jobs.sh",
   "local": "train_local.sh"
  },
  "eval": {
   "hf_jobs": "eval_hf_jobs.sh",
   "local": "eval_local.sh"
  }
 },
 "builder": {
  "verified": {
   "hf_jobs": false,
   "local": false
  },
  "train": [
   {
    "env": "HARNESS",
    "label": "Harnesses",
    "choices": [
     "pi",
     "hermes",
     "opencode"
    ],
    "multi": true,
    "hf_jobs_env": "HARNESSES",
    "platforms": [
     "hf_jobs"
    ]
   },
   {
    "env": "HARNESS",
    "label": "Harness",
    "choices": [
     "pi",
     "hermes",
     "opencode"
    ],
    "platforms": [
     "local"
    ]
   }
  ],
  "eval": [
   {
    "env": "BENCH",
    "label": "Benchmark",
    "choices": [
     "sbp",
     "tb",
     "s800",
     {
      "value": "automationbench",
      "platforms": [
       "hf_jobs",
       "local"
      ]
     }
    ]
   },
   {
    "env": "POLICIES",
    "label": "Policies",
    "input": true,
    "default": "Qwen/Qwen3.8-27B@pi,hermes,opencode",
    "unless": {
     "BENCH": "automationbench"
    }
   },
   {
    "env": "CHECKPOINTS",
    "label": "Checkpoints",
    "input": true,
    "default": "base",
    "when": {
     "BENCH": "automationbench"
    }
   }
  ]
 },
 "readme": "# Qwen3.8-27B harness adapters\n\nLoRA adapters for pi, hermes and opencode on [`Qwen/Qwen3.8-27B`](https://huggingface.co/Qwen/Qwen3.8-27B), trained for\nup to 1,000 steps. Training data is the 750 scale800 tasks interleaved with 300 TermGrade tasks. Setup and shared\nsettings: [../README.md](../README.md). Full hyperparameters: [recipe.yaml](recipe.yaml).\n\n| | HF Jobs (untested) | Local (untested) |\n|---|---|---|\n| Train | `bash train_hf_jobs.sh`, one h200x2 job per harness | `HARNESS=pi bash train_local.sh`, one harness per machine (2 GPUs) |\n| Eval | `BENCH=sbp\\|tb\\|s800\\|automationbench ... bash eval_hf_jobs.sh` (h200) | `BENCH=sbp\\|tb\\|s800\\|automationbench ... bash eval_local.sh` (1 GPU) |\n\nHow this differs from the LFM / TwIL recipes:\n- **Training script and TRL.** This folder has its own [async_grpo_harbor.py](async_grpo_harbor.py), built on\n  `HarnessAsyncGRPOTrainer`. That trainer comes from TRL's `async-grpo-shared-vllm` branch\n  (`younesbelkada/trl@e498acc6`), not the launcher's pinned TRL. Its changes relative to upstream are in\n  [trl.patch](trl.patch).\n  The HF Jobs and local launchers install it from git (`--trl-wheel`).\n- **One job per harness**, not one job for all three.\n- **Thinking off.** Each run has 50 agent steps and 1800 s, and `--no-responses-thinking`.\n- **vLLM settings:**\n  - `--language-model-only`, plus prefix caching with `--mamba-cache-mode align`, which the gated-DeltaNet layers\n    need.\n- **Safeagents plugin.** It is the generic Harbor plugin, `scripts/atif_harbor.py`.\n\n## Evaluation\n\nEvals compare each checkpoint with a base eval run the same way, under the same tag: run the base once per benchmark\n(`POLICIES=\"Qwen/Qwen3.8-27B@pi,hermes,opencode\"`). `s800` is the scale800 held-out set: the repositories left out of\ntraining, under training's own limits (1800 s, 50 steps).\n",
 "files": {
  "train_local.sh": "#!/bin/bash\n# Qwen3.8-27B harness adapter for one harness on one local machine with 2 GPUs: one vLLM (GPU 0) serving the base and\n# the adapter versions, and one LoRA AsyncGRPO trainer (GPU 1). The 27B trainer needs ~140 GB: H200 or B200 class.\n#\n# The settings of the final runs, with the HF Jobs install (train_hf_jobs.sh): TRL from the async-grpo-shared-vllm\n# commit and Triton 3.7.1, run here with `uv run`. Not run locally yet. Runs are written to $DATA_ROOT/runs/.\n#\n#   HARNESS=pi bash train_local.sh\n#   HARNESS=pi MAX_STEPS=5 MAX_INFLIGHT=16 bash train_local.sh            short smoke run\nset -euo pipefail\n\nHARNESS=\"${HARNESS:?HARNESS=pi, hermes or opencode}\"\nDATA_ROOT=\"${DATA_ROOT:-$PWD/outputs}\"\nSPLIT=\"${SPLIT:-harness-hub/scale800-harbor@56c7f75d01f70859ec1354e97866e32a175c1a40}\"\nLEARNING_RATE=\"${LEARNING_RATE:-2e-5}\"\nMAX_INFLIGHT=\"${MAX_INFLIGHT:-64}\"\nMAX_STALENESS=\"${MAX_STALENESS:-16}\"\nGRAD_ACCUM=\"${GRAD_ACCUM:-16}\"\nTOKEN_BUDGET=\"${TOKEN_BUDGET:-65536}\"  # the 27B trainer peaked at 138 GiB of 141 on an H200 with this\nMAX_STEPS=\"${MAX_STEPS:-1000}\"\nMAX_NUM_SEQS=$((2 * MAX_INFLIGHT))\nMAX_LORAS=$((MAX_STALENESS + 2))\n# HarnessAsyncGRPOTrainer, which this training script uses, is on the async-grpo-shared-vllm branch, not in the\n# launcher's pinned TRL\nTRL=\"${TRL:-trl @ git+https://github.com/younesbelkada/trl.git@e498acc637084cffff14deb09ccdc423a766adb2}\"\nHERE=\"$(cd \"$(dirname \"$0\")\" && pwd)\"\nSCRIPTS=\"$HERE/../scripts\"\nexport HF_TOKEN=\"${HF_TOKEN:-$(cat ~/.cache/huggingface/token)}\"  # also what the HF sandboxes run under\n# Names this run's folders (logs/<id>, runs/<model>-<harness>-<id>-...), as HF_JOB_ID does on HF Jobs\nexport JOB_ID=\"${JOB_ID:-local-$(date +%Y%m%d-%H%M%S)}\"\nexport PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True\n\n# triton 3.7.1: 3.6.0's gated-DeltaNet backward is wrong on Hopper (fla #640)\nuv run \"$SCRIPTS/launcher_train.py\" \\\n    --data-root \"$DATA_ROOT\" --trl-wheel \"$TRL\" \\\n    --pip-install \"triton==3.7.1 safeagents@git+https://github.com/huggingface/safeagents@5e683fa atif-scan==0.8.15 rich markdown-it-py mdurl pygments\" \\\n    --train-script-url \"file://$HERE/async_grpo_harbor.py\" \\\n    --model Qwen/Qwen3.8-27B --harness \"$HARNESS\" --split \"$SPLIT\" --n-tasks 1000 \\\n    --mix-split harness-hub/termgrade-train-harbor:300 --interleave \\\n    --sandbox hf-sandbox --expose gradio \\\n    --vllm-device 0 --train-device 1 \\\n    --tool-call-parser qwen3_xml --reasoning-parser qwen3 --max-model-len \"$TOKEN_BUDGET\" \\\n    --vllm-extra-args=\"--language-model-only --enable-prefix-caching --mamba-cache-mode align --max-num-seqs $MAX_NUM_SEQS --default-chat-template-kwargs '{\\\"enable_thinking\\\": false}'\" \\\n    --max-inflight \"$MAX_INFLIGHT\" --max-lora-rank 32 --max-loras \"$MAX_LORAS\" \\\n    --no-responses-thinking \\\n    --reward-key correctness,reward --num-generations 8 \\\n    --gradient-accumulation-steps \"$GRAD_ACCUM\" --max-staleness \"$MAX_STALENESS\" --token-budget \"$TOKEN_BUDGET\" \\\n    --max-completion-length 16384 --agent-step-limit 50 --agent-timeout 1800 --temperature 0.8 \\\n    --lora-r 32 --lora-target-modules q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj \\\n    --learning-rate \"$LEARNING_RATE\" --tool-efficiency-weight 0.1 \\\n    --safeagents --safeagents-plugin \"$SCRIPTS/atif_harbor.py:checks\" \\\n    --max-steps \"$MAX_STEPS\" --save-steps 10 --save-total-limit 0\n",
  "train_hf_jobs.sh": "#!/bin/bash\n# Qwen3.8-27B harness adapters on HF Jobs: one h200x2 job per harness, each with one vLLM (GPU 0) serving the base and\n# the adapter versions, and one LoRA AsyncGRPO trainer (GPU 1).\n#\n# The settings of the final runs, moved to HF Jobs. Not run in this exact form: the final runs used another launcher,\n# and the HF Jobs Qwen3.8 runs before them used SmolDataEnvs.\n#\n#   bash train_hf_jobs.sh                                   pi, hermes and opencode, one job each\n#   HARNESSES=pi MAX_STEPS=5 MAX_INFLIGHT=16 bash train_hf_jobs.sh\nset -euo pipefail\n\nBUCKET=\"${BUCKET:?set BUCKET=<your user>/<bucket>, the bucket the job mounts on /outputs}\"\nHARNESSES=\"${HARNESSES:-pi hermes opencode}\"\nSPLIT=\"${SPLIT:-harness-hub/scale800-harbor@56c7f75d01f70859ec1354e97866e32a175c1a40}\"\nLEARNING_RATE=\"${LEARNING_RATE:-2e-5}\"\nMAX_INFLIGHT=\"${MAX_INFLIGHT:-64}\"\nMAX_STALENESS=\"${MAX_STALENESS:-16}\"\nGRAD_ACCUM=\"${GRAD_ACCUM:-16}\"\nTOKEN_BUDGET=\"${TOKEN_BUDGET:-65536}\"  # the 27B trainer peaked at 138 GiB of 141 on an H200 with this\nMAX_STEPS=\"${MAX_STEPS:-1000}\"\nMAX_NUM_SEQS=$((2 * MAX_INFLIGHT))\nMAX_LORAS=$((MAX_STALENESS + 2))\n# HarnessAsyncGRPOTrainer, which this training script uses, is on the async-grpo-shared-vllm branch, not in the\n# launcher's pinned TRL\nTRL=\"${TRL:-trl @ git+https://github.com/younesbelkada/trl.git@e498acc637084cffff14deb09ccdc423a766adb2}\"\nHERE=\"$(cd \"$(dirname \"$0\")\" && pwd)\"\nSCRIPTS=\"$HERE/../scripts\"\n\n# The job reads the training script and the safeagents plugin from the bucket, mounted on /outputs. The Qwen training\n# script differs from the LFM / TwIL one, so it gets its own name there.\nhf buckets cp \"$HERE/async_grpo_harbor.py\" \"hf://buckets/$BUCKET/qwen3.8_async_grpo_harbor.py\"\nhf buckets cp \"$SCRIPTS/atif_harbor.py\" \"hf://buckets/$BUCKET/atif_harbor.py\"\n\nfor HARNESS in $HARNESSES; do\n    # triton 3.7.1: 3.6.0's gated-DeltaNet backward is wrong on Hopper (fla #640)\n    hf jobs uv run --detach \\\n        --flavor h200x2 --image huggingface/trl --secrets HF_TOKEN --timeout 72h \\\n        --env PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \\\n        --volume \"hf://buckets/$BUCKET:/outputs\" \\\n        \"$SCRIPTS/launcher_train.py\" -- \\\n        --data-root /outputs --trl-wheel \"$TRL\" \\\n        --pip-install \"triton==3.7.1 safeagents@git+https://github.com/huggingface/safeagents@5e683fa atif-scan==0.8.15 rich markdown-it-py mdurl pygments\" \\\n        --train-script-url file:///outputs/qwen3.8_async_grpo_harbor.py \\\n        --model Qwen/Qwen3.8-27B --harness \"$HARNESS\" --split \"$SPLIT\" --n-tasks 1000 \\\n        --mix-split harness-hub/termgrade-train-harbor:300 --interleave \\\n        --sandbox hf-sandbox --expose gradio \\\n        --vllm-device 0 --train-device 1 \\\n        --tool-call-parser qwen3_xml --reasoning-parser qwen3 --max-model-len \"$TOKEN_BUDGET\" \\\n        --vllm-extra-args=\"--language-model-only --enable-prefix-caching --mamba-cache-mode align --max-num-seqs $MAX_NUM_SEQS --default-chat-template-kwargs '{\\\"enable_thinking\\\": false}'\" \\\n        --max-inflight \"$MAX_INFLIGHT\" --max-lora-rank 32 --max-loras \"$MAX_LORAS\" \\\n        --no-responses-thinking \\\n        --reward-key correctness,reward --num-generations 8 \\\n        --gradient-accumulation-steps \"$GRAD_ACCUM\" --max-staleness \"$MAX_STALENESS\" --token-budget \"$TOKEN_BUDGET\" \\\n        --max-completion-length 16384 --agent-step-limit 50 --agent-timeout 1800 --temperature 0.8 \\\n        --lora-r 32 --lora-target-modules q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj \\\n        --learning-rate \"$LEARNING_RATE\" --tool-efficiency-weight 0.1 \\\n        --safeagents --safeagents-plugin /outputs/atif_harbor.py:checks \\\n        --max-steps \"$MAX_STEPS\" --save-steps 10 --save-total-limit 0\ndone\n",
  "eval_local.sh": "#!/bin/bash\n# Evaluate Qwen3.8-27B policies on one local GPU (H200 or B200 class), with `uv run`. Results land in\n# $DATA_ROOT/eval/. Same settings as eval_hf_jobs.sh; not run locally yet.\n#\n#   BENCH=sbp|tb|s800 each LoRA checkpoint merged into the base and served alone, one at a time.\n#                     POLICIES: `<checkpoint path or Hub id>@<harnesses>`, space-separated\n#   BENCH=automationbench\n#                     Zapier AutomationBench with its own agent loop (no sandboxes): one vLLM serves the base and every\n#                     adapter (eval_automationbench.py). CHECKPOINTS: `base` and/or checkpoint paths, space-separated\n#\n#   BENCH=sbp POLICIES=\"Qwen/Qwen3.8-27B@pi,hermes,opencode\" bash eval_local.sh\n#   BENCH=automationbench CHECKPOINTS=\"base $PWD/outputs/runs/<run>/checkpoint-50\" bash eval_local.sh\nset -euo pipefail\n\nDATA_ROOT=\"${DATA_ROOT:-$PWD/outputs}\"\nBENCH=\"${BENCH:?BENCH=sbp, tb, s800 or automationbench}\"\n# scale800 held-out: the tasks of the repositories left out of training (all of them), with training's own agent limits,\n# since it measures what training produced. Set S800_HELDOUT to the held-out dataset, pinned like the training one.\nS800_HELDOUT=\"${S800_HELDOUT:-harness-hub/scale800-heldout-harbor}\"\nHERE=\"$(cd \"$(dirname \"$0\")\" && pwd)\"\nSCRIPTS=\"$HERE/../scripts\"\nexport HF_TOKEN=\"${HF_TOKEN:-$(cat ~/.cache/huggingface/token)}\"\nexport JOB_ID=\"${JOB_ID:-local-$(date +%Y%m%d-%H%M%S)}\"\n\nif [ \"$BENCH\" = automationbench ]; then\n    CHECKPOINTS=\"${CHECKPOINTS:-base}\"\n    read -r -a CHECKPOINT_LIST <<< \"$CHECKPOINTS\"\n    # Resumable: a run stopped early keeps every finished chunk, and the same command runs only the rest.\n    # 10 tasks per domain (60), the size of the base's eval: a checkpoint is only comparable with a\n    # base run on the same tasks\n    uv run \"$HERE/eval_automationbench.py\" \\\n        --data-root \"$DATA_ROOT\" \\\n        --model Qwen/Qwen3.8-27B --checkpoints \"${CHECKPOINT_LIST[@]}\" --per-domain \"${PER_DOMAIN:-10}\" \\\n        --vllm-extra-args=\"--language-model-only --max-num-seqs 64\"\n    exit 0\nfi\n\nPOLICIES=\"${POLICIES:?POLICIES=\\\"<checkpoint>@<harness> ...\\\"}\"\ncase \"$BENCH\" in\n    sbp)\n        TAG=\"${TAG:-sbp-hard51-solo}\"\n        BENCH_ARGS=(--split harness-hub/swebench-pro-v2-hard51-harbor --n-tasks 51 --sandbox-memory-mb 4096\n            --agent-step-limit 100 --agent-timeout 7200)\n        ;;\n    tb)\n        TAG=\"${TAG:-tb21-20pct-solo}\"\n        BENCH_ARGS=(--split harborframework/terminal-bench-2.1@3e235dff6880252a587fa479c09bcb1e16edf2eb\n            --difficulty easy:1,medium:11,hard:6 --n-tasks 18 --sandbox-memory-mb 8192\n            --agent-step-limit 100 --agent-timeout 3600)\n        ;;\n    s800)\n        TAG=\"${TAG:-s800-heldout-solo}\"\n        BENCH_ARGS=(--split \"$S800_HELDOUT\" --n-tasks 1000 --sandbox-memory-mb 8192\n            --agent-step-limit 50 --agent-timeout 1800)\n        ;;\n    *)\n        echo \"unknown BENCH=$BENCH: sbp, tb, s800 or automationbench\" >&2\n        exit 1\n        ;;\nesac\nread -r -a POLICY_LIST <<< \"$POLICIES\"\n\nuv run \"$SCRIPTS/launcher_eval.py\" \\\n    --data-root \"$DATA_ROOT\" --eval-script-url \"file://$SCRIPTS/evaluate_harbor.py\" \\\n    --model Qwen/Qwen3.8-27B --eval-checkpoints \"${POLICY_LIST[@]}\" --eval-tag \"$TAG\" \"${BENCH_ARGS[@]}\" \\\n    --sandbox hf-sandbox --expose gradio --max-inflight 32 --max-model-len 131072 \\\n    --vllm-device 0 \\\n    --tool-call-parser qwen3_xml --reasoning-parser qwen3 --no-responses-thinking \\\n    --vllm-extra-args=\"--max-num-seqs 64 --enable-prefix-caching --mamba-cache-mode align\"\n",
  "eval_hf_jobs.sh": "#!/bin/bash\n# Evaluate Qwen3.8-27B policies on HF Jobs (1x H200).\n#\n#   BENCH=sbp|tb|s800 each LoRA checkpoint merged into the base and served alone, one at a time.\n#                     POLICIES: `<checkpoint path or Hub id>@<harnesses>`, space-separated\n#   BENCH=automationbench\n#                     Zapier AutomationBench with its own agent loop (no sandboxes): one vLLM serves the base and every\n#                     adapter (eval_automationbench.py). CHECKPOINTS: `base` and/or checkpoint paths, space-separated\n#\n#   BENCH=sbp POLICIES=\"Qwen/Qwen3.8-27B@pi,hermes,opencode\" bash eval_hf_jobs.sh\n#   BENCH=automationbench CHECKPOINTS=\"base /outputs/runs/<run>/checkpoint-50\" bash eval_hf_jobs.sh\n#\n# The sbp / tb settings are those of the final evals, not run on HF Jobs in this form. AutomationBench ran on HF Jobs.\nset -euo pipefail\n\nBUCKET=\"${BUCKET:?set BUCKET=<your user>/<bucket>, the bucket the job mounts on /outputs}\"\nBENCH=\"${BENCH:?BENCH=sbp, tb, s800 or automationbench}\"\n# scale800 held-out: the tasks of the repositories left out of training (all of them), with training's own agent limits,\n# since it measures what training produced. Set S800_HELDOUT to the held-out dataset, pinned like the training one.\nS800_HELDOUT=\"${S800_HELDOUT:-harness-hub/scale800-heldout-harbor}\"\nHERE=\"$(cd \"$(dirname \"$0\")\" && pwd)\"\nSCRIPTS=\"$HERE/../scripts\"\n\nif [ \"$BENCH\" = automationbench ]; then\n    CHECKPOINTS=\"${CHECKPOINTS:?CHECKPOINTS=\\\"base /outputs/runs/<run>/checkpoint-N ...\\\"}\"\n    read -r -a CHECKPOINT_LIST <<< \"$CHECKPOINTS\"\n    # Resumable: a job that hits its timeout keeps every finished chunk, and the same command runs only the rest.\n    # 10 tasks per domain (60), the size of the base's eval (Qwen_Qwen3.8-27B_automationbench): a\n    # checkpoint is only comparable with a base run on the same tasks\n    hf jobs uv run --detach \\\n        --flavor h200 --image huggingface/trl --secrets HF_TOKEN --timeout 4h \\\n        --volume \"hf://buckets/$BUCKET:/outputs\" \\\n        \"$HERE/eval_automationbench.py\" -- \\\n        --model Qwen/Qwen3.8-27B --checkpoints \"${CHECKPOINT_LIST[@]}\" --per-domain \"${PER_DOMAIN:-10}\" \\\n        --vllm-extra-args=\"--language-model-only --max-num-seqs 64\"\n    exit 0\nfi\n\nPOLICIES=\"${POLICIES:?POLICIES=\\\"<checkpoint>@<harness> ...\\\"}\"\ncase \"$BENCH\" in\n    sbp)\n        TAG=\"${TAG:-sbp-hard51-solo}\"\n        BENCH_ARGS=(--split harness-hub/swebench-pro-v2-hard51-harbor --n-tasks 51 --sandbox-memory-mb 4096\n            --agent-step-limit 100 --agent-timeout 7200)\n        ;;\n    tb)\n        TAG=\"${TAG:-tb21-20pct-solo}\"\n        BENCH_ARGS=(--split harborframework/terminal-bench-2.1@3e235dff6880252a587fa479c09bcb1e16edf2eb\n            --difficulty easy:1,medium:11,hard:6 --n-tasks 18 --sandbox-memory-mb 8192\n            --agent-step-limit 100 --agent-timeout 3600)\n        ;;\n    s800)\n        TAG=\"${TAG:-s800-heldout-solo}\"\n        BENCH_ARGS=(--split \"$S800_HELDOUT\" --n-tasks 1000 --sandbox-memory-mb 8192\n            --agent-step-limit 50 --agent-timeout 1800)\n        ;;\n    *)\n        echo \"unknown BENCH=$BENCH: sbp, tb, s800 or automationbench\" >&2\n        exit 1\n        ;;\nesac\nread -r -a POLICY_LIST <<< \"$POLICIES\"\n\n# The job reads the eval client from the bucket, mounted on /outputs\nhf buckets cp \"$SCRIPTS/evaluate_harbor.py\" \"hf://buckets/$BUCKET/evaluate_harbor.py\"\n\nhf jobs uv run --detach \\\n    --flavor h200 --image huggingface/trl --secrets HF_TOKEN --timeout 14h \\\n    --volume \"hf://buckets/$BUCKET:/outputs\" \\\n    \"$SCRIPTS/launcher_eval.py\" -- \\\n    --data-root /outputs \\\n    --model Qwen/Qwen3.8-27B --eval-checkpoints \"${POLICY_LIST[@]}\" --eval-tag \"$TAG\" \"${BENCH_ARGS[@]}\" \\\n    --sandbox hf-sandbox --expose gradio --max-inflight 32 --max-model-len 131072 \\\n    --vllm-device 0 \\\n    --tool-call-parser qwen3_xml --reasoning-parser qwen3 --no-responses-thinking \\\n    --vllm-extra-args=\"--max-num-seqs 64 --enable-prefix-caching --mamba-cache-mode align\"\n",
  "recipe.yaml": "meta:\n  title: \"Qwen3.8-27B harness adapters\"\n  project: harness-adapters\n  trainer: AsyncGRPOTrainer\n  model_id: Qwen/Qwen3.8-27B\n  description: \"One LoRA adapter per agent harness (pi, hermes, opencode) on Qwen3.8-27B, trained with async GRPO on agentic coding and terminal tasks (scale800 + TermGrade), one job per harness, thinking off.\"\n  tags: [lora, agentic-rl, harbor, safeagents, multi-harness]\n  harnesses: [pi, hermes, opencode]\n  date_added: 2026-11-13\n\nhardware:\n  local: \"2 GPUs per harness, H200 or B200 class (untested)\"\n  hf_jobs: \"h200x2 per harness (untested)\"\n\ndatasets:\n  train:\n    - harness-hub/scale800-harbor@56c7f75d01f70859ec1354e97866e32a175c1a40   # 750 tasks\n    - harness-hub/termgrade-train-harbor                                      # 300 tasks, interleaved\n  eval:\n    sbp-hard51: harness-hub/swebench-pro-v2-hard51-harbor\n    tb21-20pct: \"harborframework/terminal-bench-2.1@3e235dff6880252a587fa479c09bcb1e16edf2eb, 18 tasks\"\n    s800-heldout: \"harness-hub/scale800-heldout-harbor (the repositories left out of training), 1800 s and 50 steps as in training\"\n    automationbench: \"Zapier AutomationBench, 10 tasks per domain (60), as the base eval\"\n\nhyperparameters:\n  lora_r: 32\n  lora_target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]\n  learning_rate: 2.0e-5\n  num_generations: 8\n  gradient_accumulation_steps: 16\n  max_staleness: 16\n  temperature: 0.8\n  max_completion_length: 16384\n  max_model_len: 65536\n  token_budget: 65536\n  agent_step_limit: 50\n  agent_timeout_s: 1800\n  max_inflight: 64\n  tool_efficiency_weight: 0.1\n  max_steps: 1000\n  save_steps: 10\n  thinking: false\n\nvllm:\n  tool_call_parser: qwen3_xml\n  reasoning_parser: qwen3\n  extra_args: [--language-model-only, --enable-prefix-caching, --mamba-cache-mode align]\n\ntrl:\n  fork: \"younesbelkada/trl@e498acc637084cffff14deb09ccdc423a766adb2 (async-grpo-shared-vllm)\"\n  upstream_base: d115286bc5aef8d346e8510bfe312803c7881c4a\n  patch: trl.patch            # the fork's changes to trl/, relative to upstream_base\n\nscripts:\n  train: {hf_jobs: train_hf_jobs.sh, local: train_local.sh}\n  eval: {hf_jobs: eval_hf_jobs.sh, local: eval_local.sh}\n\n# What the command builder on the recipes site offers. Each option is an environment variable of the script it runs.\nbuilder:\n  verified: {hf_jobs: false, local: false}   # whether the scripts of each platform ran as written\n  train:\n    - env: HARNESS\n      label: Harnesses\n      choices: [pi, hermes, opencode]\n      multi: true                # one job per harness: HARNESSES=\"...\" on HF Jobs\n      hf_jobs_env: HARNESSES\n      platforms: [hf_jobs]\n    - env: HARNESS\n      label: Harness\n      choices: [pi, hermes, opencode]\n      platforms: [local]         # one machine trains one harness\n  eval:\n    - env: BENCH\n      label: Benchmark\n      choices:\n        - sbp\n        - tb\n        - s800\n        - {value: automationbench, platforms: [hf_jobs, local]}\n    - env: POLICIES\n      label: Policies\n      input: true\n      default: \"Qwen/Qwen3.8-27B@pi,hermes,opencode\"\n      unless: {BENCH: automationbench}\n    - env: CHECKPOINTS\n      label: Checkpoints\n      input: true\n      default: \"base\"\n      when: {BENCH: automationbench}\n",
  "trl.patch": "TRL changes these recipes run on, relative to upstream huggingface/trl.\n  upstream base: d115286bc5aef8d346e8510bfe312803c7881c4a (2026-11-11, Add UDPO loss for noisy preferences to DPOTrainer (#8211))\n  fork:          younesbelkada/trl async-grpo-shared-vllm = e498acc637084cffff14deb09ccdc423a766adb2\nFork commits:\n  e498acc6 AsyncGRPO: start the rollout concurrency cap at max_concurrent_rollouts\n  965cb093 Harbor example: LoRA, safeagents, live log, token budget and resume, on HarnessAsyncGRPOTrainer\n  83bdbc7c Let several AsyncGRPO/AsyncDistillation trainers share one vLLM server\nApply on a checkout of the upstream base: git apply trl.patch\nRegenerate: git diff $(git merge-base origin/main <fork commit>) <fork commit> -- trl/\n\ndiff --git a/trl/experimental/async_distillation/async_distillation_config.py b/trl/experimental/async_distillation/async_distillation_config.py\nindex bc1d422e..38a1e7a2 100644\n--- a/trl/experimental/async_distillation/async_distillation_config.py\n+++ b/trl/experimental/async_distillation/async_distillation_config.py\n@@ -84,6 +84,9 @@ class AsyncDistillationConfig(_BaseConfig):\n             Timeout in seconds for calls to the vLLM servers: waiting for the student's server to be ready at startup,\n             each generation or scoring request, and each weight-sync call. Waiting for the server and weight-sync calls\n             raise when it runs out; a generation or scoring request that times out is retried.\n+        vllm_lora_name (`str`, *optional*, defaults to `\"trl-policy\"`):\n+            Prefix of the adapter names published to the student's vLLM server under adapter-only sync\n+            (`{vllm_lora_name}-v{N}`). Give each trainer its own prefix when several share one server.\n         teacher_server_urls (`dict[str, str]`, *optional*, defaults to `{\"default\": \"http://localhost:8001\"}`):\n             Teacher vLLM server(s), each started with `vllm serve <teacher-model> --logprobs-mode processed_logprobs\n             --max-logprobs -1`. Every teacher is static: this trainer never streams weight updates to any of them, so a\n@@ -295,6 +298,13 @@ class AsyncDistillationConfig(_BaseConfig):\n             \"weight-sync calls raise when it runs out; a generation or scoring request that times out is retried.\"\n         },\n     )\n+    vllm_lora_name: str = field(\n+        default=\"trl-policy\",\n+        metadata={\n+            \"help\": \"Prefix of the adapter names published to the student's vLLM server under adapter-only sync \"\n+            \"(`{vllm_lora_name}-v{N}`). Give each trainer its own prefix when several share one server.\"\n+        },\n+    )\n     teacher_server_urls: dict[str, str] | str | None = field(\n         default=None,\n         metadata={\ndiff --git a/trl/experimental/async_distillation/async_distillation_trainer.py b/trl/experimental/async_distillation/async_distillation_trainer.py\nindex 69a5da64..b42c97c9 100644\n--- a/trl/experimental/async_distillation/async_distillation_trainer.py\n+++ b/trl/experimental/async_distillation/async_distillation_trainer.py\n@@ -1348,7 +1348,7 @@ class AsyncDistillationTrainer(_BaseTrainer):\n         # Adapter-only vLLM sync is derived from a PEFT model plus a server started with `--enable-lora`, rather\n         # than configured. Rank 0 probes and broadcasts the answer below.\n         self._lora_sync = False\n-        self._lora_name = \"trl-policy\"\n+        self._lora_name = self.args.vllm_lora_name\n         # Absolute: the path is resolved by the *server's* process, which has its own working directory and may not\n         # be on this machine. vLLM reads a path it cannot resolve as a Hub repo id, failing deep inside the engine.\n         self._lora_dir = os.path.abspath(os.path.join(self.args.output_dir, \".vllm_lora\"))\n@@ -1967,11 +1967,10 @@ class AsyncDistillationTrainer(_BaseTrainer):\n         # Under DDP `self.model` is the wrapper, which does not expose `save_pretrained`.\n         model = self.accelerator.unwrap_model(self.model)\n \n-        logger.info(\"Weight sync: pausing vLLM...\")\n-        if self.accelerator.is_main_process:\n-            self.vllm_client.pause()\n+        # No `/pause`: in-flight requests keep the adapter they named, and pausing would stall every other trainer\n+        # sharing this server.\n         t_pause = time.time()\n-        logger.info(f\"Weight sync: pause took {t_pause - t0:.1f}s, waiting for all ranks...\")\n+        logger.info(\"Weight sync: waiting for all ranks...\")\n \n         self.accelerator.wait_for_everyone()\n         t_barrier = time.time()\n@@ -1984,12 +1983,11 @@ class AsyncDistillationTrainer(_BaseTrainer):\n \n         self.accelerator.wait_for_everyone()\n \n-        logger.info(f\"Weight sync: resuming vLLM... (transfer took {t_transfer - t_barrier:.1f}s)\")\n+        logger.info(f\"Weight sync: loading adapter... (transfer took {t_transfer - t_barrier:.1f}s)\")\n         if self.accelerator.is_main_process:\n             # The adapter has to exist on the server BEFORE the version moves below: the rollout worker derives the\n             # adapter it requests from `model_version`, so bumping first would name one that is not loaded yet.\n             self.vllm_client.load_lora_adapter(f\"{self._lora_name}-v{version}\", adapter_dir)\n-            self.vllm_client.resume()\n             stale_version = version - (self.args.max_staleness + 1)\n             if stale_version > 0:\n                 self.vllm_client.unload_lora_adapter(f\"{self._lora_name}-v{stale_version}\")\ndiff --git a/trl/experimental/async_grpo/async_grpo_config.py b/trl/experimental/async_grpo/async_grpo_config.py\nindex 6335eb5f..26a20220 100644\n--- a/trl/experimental/async_grpo/async_grpo_config.py\n+++ b/trl/experimental/async_grpo/async_grpo_config.py\n@@ -88,6 +88,9 @@ class AsyncGRPOConfig(_BaseConfig):\n             Timeout in seconds for calls to the vLLM server: waiting for it to be ready at startup, each generation\n             request, and each weight-sync call. Waiting for the server and weight-sync calls raise when it runs out; a\n             generation request that times out is retried.\n+        vllm_lora_name (`str`, *optional*, defaults to `\"trl-policy\"`):\n+            Prefix of the adapter names published to the vLLM server under adapter-only sync (`{vllm_lora_name}-v{N}`).\n+            Give each trainer its own prefix when several share one server.\n \n         > Parameters that control the training\n \n@@ -296,6 +299,13 @@ class AsyncGRPOConfig(_BaseConfig):\n             \"it runs out; a generation request that times out is retried.\"\n         },\n     )\n+    vllm_lora_name: str = field(\n+        default=\"trl-policy\",\n+        metadata={\n+            \"help\": \"Prefix of the adapter names published to the vLLM server under adapter-only sync \"\n+            \"(`{vllm_lora_name}-v{N}`). Give each trainer its own prefix when several share one server.\"\n+        },\n+    )\n \n     # Parameters that control the training\n     epsilon: float = field(\ndiff --git a/trl/experimental/async_grpo/async_grpo_trainer.py b/trl/experimental/async_grpo/async_grpo_trainer.py\nindex d716d5c7..28251f89 100644\n--- a/trl/experimental/async_grpo/async_grpo_trainer.py\n+++ b/trl/experimental/async_grpo/async_grpo_trainer.py\n@@ -1247,7 +1247,7 @@ class AsyncGRPOTrainer(_BaseTrainer):\n         # Adapter-only vLLM sync is derived from a PEFT model plus a server started with `--enable-lora`, rather\n         # than configured. Rank 0 probes and broadcasts the answer below.\n         self._lora_sync = False\n-        self._lora_name = \"trl-policy\"\n+        self._lora_name = self.args.vllm_lora_name\n         # Absolute: the path is resolved by the *server's* process, which has its own working directory and may not\n         # be on this machine. vLLM reads a path it cannot resolve as a Hub repo id, failing deep inside the engine.\n         self._lora_dir = os.path.abspath(os.path.join(self.args.output_dir, \".vllm_lora\"))\n@@ -1799,11 +1799,10 @@ class AsyncGRPOTrainer(_BaseTrainer):\n         # Under DDP `self.model` is the wrapper, which does not expose `save_pretrained`.\n         model = self.accelerator.unwrap_model(self.model)\n \n-        logger.info(\"Weight sync: pausing vLLM...\")\n-        if self.accelerator.is_main_process:\n-            self.vllm_client.pause()\n+        # No `/pause`: in-flight requests keep the adapter they named, and pausing would stall every other trainer\n+        # sharing this server.\n         t_pause = time.time()\n-        logger.info(f\"Weight sync: pause took {t_pause - t0:.1f}s, waiting for all ranks...\")\n+        logger.info(\"Weight sync: waiting for all ranks...\")\n \n         self.accelerator.wait_for_everyone()\n         t_barrier = time.time()\n@@ -1816,12 +1815,11 @@ class AsyncGRPOTrainer(_BaseTrainer):\n \n         self.accelerator.wait_for_everyone()\n \n-        logger.info(f\"Weight sync: resuming vLLM... (transfer took {t_transfer - t_barrier:.1f}s)\")\n+        logger.info(f\"Weight sync: loading adapter... (transfer took {t_transfer - t_barrier:.1f}s)\")\n         if self.accelerator.is_main_process:\n             # The adapter has to exist on the server BEFORE the version moves below: the rollout worker derives the\n             # adapter it requests from `model_version`, so bumping first would name one that is not loaded yet.\n             self.vllm_client.load_lora_adapter(f\"{self._lora_name}-v{version}\", adapter_dir)\n-            self.vllm_client.resume()\n             stale_version = version - (self.args.max_staleness + 1)\n             if stale_version > 0:\n                 self.vllm_client.unload_lora_adapter(f\"{self._lora_name}-v{stale_version}\")\ndiff --git a/trl/experimental/async_grpo/async_rollout_worker.py b/trl/experimental/async_grpo/async_rollout_worker.py\nindex 754a02d4..d55e043d 100644\n--- a/trl/experimental/async_grpo/async_rollout_worker.py\n+++ b/trl/experimental/async_grpo/async_rollout_worker.py\n@@ -564,6 +564,9 @@ class AsyncRolloutLoop:\n             max_workers=max(1, config.max_concurrent_rollouts), thread_name_prefix=\"grpo-tool\"\n         )\n \n+        # Starts at the requested concurrency, not at `KV cache tokens / max_model_len`: agent rollouts use a small\n+        # fraction of max_model_len, and growing 25% per turnover of the pool took hours when rollouts last minutes.\n+        # The control loop still cuts it when the server's KV cache fills up.\n         self._kv_cap = config.max_concurrent_rollouts\n         self._total_rollouts = 0\n         self._metrics_poll_s = 5.0\n@@ -667,7 +670,6 @@ class AsyncRolloutLoop:\n         async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:\n             self.session = session\n             await self._check_sampling_replay()\n-            await self._init_kv_cap()\n             logger.info(\n                 f\"vllm worker started: num_generations={self.config.num_generations}, \"\n                 f\"max_concurrent_rollouts={self.config.max_concurrent_rollouts}, kv_cap={self._kv_cap}, \"\n@@ -694,26 +696,6 @@ class AsyncRolloutLoop:\n         expected_tokens = self._produced_tokens + self._rollouts_unqueued * self._tokens_per_rollout\n         return expected_tokens < self._token_allowance.value\n \n-    async def _init_kv_cap(self) -> None:\n-        \"\"\"Start the cap at `KV cache tokens / max_model_len`: as many requests as fit at full length.\"\"\"\n-        try:\n-            async with self.session.get(f\"{self.vllm_server_url}/metrics\") as response:\n-                response.raise_for_status()\n-                text = await response.text()\n-            async with self.session.get(f\"{self.vllm_server_url}/v1/models\") as response:\n-                response.raise_for_status()\n-                models = await response.json()\n-        except Exception as e:\n-            logger.warning(f\"Could not read the vLLM server's KV capacity, starting at max_concurrent_rollouts: {e!r}\")\n-            return\n-        kv_matches = re.findall(r'^vllm:cache_config_info\\{.*kv_cache_size_tokens=\"(\\d+)\"', text, re.M)\n-        if not kv_matches:\n-            logger.warning(\"`/metrics` has no `kv_cache_size_tokens`, starting at max_concurrent_rollouts\")\n-            return\n-        kv_tokens = sum(map(int, kv_matches))\n-        max_model_len = max(model[\"max_model_len\"] for model in models[\"data\"] if model[\"max_model_len\"])\n-        self._kv_cap = max(1, min(self.config.max_concurrent_rollouts, kv_tokens // max_model_len))\n-\n     async def _control_loop(self, stop_event: asyncio.Event) -> None:\n         \"\"\"Size the KV cap from the vLLM server's load, polled from `/metrics`.\n \n"
 },
 "other_files": [
  "async_grpo_harbor.py",
  "eval_automationbench.py"
 ],
 "space": "trl-lib/trl-recipes",
 "shared_files": [
  "async_grpo_harbor.py",
  "atif_harbor.py",
  "atif_smoldataenvs.py",
  "atif_traj2envs.py",
  "deepseek_harness.py",
  "eval_sweep.py",
  "evaluate_harbor.py",
  "launcher_eval.py",
  "launcher_train.py",
  "release_adapters.py",
  "slurm_setup.sh"
 ],
 "urls": {
  "html": "https://trl-lib-trl-recipes.static.hf.space/recipes/harness-adapters/Qwen3.8-27B/index.html",
  "markdown": "https://trl-lib-trl-recipes.static.hf.space/recipes/harness-adapters/Qwen3.8-27B/index.md",
  "json": "https://trl-lib-trl-recipes.static.hf.space/recipes/harness-adapters/Qwen3.8-27B/recipe.json",
  "yaml": "https://trl-lib-trl-recipes.static.hf.space/recipes/harness-adapters/Qwen3.8-27B/recipe.yaml",
  "hub_blob_markdown": "https://huggingface.co/spaces/trl-lib/trl-recipes/blob/main/recipes/harness-adapters/Qwen3.8-27B/index.md",
  "hub_raw_markdown": "https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/harness-adapters/Qwen3.8-27B/index.md",
  "hub_raw_yaml": "https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/harness-adapters/Qwen3.8-27B/recipe.yaml",
  "hub_tree": "https://huggingface.co/spaces/trl-lib/trl-recipes/tree/main/recipes/harness-adapters/Qwen3.8-27B",
  "rel_html": "recipes/harness-adapters/Qwen3.8-27B/index.html",
  "rel_markdown": "recipes/harness-adapters/Qwen3.8-27B/index.md",
  "rel_json": "recipes/harness-adapters/Qwen3.8-27B/recipe.json",
  "rel_yaml": "recipes/harness-adapters/Qwen3.8-27B/recipe.yaml"
 },
 "commands": {
  "train": {
   "local": {
    "script": "train_local.sh",
    "direct": false,
    "verified": false,
    "hardware": "2 GPUs per harness, H200 or B200 class (untested)",
    "command": "hf download trl-lib/trl-recipes --repo-type space --include \"recipes/harness-adapters/*\" --local-dir trl-recipes\ncd trl-recipes/recipes/harness-adapters/Qwen3.8-27B\nHARNESS=pi bash train_local.sh"
   },
   "hf_jobs": {
    "script": "train_hf_jobs.sh",
    "direct": false,
    "verified": false,
    "hardware": "h200x2 per harness (untested)",
    "command": "hf download trl-lib/trl-recipes --repo-type space --include \"recipes/harness-adapters/*\" --local-dir trl-recipes\ncd trl-recipes/recipes/harness-adapters/Qwen3.8-27B\nBUCKET=\"<your user>/<bucket>\" bash train_hf_jobs.sh"
   }
  },
  "eval": {
   "local": {
    "script": "eval_local.sh",
    "direct": false,
    "verified": false,
    "hardware": "2 GPUs per harness, H200 or B200 class (untested)",
    "command": "hf download trl-lib/trl-recipes --repo-type space --include \"recipes/harness-adapters/*\" --local-dir trl-recipes\ncd trl-recipes/recipes/harness-adapters/Qwen3.8-27B\nBENCH=sbp \\\nPOLICIES=Qwen/Qwen3.8-27B@pi,hermes,opencode \\\nbash eval_local.sh"
   },
   "hf_jobs": {
    "script": "eval_hf_jobs.sh",
    "direct": false,
    "verified": false,
    "hardware": "h200x2 per harness (untested)",
    "command": "hf download trl-lib/trl-recipes --repo-type space --include \"recipes/harness-adapters/*\" --local-dir trl-recipes\ncd trl-recipes/recipes/harness-adapters/Qwen3.8-27B\nBENCH=sbp \\\nPOLICIES=Qwen/Qwen3.8-27B@pi,hermes,opencode \\\nBUCKET=\"<your user>/<bucket>\" \\\nbash eval_hf_jobs.sh"
   }
  }
 }
}