> ## 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.

# Open-Weight RL suite

> Train open-weight agents with chunked/Triton GSPO, DAPO, GEPO, and VAPO policy losses, six concurrent verifiable MCP sandboxes, MoE/FP8 precision bridging, and Step-0 CAA warm-start.

StateSet Agents pairs memory-efficient long-context policy optimization across all four
flagship RL trainers (`GSPOTrainer`, `DAPOTrainer`, `GEPOTrainer`, and `VAPOTrainer`) with
six deterministic enterprise MCP sandboxes, turn-level credit assignment, adaptive
curriculum scheduling, and an online reward-hacking circuit breaker.

> [!NOTE]
>
> This guide reflects the `v0.99.1` release candidate for `v1.0.0` reviewed on November 24,
> 2026\. The retained 3-seed ablation (`benchmark_results/open_weight_rl/ablation_v1_rc.json`)
> verifies the full pipeline on CPU with a tiny transformer; live 8B+ multi-GPU and CUDA
> Triton kernel measurements remain an explicit pre-graduation gate recorded in
> `contracts/component_maturity_v1.json`.

## Chunked and Triton-fused LM-head loss

Large-vocabulary open-weight models (for example Qwen3 with `vocab_size = 152,064` at 16k
sequence length) require roughly **37.1 GB** just to materialize full `[B, T, V]` logits.
Enabling `chunked_loss_chunk_size` projects `[B, T, H]` hidden states through `lm_head` in
token chunks, auto-dispatching a single-pass Triton online-logsumexp SRAM kernel on CUDA
with a bit-exact PyTorch chunked fallback on CPU:

```python theme={null}
from stateset_agents.training import (
    DAPOConfig,
    GEPOConfig,
    GSPOConfig,
    VAPOConfig,
    triton_chunked_logprobs_available,
)

print("Triton CUDA kernel available:", triton_chunked_logprobs_available())

config = GSPOConfig(
    model_name="Qwen/Qwen3-8B",
    chunked_loss_chunk_size=256,
    use_loss_checkpointing=True,
    tis_clip_max=2.0,
    icepop_bounds=(0.5, 2.0),
    moe_aux_loss_coef=0.01,
)
```

* **16k Qwen3 projection (`B=4`, `chunk_size=256`):** `37.123 GB -> 0.145 GB` (**99.61% peak logit VRAM saved**) with `0.0` forward/backward log-prob delta against full logits.
* **MoE and FP8 stability:** `moe_router_aux_loss` penalizes router collapse, while `tis_clip_max` (Truncated Importance Sampling) and double-sided `icepop_bounds` stabilize FP8 rollout workers paired with BF16 learners.

## Six concurrent verifiable MCP sandboxes

`MultiDomainSandboxPool` runs mixed multi-turn batches across six zero-dependency
enterprise state-machine verifiers with per-domain z-score advantage normalization and
automatic turn-level PRM credit assignment:

| Domain | Sandbox class | Deterministic verification |
| - | - | - |
| `commerce` | `CommerceLedgerSandbox` | SQLite order, return, and refund ledger transitions |
| `coding` | `CodeVerificationSandbox` | Timeout-guarded Python patch and unit-test execution |
| `sql` | `SQLAnalyticsSandbox` | Read-only BI SQL query result verification |
| `rest_api` | `RESTAPISandbox` | OpenAPI schema validation and idempotency-key enforcement |
| `docker_code` | `DockerCodeSandbox` | Container-isolated patch and pytest check (with clean subprocess fallback) |
| `web_agent` | `BrowserDOMSandbox` | Stateful DOM, form, and checkout/return portal verification |
| `client_matter` *(post-`v0.99.1`)* | `ClientMatterSandbox` | Closed-universe client matter document search, work-product drafting, and binary hierarchical rubric verification |

All sandboxes also plug directly into River AI's native `rl.RolloutEngine` through
`river_mcp_sandbox_factory(domain)` in `stateset_agents.remote.river_environment`. See the
[Controlled Frontier RL Stack](https://docs.stateset.com/stateset-agents/controlled-rl-stack.md) for the full closed-universe
legal/enterprise stack, `dr_cispo` objective, and 5-model frontier fine-tuning matrix.

## Closed-loop adaptive runtime and Step-0 warm-start

`DisaggregatedRLRuntime.run_adaptive_sandbox_loop(...)` unifies:

1. **Step-0 PyTorch CAA warm-start:** `extract_torch_caa_vector` and
   `bake_torch_caa_steering` apply reversible `rank1_weight_bake` or `bias_shift` edits to
   PyTorch/HF/PEFT causal LMs before RL step 1.
2. **Adaptive difficulty curriculum:** `AdaptiveDifficultyCurriculum` concentrates rollouts
   in the 20%–80% solve band, promotes failing OTLP production traces into the active replay
   queue, and synthesizes multi-constraint variants of mastered tasks.
3. **Turn-level credit and reward-hacking defense:** `compute_turn_level_advantages`
   attributes terminal rewards to exact tool calls, while `OnlineRewardHackingGuard` flags
   calibration drift (`REWEIGHT_JUDGE`), entropy collapse, length explosion
   (`INCREASE_KL`), or reward hacking (`HALT_AND_ROLLBACK`).
4. **vLLM Level-1 sleep/wake weight sync:** `sync_vllm_sleep_wake` sleeps the rollout
   engine, pushes updated weights, and wakes it without OOM spikes.

## Quick offline verification and blueprints

Run the local shootout, inspect a cloud/River blueprint, or execute the end-to-end demo
without a GPU or API key:

```bash theme={null}
# Verify chunked forward/backward parity, VRAM projection & 6-domain sandbox pool
stateset-agents rl --run-shootout --json

# Plan a reproducible Modal, RunPod, Kubernetes, local, or River AI RL run
stateset-agents rl --model Qwen/Qwen3.6-35B-A3B-FP8 --algorithm cispo --cloud river --json
stateset-agents rl --model Qwen/Qwen3-8B --algorithm dapo --cloud modal --gpus 4 --json

# Reproduce the 3-seed Step-0 CAA + Chunked GSPO ablation artifact
python benchmarks/open_weight_rl_ablation.py
```

The retained `v0.99.1` ablation (`benchmark_results/open_weight_rl/ablation_v1_rc.json`)
records **`+1.846 ± 0.0298`** mean log-prob margin gain (`0.0375 -> 1.8836`), **`3/3` seeds
improved**, and **`6/6` verifiable sandboxes passing in `114.64 ms`** on CPU.

Continue with the [3D Weight Studio and Live RL Cockpit](https://docs.stateset.com/stateset-agents/weight-studio.md),
[River AI 0.11 training and serving](https://docs.stateset.com/stateset-agents/river-training.md), or the
[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.