Copy page "**[📖 Documentation](https://gym.modal.dev)** · **[API Reference](https://gym.modal.dev/reference/)**\n\nModal Training Gym is a Python SDK for RL post-training on [Modal](https://modal.com).\n\nThe library takes care of infrastructure concerns such as Cluster topology, Ray/NCCL bring-up, volume mounts, checkpointing, and serving for eval and rollouts, so you can focus on training models.\n\n## Quickstart\n\nRequirements:\n\n- Python 3.12\n\nInstall with pip:\n\n```bash\npip install -q git+https://github.com/modal-projects/training-gym.git@main\n```\n\nOr pin it in `pyproject.toml` for uv:\n\n```toml\ntraining-gym = { git = \"https://github.com/modal-projects/training-gym.git\", branch = \"main\" }\n```\n\nAuthenticate with Modal:\n\n```bash\nmodal setup\n```\n\nThen, it's as easy to use as:\n\n```python\nfrom modal_training_gym import (\n HuggingFaceDataset,\n Qwen3_4B,\n Qwen3_4b_Recipe,\n TrainConfig,\n)\n\n\nclass MathDataset(HuggingFaceDataset):\n hf_repo = \"zhuzilin/dapo-math-17k\"\n input_key = \"prompt\"\n label_key = \"label\"\n output_format = \"jsonl\"\n apply_chat_template = True\n\n\nconfig = TrainConfig(\n model=Qwen3_4B(),\n dataset=MathDataset(n_rows=120),\n recipe=Qwen3_4b_Recipe(\n gpu_type=\"H100\",\n actor_num_nodes=1,\n actor_num_gpus_per_node=8,\n tensor_model_parallel_size=1,\n sequence_parallel=False,\n rollout_num_gpus=8,\n rollout_num_gpus_per_engine=1,\n colocate=True,\n num_rollout=1,\n n_samples_per_prompt=4,\n rollout_batch_size=8,\n rollout_max_response_len=2048,\n max_tokens_per_gpu=4096,\n sglang_mem_fraction_static=0.6,\n rm_type=\"deepscaler\",\n ),\n)\nrun = config.launch()\nprint(run.training_run_id)\n```\n\nWhile that's running, you can view the run in the dashboard:\n\n```bash\ntraining-gym setup # first-time deploy\ntraining-gym open # opens in your browser\n```\n\n\n\n## Agent set-up\n\nInstall the Training Gym skill bundle into your project:\n\n```bash\ntraining-gym skills install\n```\n\nThis installs all bundled skills—`agent-driven-training`, `example-validation`,\n`modal-infrastructure`, `model-support`, and `training-gym-overview`—under the\ncross-tool `.agents/skills/` directory. It also links each skill into\n`.claude/skills/` when that path is safe to manage. Canonical and Claude-side\nconflicts are preserved with a warning without blocking unrelated skills. Run\nthe command again with `--force` to replace existing canonical copies or\nmanageable Claude child paths.\n\nThis repository also includes an `AGENTS.md` and the source `skills/`\ndirectory that teach agents how to use and develop the framework.\n\nAgents browsing the docs can start at the [llms.txt](https://gym.modal.dev/llms.txt).\n\n## Models\n\nModels with a built-in training recipe, with the `ModelConfig` and recipe classes to import for each.\n\n<div class=\"catalog models-catalog\" style=\"--catalog-columns: minmax(0, 1.7fr) minmax(0, 0.7fr) minmax(0, 1.1fr) minmax(0, 1.6fr)\">\n\n<!-- BEGIN MODELS TABLE -->\n<!-- Auto-generated by scripts/generate_models_table.py from the recipe registries in modal_training_gym/train_recipes/*/__init__.py. Do not edit by hand. -->\n\n| Model | Framework | ModelConfig | Recipe |\n|---|---|---|---|\n| `Qwen/Qwen3-0.6B` | `slime` | `Qwen3_0_6B` | `Qwen3_0_6b_Recipe` |\n| `Qwen/Qwen3-1.7B` | `slime` | `Qwen3_1_7B` | `Qwen3_1_7b_Recipe` |\n| `Qwen/Qwen3-4B` | `slime` | `Qwen3_4B` | `Qwen3_4b_Recipe` |\n| `Qwen/Qwen3-8B` | `slime` | `Qwen3_8B` | `Qwen3_8b_Recipe` |\n| `Qwen/Qwen3-ASR-1.7B` | `slime` | `Qwen3_ASR_1_7B` | `Qwen3_ASR_1_7b_Recipe` |\n| `Qwen/Qwen3-VL-8B-Instruct` | `slime` | `Qwen3_VL_8B` | `Qwen3_VL_8b_Recipe` |\n| `Qwen/Qwen3.5-0.8B` | `slime` | `Qwen3_5_0_8B` | `Qwen3_5_0_8b_Recipe` |\n| `Qwen/Qwen3.5-2B` | `slime` | `Qwen3_5_2B` | `Qwen3_5_2b_Recipe` |\n| `Qwen/Qwen3.5-4B` | `slime`, `miles` | `Qwen3_5_4B` | `Qwen3_5_4b_Recipe`, `Qwen3_5_4b_Miles_Recipe` |\n| `Qwen/Qwen3.5-9B` | `slime` | `Qwen3_5_9B` | `Qwen3_5_9b_Recipe` |\n| `Qwen/Qwen3.6-27B` | `slime` | `Qwen3_6_27B` | `Qwen3_6_27b_Recipe` |\n| `Qwen/Qwen3.6-35B-A3B` | `slime` | `Qwen3_6_35B` | `Qwen3_6_35b_Recipe` |\n| `Qwen/Qwen3.8-27B` | `slime` | `Qwen3_8_27B` | `Qwen3_8_27b_Recipe` |\n| `google/gemma-4-26B-A4B-it` | `miles` | `Gemma4_26B_A4B` | `Gemma4_26B_A4B_Recipe` |\n| `moonshotai/Moonlight-16B-A3B-Instruct` | `miles` | `Moonlight_16B_A3B_Instruct` | `Moonlight_16B_A3B_Recipe` |\n| `zai-org/GLM-4.7` | `slime` | `GLM_4_7` | `GLM_4_7_Recipe` |\n<!-- END MODELS TABLE -->\n\n</div>\n\n## Tutorials\n\nThe fastest path through the API is the [tutorials](https://github.com/modal-projects/training-gym/blob/main/tutorials). Each one ships as a runnable `.py` and a paired `.ipynb` narrated cell-by-cell.\n\nDifficulty is a rough signal for where to start:\n\n- _Beginner_: single-node, introduces one framework concept.\n- _Intermediate_: 1–2 nodes, or wires up something non-default (custom reward, external script).\n- _Advanced_: ≥2 nodes with non-trivial parallelism (tensor-parallel, colocated RL, long context); assumes familiarity with the underlying framework (i.e, slime/miles).\n\n<div class=\"catalog tutorial-catalog\" style=\"--catalog-columns: minmax(0, 1.6fr) minmax(0, 2.6fr) minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1fr)\">\n\n<!-- BEGIN TUTORIAL TABLE -->\n<!-- Auto-generated by generate_tutorial.py from TUTORIAL_METADATA in each tutorial source. Edit metadata there, not here. -->\n\n### RL\n\n| Tutorial | Summary | Difficulty | Framework | Launch |\n|---|---|---|---|---|\n| [`000_rl_basics`](https://gym.modal.dev/tutorials/rl/000_rl_basics/) | Writing correct haikus | Beginner | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F000_rl_basics%2F000_rl_basics.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`001_sandboxes`](https://gym.modal.dev/tutorials/rl/001_sandboxes/) | Code RL with Harbor sandboxed evals | Intermediate | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F001_sandboxes%2F001_sandboxes.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`002_multiturn`](https://gym.modal.dev/tutorials/rl/002_multiturn/) | Multi-turn number-guessing RL with custom generate and reward functions | Intermediate | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F002_multiturn%2F002_multiturn.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`003_on_policy_distillation`](https://gym.modal.dev/tutorials/rl/003_on_policy_distillation/) | Teacher-student (OPD) distillation | Intermediate | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F003_on_policy_distillation%2F003_on_policy_distillation.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`005_dapo`](https://gym.modal.dev/tutorials/rl/005_dapo/) | Large-scale RL for everyone | Advanced | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F005_dapo%2F005_dapo.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`006_audio_asr`](https://gym.modal.dev/tutorials/rl/006_audio_asr/) | Automatic Speech Recognition | Intermediate | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F006_audio_asr%2F006_audio_asr.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`007_param_sweep`](https://gym.modal.dev/tutorials/rl/007_param_sweep/) | Easy grid search | Intermediate | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F007_param_sweep%2F007_param_sweep.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`008_computer_use`](https://gym.modal.dev/tutorials/rl/008_computer_use/) | GUI grounding to predict click coordinates | Advanced | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F008_computer_use%2F008_computer_use.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n| [`009_cross_tokenizer_distillation`](https://gym.modal.dev/tutorials/rl/009_cross_tokenizer_distillation/) | Cross-tokenizer agentic distillation on BFCL v3 multi-turn | Advanced | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Frl%2F009_cross_tokenizer_distillation%2F009_cross_tokenizer_distillation.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n\n### Agents\n\n| Tutorial | Summary | Difficulty | Framework | Launch |\n|---|---|---|---|---|\n| [`000_agent_sandbox`](https://gym.modal.dev/tutorials/agent/000_agent_sandbox/) | Build an LLM agent harness with a self-hosted model and Modal Sandbox tool execution | Beginner | Modal Sandbox | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Fagent%2F000_agent_sandbox%2F000_agent_sandbox.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n\n### Multinode\n\n| Tutorial | Summary | Difficulty | Framework | Launch |\n|---|---|---|---|---|\n| [`002_glm_4_7`](https://github.com/modal-projects/training-gym/blob/main/tutorials/multinode/002_glm_4_7/002_glm_4_7.ipynb) | Multi-node full-weight training | Advanced | `slime` | <a href=\"https://modal.com/notebooks/new/https%3A%2F%2Fgithub.com%2Fmodal-projects%2Ftraining-gym%2Fblob%2Fmain%2Ftutorials%2Fmultinode%2F002_glm_4_7%2F002_glm_4_7.ipynb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://modal-cdn.com/open-in-modal.svg\" alt=\"Open in Modal\"></a> |\n<!-- END TUTORIAL TABLE -->\n\n</div>\n\n## Multi-node access\n\n:::caution[Important]\nSingle-node training is open to everyone. Multi-node clusters — required for larger models — are still in Beta. [**Contact us on Slack**](https://modal.com/slack) for access.\n:::\n"