Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CPU checks
on:
push:
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install -e '.[dev]'
- run: ruff check .
- run: pytest -q
- run: bash scripts/audit_public_tree.sh
- name: Audit pull request document history
if: github.event_name == 'pull_request'
env:
BASE_REF: ${{ github.base_ref }}
run: bash scripts/audit_public_tree.sh --history-base "origin/$BASE_REF"
sandbox-practice:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install -e '.[dev,sandbox]' -e practices/h_cluster
- run: pytest practices/h_cluster/tests -q
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ docs/agents/*
!docs/deployment.md
!docs/math-distill.md
!docs/sandbox-rollout.md
!docs/rollout-runtime-lifecycle.md
!docs/train-inference-consistency.md
!docs/web-console.md
practices/**/VALIDATION.md
Expand Down
31 changes: 31 additions & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,37 @@ even when service shutdown fails. Both Docker and Sandbox runtimes reject new
attempts while observed cleanup-required markers remain. Inspect the resources
before removing resolved markers.

## Hub training with remote workers

Use `manager.mode: hub` with an explicit `hub_port`, reachable `hub_url`
and GPU pool, and select `rollout.provider: hub_pull`. The trainer submits
groups to the Hub; workers execute attempts and publish trajectory IRs.
The trainer validates their digests, batch identities, readiness and policy
versions before consuming them. Workers use Docker by default; a sandbox
configuration selects OpenSandbox with the same trajectory contract. See
[sandbox rollout](sandbox-rollout.md) for environment and cleanup settings.

Set `HARBORRL_HUB_URL` and `HARBORRL_HUB_TOKEN_FILE` for the training process.
For Ray deployments, `HARBORRL_HUB_ENV_FILE` can name a shared JSON object
mapping these variable names and `RUN_ID` to values; explicit environment
variables take precedence. Protect the token file and keep credentials out
of checked-in configuration.

Every worker must export `HARBORRL_HUB_ATTEMPT_MIRROR` as an absolute shared
directory, for example `/shared/harborrl/attempts`. The trainer must see the
same directory at the same path. Missing or relative paths fail before an
attempt starts. Attempts execute on worker-local storage and publish their
IR and evaluation records into this shared directory. If task roots differ
between trainer and worker, configure `HARBORRL_HUB_TASK_PATH_MAP` as
`shared_path=worker_path` pairs separated by commas. The worker gateway
address must be reachable from inside its Docker or OpenSandbox environment.

Validate consecutive training steps, checkpoint publication and a separate
restore followed by another training step. Successful transport, zero-reward
steps and checkpoint restoration establish execution correctness; they do
not establish learning improvement. Checkpoint space guards and retention
settings help bound storage use but do not replace capacity planning.

## Operational limits

Service mode requires shared storage visible at the configured paths on the
Expand Down
153 changes: 147 additions & 6 deletions docs/sandbox-rollout.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,27 @@ Set `training.export_hf: true` to export HF weights under
independent model serving and evaluation. Optimizer checkpoints remain under
`checkpoints/`. The export option defaults to `false`.

Use `training.resume` to load a Slime checkpoint root, including optimizer and
scheduler state. Relative paths resolve beside the YAML file. The default is
`null`, which starts from the model checkpoint. `training.num_rollout` remains
the total target rollout count. A checkpoint at index `k` resumes at `k + 1`;
set the target to at least `k + 2` to perform another update. A target of
`k + 1` restores state without taking a new training step. Set
`training.max_tokens_per_gpu` (default `16384`)
for the training batch token budget and `training.max_ckpt_keep` (default `2`)
for checkpoint retention; both require positive integers. These options must
be declared in configuration: ambient `RESUME_LOAD`, `MAX_TOKENS_PER_GPU`, and
`MAX_CKPT_KEEP` variables are filtered by the local training target.

The launcher supervises Slime with `harborrl.platform.checkpoint_guard`; the
pinned backend silently ignores unknown retention flags. The supervisor checks
available space before launch (at least 128 GiB, or 1.15 times the resumed
checkpoint size), and removes older generations only after a tracker-published
successor has readable tensor archives and complete requested HF exports. It
records deletion manifests in `checkpoints/<run>/retention.jsonl`. These are
structural checks, not a full tensor restore, and the preflight is not a space
reservation: budget for a complete extra generation while the old one remains.

## Concurrency and evidence

`max_live_instances` bounds all active instances; each image binding has its
Expand All @@ -151,12 +172,132 @@ using process-shared locks. Shared-filesystem flock support is required when
runners use the same lock directory across hosts.

Groups use the same identity, policy barrier, verifier and consumption audit
as Docker. Failed slots cancel their group siblings. Direct Slime rollout
batches cancel and await all remaining groups and their slot cleanup before
closing the runtime and propagating a failure or cancellation. RolloutService
requests wait for submitted independent groups before rejecting a partial
batch. Unconfirmed cleanup blocks new admission. Production export never
accepts synthetic evidence.
as Docker. Failed slots cancel and await their group siblings. Direct Slime
rollout batches also settle every remaining group before deciding whether
recovery is permitted. RolloutService requests wait for submitted independent
groups before rejecting a partial batch. Unconfirmed cleanup blocks new
admission. Production export never accepts synthetic evidence.

### Independent cleanup and admission debt

Each Sandbox runner registers a dedicated Linux session, inherited attempt
tag, PID start time, host and boot identity in `runner-process.json`. After the
runner exits, a separate process on the same host observes and terminates any
surviving owned processes. PID reuse, a different host or boot, and unreadable
possible descendants leave ownership unresolved. Protected processes older
than the runner are excluded. The observer also verifies its parent chain and
excludes those exact ancestor PIDs and start times, so a protected SSH service
that launched the observer cannot block cleanup just because it started after
the runner. A changed parent chain, the runner's session, or its inherited
attempt tag rejects the observer as nonindependent. Transient process read
errors retry a complete scan within the cleanup deadline; persistent errors
retain debt and their observations. Process sessions, `/proc` and POSIX signals
are required; this is a Linux runner contract.

The observer reads the attempt's locked runtime and lifecycle, then polls the
platform independently of the SDK. A known allocation is absent only after
GET returns 404, a complete and consistent paginated project inventory excludes
that ID, and the process proof succeeds. DELETE acknowledgement or a lifecycle
string alone cannot close cleanup. The observer can delete only the allocation
ID recorded for that attempt; an unknown POST outcome remains blocked for
ownership reconciliation. Unknown inventory entries are preserved.

Every observation is retained under `cleanup-reconciliations/`. A successful
observation publishes immutable `cleanup-reconciliation.json`, bound to the
runtime, lifecycle and process-owner digests. The original
`cleanup-required.json` markers and lifecycle history remain available; a
validated receipt explains their closure. Repeating a completed reconciliation
returns that receipt.

Image and global live capacity remain reserved while cleanup is unresolved.
Queued requests wake and fail when debt appears, including when all capacity
is retained. After a new independent reconciliation succeeds, the owning
runtime can call `sandbox_admission.reconcile(attempt_root)` to release the
retained capacity. Restarting into an old attempt is forbidden: inspect its
evidence, finish cleanup on the original runner host, then use a fresh protocol.
To invoke the observer manually on that host, supply the nonsecret resolved
configuration on stdin, for example from a private deployment script:

```python
import json
import subprocess
import sys
from harborrl.rollout.harbor_job.sandbox_config import load_sandbox

cfg = load_sandbox('sandbox.yaml')
subprocess.run([sys.executable, '-m', 'harborrl.rollout.harbor_job.reconcile',
'ATTEMPT_ROOT'], input=json.dumps(cfg) + '\n', text=True, check=True)
```

Credentials remain in the configured permission-restricted file. Cleanup stderr
and receipts belong in the private run evidence directory.

### Whole rollout generation recovery

Sandbox Slime batches freeze task order, group and slot membership, sampling
parameters and the serving policy version before the first generation. A
retryable infrastructure failure invalidates the entire generation, discards
all partial sample IR/reward/response fields, and uses new batch, group, attempt
and trajectory identities for recovery. The task list and policy stay fixed.
Low rewards, protocol or audit errors, cancellation, seed budget exhaustion
and unresolved cleanup never trigger this recovery. A sibling terminal error
discovered during cleanup takes precedence over a retryable failure.

`HARBORRL_NATIVE_GENERATION_POLICY` accepts the positive integer limits
`max_attempts_per_rollout` (default 32) and `max_failed_groups_per_rollout`
(default 8), plus the nonnegative `max_reruns_per_seed` (default 2). The
failed-group limit blocks new attempts after it is exceeded; exhaustion of any
group's slot attempts also invalidates the generation immediately. Seed reruns
are shared across all batches, not reset for each batch.

`rollout-generations/` contains a frozen policy, each batch's input manifest,
generation reservation, failure and superseded records, and a single selected
generation. Only complete results from the expected tasks, slots, policy and
generation can be selected, after the normal training-export audit passes.
An attempt retry within a generation preserves its input-derived sampling seed.
A whole generation rerun changes the batch and group identity, so the existing
SGLang seed derivation produces a new sampling seed. The base training seed,
sampling parameters, tasks and policy stay frozen; recovery is independent of
reward and does not promise bit-for-bit replay across generations.
`generation-budgets/` persists attempt reservations and failed groups under a
shared-filesystem flock. Embedded and service workers use the same bound;
restarting a worker cannot reset it or increase the limits. Reopening an
existing rollout directory is rejected and requires a fresh run protocol.

### Reliability control plane

Sandbox rollouts also maintain an append-only `sandbox-reliability/events.jsonl`
journal under the run root. Every event has a monotonic sequence, UTC and
monotonic timestamps, attempt id, state, failure kind, node, allocation id,
budget snapshot, decision and sanitized detail. Consecutive events are linked
by SHA-256 digests, so rewriting or removing history is detectable. URLs,
credential-looking fields and long diagnostic strings are redacted before the
journal is written. The journal is independent from rewards: an invalid attempt
can be retried as a new attempt id, but its partial trajectory never enters a
training export.

Configure retry spacing and node cooling with
`HARBORRL_NATIVE_RELIABILITY_POLICY` as a JSON object. Supported keys are
`backoff_seconds`, `max_backoff_seconds`, `node_consecutive_failures` and
`node_cooldown_seconds`; `max_attempts_per_slot` remains governed by the
existing native attempt limit. A node reaching the consecutive platform-failure
threshold is unavailable until its cooldown expires. Configure the frozen seed
infrastructure budget with `HARBORRL_NATIVE_INFRA_BUDGET` using positive JSON
integers for `attempts`, `create_retries`, `cleanup_reconciliations` and
`storage_faults`, plus a positive finite `wall_clock_seconds`. Once any budget
is exhausted, the runtime records a fail-seed event and does not reserve another
attempt. These limits must be chosen before a run and cannot be increased after
observing rewards or held-out results.
The seed budget lock persists its original limits and absolute wall-clock
expiry, and journal replay restores the remaining counters. Removing the
budget when reopening a locked seed is rejected, even before its first attempt.
An infrastructure failure remains counted after cleanup succeeds; cleanup
receipts are additional events and do not replace failed outcomes.

The node-cooling ledger can exclude known nodes when candidates are available.
Server-controlled scheduling is still authoritative; this does not force the
platform to choose a different node. Unknown allocation ownership, cleanup
debt and exhausted budgets require reconciliation or a fresh protocol.

## Checks

Expand Down
5 changes: 5 additions & 0 deletions harborrl/backends/slime_v032/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"MODEL_TAG": ("model", "args_file"),
"NUM_ROLLOUT": ("training", "num_rollout"),
"SAVE_INTERVAL": ("training", "save_interval"),
"MAX_TOKENS_PER_GPU": ("training", "max_tokens_per_gpu"),
"MAX_CKPT_KEEP": ("training", "max_ckpt_keep"),
"LR": ("training", "learning_rate"),
"ROLLOUT_BATCH_SIZE": ("sampling", "groups_per_batch"),
"N_SAMPLES": ("sampling", "group_size"),
Expand Down Expand Up @@ -93,6 +95,8 @@ def launch_plan(config):
environment['HARBORRL_NATIVE_RUNNER_TRANSPORT'] = c['harbor'].get('runner_transport', 'ssh')
if c['training'].get('seed') is not None:
environment['HARBORRL_TRAINING_SEED'] = c['training']['seed']
if c['training'].get('resume') is not None:
environment['RESUME_LOAD'] = c['training']['resume']
if sandbox is not None:
environment['HARBORRL_NATIVE_SANDBOX'] = json.dumps(sandbox, sort_keys=True)
return {'config': config, 'math': selection.asdict(),
Expand Down Expand Up @@ -121,6 +125,7 @@ def field_usage():
"training.backend_contract": ["environment:HARBORRL_NATIVE_SLIME_CONTRACT", "preflight:backend hooks"],
"training.seed": ["environment:HARBORRL_TRAINING_SEED"],
"training.export_hf": ["run_environment:SAVE_HF"],
"training.resume": ["environment:RESUME_LOAD"],
"harbor.workers": ["environment:HARBORRL_NATIVE_RUNNER_WORKERS", "preflight:worker probe"],
"harbor.runner_transport": ["environment:HARBORRL_NATIVE_RUNNER_TRANSPORT"],
"harbor.environment": ["environment:HARBORRL_NATIVE_SANDBOX", "runner:environment"],
Expand Down
Loading
Loading