> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Controlled Frontier RL Stack

> Run controlled multi-model closed-universe legal and enterprise RL with ClientMatterSandbox, HierarchicalRubricReward (zero length penalty), rank-64 LoRA dr_cispo optimization, StateSet Sandboxes, and audited 5-model frontier fine-tuning.

StateSet Agents ships a controlled closed-universe legal and enterprise RL stack built for
apples-to-apples multi-model fine-tuning across open-weight and pre-release hosted models
using the same **StateSet Sandboxes**, binary expert rubric reward, judge, and rank-64 LoRA
optimization settings.

> [!NOTE]
>
> This stack (`ClientMatterSandbox`, `HierarchicalRubricReward`, `dr_cispo`, `FrontierRLRunner`,
> `VLLMLoRASyncClient`, `trace_sandbox_compiler`, `TinkerRLRunner`, `stateset_rl_core` v0.2.0,
> and the `frontier-rl`, `controlled-study`, `tinker-rl`, and `compile-sandbox` CLI commands)
> ships in **StateSet Agents `v1.1.0`**. Model checkpoint metadata is pinned from live Hugging
> Face audits, and architecture, kernel, canary, control-plane, and Rust parity verification is
> captured in `benchmark_results/controlled_frontier_rl/README.md`; live multi-GPU FSDP+vLLM and
> hosted Tinker training require provisioned cluster or Tinker credentials.

## Environments: Closed-Universe Client Matter Sandboxes

Each `ClientMatterTask` (`stateset_agents.core.client_matter_sandbox`) places an agent in a
self-contained client matter containing both **key controlling documents** and **peripheral
distractor documents**. The environment is registered as the 7th domain (`client_matter`) in
both `MultiDomainSandboxPool` and `river_mcp_sandbox_factory`.

Agents operate inside a confined workspace with six sandbox tools:

| Tool | Purpose |
| - | - |
| `list_matter_files` | Lists filenames, categories, and size metadata without leaking document contents |
| `search_matter` | Case-insensitive keyword and regex search across the matter |
| `read_document` | Confined line-ranged read that rejects `..`, path separators, and out-of-matter files |
| `draft_work_product` | Creates or appends to the work-product deliverable (`deliverable.md`) |
| `read_draft` | Inspects the current deliverable revision |
| `signal_complete` | Signals episode completion cleanly (episodes also terminate at `max_steps`) |

## Reward: Hierarchical Binary Rubric (Zero Length Penalty)

Deliverables are graded against an expert rubric of strictly binary **pass (`1`) / fail (`0`)**
criteria grouped by legal or domain issue (`stateset_agents.rewards.rubric_reward`):

* **Judges:** `LLMRubricJudge` (temperature `0.0`, fail-closed JSON verdict parsing) for live
  runs and `DeterministicRubricJudge` for reproducible offline verification.
* **Reward formula:** Weighted sum of criteria pass fraction, full issue-group pass fraction,
  and an all-pass bonus, with **explicitly zero length penalty** (`length_penalty = 0.0`,
  enforced fail-closed by `RubricRewardConfig`):

```text theme={null}
R = w_criteria * (criteria_passed / total_criteria)
  + w_groups   * (issue_groups_passed_in_full / total_issue_groups)
  + w_all      * I[all_criteria_passed]
```

Default weights are `criteria_weight = 0.50`, `issue_group_weight = 0.35`,
`all_pass_bonus = 0.15`, and `length_penalty = 0.0`.

## Optimization: Rank-64 LoRA + CISPO + Dr. GRPO (`dr_cispo`)

Every model in a controlled study trains a **rank-64 LoRA** adapter (`lora_alpha = 128`) with
the **`dr_cispo`** objective preset across `stateset_agents.training.objectives`,
`chunked_rl_loss`, `river_rl`, and `tinker_rl`:

* **Dr. GRPO advantage normalization:** Unscaled group-mean centering `A_i = R_i - mean(R_group)`
  (no standard-deviation division).
* **Dr. GRPO loss normalization:** Constant-denominator token-sum normalization (`seq_sum_const`
  / `normalization="dr_grpo"`), dividing by `batch_size * max_completion_length` to remove
  response-length bias.
* **CISPO asynchronous importance clipping:** Per-token detached clipped importance weights
  (`clip="cispo"`, `cispo_is_cap = 5.0`, or Tinker `loss_fn="cispo"` with `clip_low_threshold`,
  `clip_high_threshold`, and `eps_max = 6.0`) for asynchronous rollout sampling.

> [!WARNING]
>
> **River AI LoRA rank cap:** River's hosted service enforces `MAX_LORA_RANK = 32`
> (`stateset_agents.remote.river_batches.MAX_LORA_RANK`). Both `FrontierRLConfig` and
> `validate_study_controls()` fail closed if `lora_rank > 32` is requested on `river`. Use
> `distributed_fsdp_vllm` for the four open-weight checkpoints and `tinker` for Inkling 2 Small
> when training rank-64 LoRA adapters, or cap `lora_rank <= 32` when targeting River.

## Audited 5-Model Frontier Fine-Tuning Matrix

All five models run rollouts in **StateSet Sandboxes** under the `lab_default` harness, with
`(learning_rate, rollout_group_size)` swept on **Nemotron 3.5 Super VL** and transferred
verbatim to the other four models:

| Model | Audited HF Checkpoint (Pinned SHA) | Architecture & Format | SFT Path | RL Path (`r=64`, `dr_cispo`) |
| - | - | - | - | - |
| **Muse Spark Open** | `meta-models/Muse-Spark-Open-816B-A42B` (`0fb02478`) | `MuseSparkForConditionalGeneration` (BF16, gated) | `stateset-agents muse-spark-open` | `FrontierRLConfig(model="muse-spark-open")` (`distributed_fsdp_vllm`) |
| **Nemotron 3.5 Super VL** *(Sweep Anchor)* | `nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-BF16` (`fc067b34`) | Hybrid Mamba-2 + Attn + MoE + C-RADIO (BF16) | `stateset-agents nemotron-vl --model super-vl` | `FrontierRLConfig(model="nemotron-3.5-super-vl")` (attention-only, vision frozen) |
| **Beam 1.0** | `reflection/Beam-1.0-501B-A23B` (`877a5d69`) | `BeamForCausalLM` (BF16 MoE, Apache 2.0) | `stateset-agents frontier-sft --model beam-1.0` | `FrontierRLConfig(model="beam-1.0")` (gated GQA attention targets) |
| **GLM-5.3** | `zai-org/GLM-5.3` (`ba32f8c1`) | `GlmMoeDsaForCausalLM` (FP8 to BF16 FSDP) | `stateset-agents frontier-sft --model glm5.3` | `FrontierRLConfig(model="glm5.3")` (sparse attention targets) |
| **Inkling 2 Small** | `thinkingmachines/Inkling-2-Small` (`885d78bf`) | `Inkling2ForConditionalGeneration` (ModelOpt NVFP4 public weights; hosted on Tinker) | `stateset-agents train-remote --provider tinker --base-model thinkingmachines/Inkling-2-Small` | `TinkerRLRunner` (`rank=64`, `loss_fn="cispo"`, Dr. GRPO normalization) |

## CLI Quickstart and Controls Verification

All three frontier RL CLI commands import lazily with zero eager `torch` startup overhead:

```bash theme={null}
# 1. Inspect all 5 audited frontier RL models and backend blockers
stateset-agents frontier-rl --list

# 2. Preview, export a cluster FSDP2+vLLM/Tinker bundle, or execute rank-64 dr_cispo RL
stateset-agents frontier-rl --model beam-1.0 --lora-rank 64 --backend distributed_fsdp_vllm
stateset-agents frontier-rl --model beam-1.0 --export-bundle outputs/beam_cluster --judge-model claude-sonnet-4-6
stateset-agents frontier-rl --model beam-1.0 --execute --rounds 2 --update-epochs 2 --judge-model claude-sonnet-4-6 --output-dir outputs/beam_rl
stateset-agents frontier-rl --model nemotron-3.5-super-vl --lora-rank 64 --backend distributed_fsdp_vllm

# 3. Validate 5-model study controls, run ClientMatterSandbox Dr. GRPO smoke & export full 5-model cluster kit
stateset-agents controlled-study --smoke --output-dir outputs/controlled_study
stateset-agents controlled-study --output-dir outputs/study_kit --export-bundles --judge-model claude-sonnet-4-6 --vllm-rollout-url http://127.0.0.1:8000/v1

# 4. Preview online Tinker RL for Inkling 2 Small (rank-64 CISPO + Dr. GRPO)
stateset-agents tinker-rl --base-model thinkingmachines/Inkling-2-Small --lora-rank 64 --loss-fn cispo --dry-run

# 5. Compile production agent traces into offline replay sandboxes + binary rubrics + canary checks
stateset-agents compile-sandbox --demo --output-dir outputs/compiled_sandboxes

# 6. Disaggregated async RL with live vLLM LoRA hot-swap sync and pickle-free resume checkpoints
stateset-agents frontier-rl --model beam-1.0 --execute --rounds 4 \
  --vllm-rollout-url http://127.0.0.1:8000/v1 \
  --vllm-sync-url http://127.0.0.1:8000 \
  --checkpoint-every-round \
  --resume-from outputs/beam_rl

# 7. Preview Beam 1.0 or GLM-5.3 distributed FSDP SFT blueprints
stateset-agents frontier-sft --model beam-1.0
stateset-agents frontier-sft --model glm5.3
```

## Disaggregated Async RL, Trace-to-Sandbox Compiler & Rust Accelerator

* **Live vLLM LoRA Hot-Swap & Pickle-Free Resume:** `VLLMLoRASyncClient` syncs updated attention-only LoRA adapters into disaggregated vLLM workers between rounds (`/v1/load_lora_adapter`, `/v1/unload_lora_adapter`, `/health`, transient retries, SSRF localhost/HTTPS guard), while `create_vllm_rollout_fn(active_model_fn=...)` routes rollouts dynamically without restarting the inference server. `FrontierRLRunner` saves pickle-free `safetensors` adapter + AdamW resume checkpoints validated by a fail-closed `config_sha256` fingerprint, and `max_policy_lag_rounds` drops stale async rollouts via `policy_version`.
* **Production Trace-to-Sandbox Compiler:** `stateset_agents.core.trace_sandbox_compiler` turns OpenAI-chat or normalized production logs into deterministic offline replay sandboxes (`CompiledTraceSandbox`), binary issue-group rubrics, anti-reward-hacking canary reports (golden vs. empty deflection vs. forbidden claim vs. 25x verbose padding with `length_penalty == 0.0`), and `ClientMatterTask` JSONL datasets. Exposed with full parity across CLI (`compile-sandbox`), Weight Studio REST (`POST /api/weight-studio/rl/compile-sandbox`), stdio/HTTP MCP (`studio_compile_sandbox`), and `@stateset/agents` (`client.studio.compileSandbox(...)`).
* **Native Rust Accelerator (`stateset_rl_core` v0.2.0):** Optional `abi3-py310` PyO3 wheel providing Rayon-parallel `compute_dr_grpo_advantages` (up to **13x** faster), `batch_score_hierarchical_rubrics` (up to **94x** faster), `batch_compute_gae` (up to **20x** faster), and `compute_dr_cispo_batch_loss` with bit-exact NumPy/Python fallback when the wheel is not installed.

For interactive GPU execution on Google AI Ultra (H100 / A100 / L4, with T4/CPU fallback),
open `notebooks/controlled_frontier_rl_colab.ipynb` to run `ClientMatterSandbox` + `.jsonl`
matter loading, real rank-64 attention LoRA `dr_cispo` updates via `FrontierRLRunner`, the
Nemotron 3.5 Super VL sweep + Appendix export, and opt-in `TinkerRLRunner` for Inkling 2 Small.

`controlled-study --output-dir` writes both `study_manifest.json` and
`appendix_training_config.md` capturing the exact shared environment, reward weights, judge
prompt, LoRA rank/targets, swept hyperparameters from Nemotron 3.5 Super VL, and pinned
checkpoint revisions.

Continue with the [Open-Weight RL suite](https://docs.stateset.com/stateset-agents/open-weight-rl.md),
[River AI training](https://docs.stateset.com/stateset-agents/river-training.md), or the
[StateSet Agents CLI reference](https://docs.stateset.com/stateset-agents/cli.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.