Metadata-Version: 2.5
Name: modal-dojo
Version: 0.1.0
Summary: Reusable building blocks for Modal multi-node training examples
Project-URL: Homepage, https://github.com/modal-projects/modal-dojo
Project-URL: Documentation, https://dojo.modal.dev
Author: Modal Labs
License: MIT License
        
        Copyright (c) 2025 Modal Labs
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Requires-Dist: click<9,>=8.2
Requires-Dist: cloudpickle
Requires-Dist: datasets
Requires-Dist: fastapi
Requires-Dist: httpx
Requires-Dist: modal==1.6.1
Requires-Dist: pydantic
Requires-Dist: randomname
Requires-Dist: rich
Requires-Dist: transformers>=5.12.1
Description-Content-Type: text/markdown

# Modal Dojo

Modal Dojo is an open-source library to get started with production-grade LLM training on [Modal](https://modal.com).

To get started, you can go through the [Quickstart](#quickstart) section below, or paste the prompt below into your favorite agent:

```txt
Install the `modal-dojo` library. Then, install the skill bundle into the local project with `modal-dojo skills install`. Finally, tell the user that they can ask you to do something like: "Walk through tutorials/rl_basics.py and train Qwen3.5-4B to write 5-7-5 haikus from statworx/haiku."
```

## Quickstart

Requirements:

- Python 3.12

Install the package directly:

```bash
uv pip install modal-dojo
```

Or pin it in `pyproject.toml`:

```toml
modal-dojo = { git = "https://github.com/modal-projects/modal-dojo.git", branch = "main" }
```

Set up [Modal](https://modal.com/docs/cli/latest/setup) and the [dashboard](https://dojo.modal.dev/guides/dashboard):

```bash
modal-dojo setup
```

<div class="tg-dashboard-previews">
  <video autoplay muted loop playsinline width="100%">
    <source src="https://modal-cdn.com/cdnbot/substep1_a17bacdc.webm" type="video/webm">
    <a href="https://modal-cdn.com/cdnbot/substep1_a17bacdc.webm">Watch the Modal Dojo dashboard substep view.</a>
  </video>
  <video autoplay muted loop playsinline width="100%">
    <source src="https://modal-cdn.com/cdnbot/rollout1_15a56ce1.webm" type="video/webm">
    <a href="https://modal-cdn.com/cdnbot/rollout1_15a56ce1.webm">Watch the Modal Dojo dashboard rollout view.</a>
  </video>
</div>

And empower your agents with the Modal Dojo's skill bundle:

```bash
modal-dojo skills install
```

Then, it's as easy as:

<!-- BEGIN QUICKSTART -->
```python
import re

from modal_dojo import (
    HuggingFaceDataset,
    Qwen3_5_4B,
    Qwen3_5_4B_Recipe,
    TrainConfig,
)

model = Qwen3_5_4B()


async def gsm8k_rm(args, sample, **kwargs) -> float:
    text = model.parse_response(sample.response or "").content
    boxed = re.findall(r"\\boxed\{([^}]+)\}", text)
    pred = boxed[-1] if boxed else (re.findall(r"-?[\d,]+(?:\.\d+)?", text) or [""])[-1]
    try:
        return float(float(pred.replace(",", "")) == float(sample.label))
    except ValueError:
        return 0.0


config = TrainConfig(
    model=model,
    dataset=HuggingFaceDataset(
        hf_repo="skrishna/gsm8k_only_answer",
        hf_split="train[:120]",
        input_column="text",
        output_column="label",
        input_format="text",
    ),
    recipe=Qwen3_5_4B_Recipe(
        custom_rm_function=gsm8k_rm,
    ),
)

if __name__ == "__main__":
    run = config.launch()
    print(run.training_run_id)
```
<!-- END QUICKSTART -->

For a step-by-step walkthrough, see the [Getting started tutorial](https://dojo.modal.dev/tutorials/rl_basics).

## Supported models

<!-- BEGIN MODELS LIST -->
<!-- Auto-generated by scripts/generate_models_table.py from the recipe registries in modal_dojo/train_recipes/*/__init__.py. -->

| Family | Models |
|---|---|
| DeepSeek | <ul><li>[DeepSeek-V4.1-Flash](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash)</li></ul> |
| GLM | <ul><li>[GLM-4.7](https://huggingface.co/zai-org/GLM-4.7)</li><li>[GLM-5.3-Flash](https://huggingface.co/zai-org/GLM-5.3-Flash)</li></ul> |
| Gemma | <ul><li>[gemma-4-26B-A4B-it](https://huggingface.co/google/gemma-4-26B-A4B-it)</li></ul> |
| Inkling | <ul><li>[Inkling-Small](https://huggingface.co/thinkingmachines/Inkling-Small)</li></ul> |
| Kimi | <ul><li>[Kimi-K3](https://huggingface.co/moonshotai/Kimi-K3)</li></ul> |
| Moonlight | <ul><li>[Moonlight-16B-A3B-Instruct](https://huggingface.co/moonshotai/Moonlight-16B-A3B-Instruct)</li></ul> |
| Qwen3 | <ul><li>[Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B)</li><li>[Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B)</li><li>[Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B)</li><li>[Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B)</li><li>[Qwen3-ASR-1.7B](https://huggingface.co/Qwen/Qwen3-ASR-1.7B)</li><li>[Qwen3-VL-8B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-8B-Instruct)</li></ul> |
| Qwen3.5 | <ul><li>[Qwen3.5-0.8B](https://huggingface.co/Qwen/Qwen3.5-0.8B)</li><li>[Qwen3.5-2B](https://huggingface.co/Qwen/Qwen3.5-2B)</li><li>[Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B)</li><li>[Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B)</li></ul> |
| Qwen3.6 | <ul><li>[Qwen3.6-27B](https://huggingface.co/Qwen/Qwen3.6-27B)</li><li>[Qwen3.6-35B-A3B](https://huggingface.co/Qwen/Qwen3.6-35B-A3B)</li></ul> |
| Qwen3.8 | <ul><li>[Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B)</li></ul> |
<!-- END MODELS LIST -->
