Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ada6bd26db | ||
|
|
70149e9e49 | ||
|
|
80f9bd1a63 | ||
|
|
15dc2c6f40 | ||
|
|
db699f39ee | ||
|
|
2d7a753320 | ||
|
|
1bddcf6b11 | ||
|
|
2476f6360c | ||
|
|
15f4704092 |
@@ -53,15 +53,13 @@ With `[model] impl = "auto"` (the default), the trainer selects that custom stac
|
||||
| GLM-5 (`glm_moe_dsa`) | `zai-org/GLM-5`, `zai-org/GLM-5-FP8` | yes | ✅ | ✅ |
|
||||
| Qwen3 MoE (`qwen3_moe`) | `Qwen/Qwen3-30B-A3B`, … | yes | ✅ | ✅ |
|
||||
| Qwen3.5 MoE (`qwen3_5_moe`) | `Qwen/Qwen3.5-35B-A3B`, … | yes | ✅ | ✅ |
|
||||
| Qwen3 / Qwen3.5 VLMs | see [advanced.md](docs/advanced.md#multimodal-training) (`qwen3_vl`, `qwen3_5`, `qwen3_5_moe`) | MoE only on MoE VLMs | MoE only | ❌ |
|
||||
| Qwen3 / Qwen3.5 VLMs | see [advanced.md](docs/advanced.md#multimodal-training) (`qwen3_vl`, `qwen3_5`, `qwen3_5_moe`) | MoE only on MoE VLMs | MoE only | ✅ |
|
||||
| Poolside Laguna (`laguna`) | `poolside/Laguna-XS.2` | yes | ✅ | ✅ |
|
||||
| MiniMax M2 (`minimax_m2`) | `MiniMax/MiniMax-M2` | yes | ✅ | ✅ |
|
||||
| Nemotron H (`nemotron_h`) | `nvidia/Nemotron-3-Nano-30B-A3B`, `nvidia/Nemotron-3-Super-120B-A12B`, … | yes | ✅ | ✅ |
|
||||
| Trinity (`afmoe`) | `arcee-ai/Trinity-Mini`, … | yes | ✅ | ✅ |
|
||||
| GLM-4 · GLM-4.5 MoE · INTELLECT-3 (`glm4_moe`) | `THUDM/GLM-4-9B-0414`, `zai-org/GLM-4.5-Air`, `zai-org/GLM-4.5`, `PrimeIntellect/INTELLECT-3`, … | yes | ✅ | ✅ |
|
||||
| GPT-OSS (`gpt_oss`) | `unsloth/gpt-oss-20b-BF16`, … | yes | ✅ | ✅ |
|
||||
| Other HF causal LMs | Qwen3 dense, Mistral, … (`impl = "hf"`) | varies | ❌ | ✅ |
|
||||
|
||||
|
||||
## Setup
|
||||
|
||||
|
||||
@@ -9,5 +9,7 @@ group_size = 4
|
||||
env.taskset.id = "terminal-bench-2"
|
||||
env.agent.harness.id = "bash"
|
||||
env.agent.timeout.rollout = 3600
|
||||
env.agent.retries.max_retries = 2
|
||||
env.agent.retries.include = ["ProviderError", "SandboxError"]
|
||||
env.agent.retries.rules = [
|
||||
{type = "ProviderError", max_retries = 2},
|
||||
{type = "SandboxError", max_retries = 2},
|
||||
]
|
||||
|
||||
Vendored
+1
-1
Submodule deps/prime-envs updated: 565e8a74c0...e82de8b056
Vendored
+1
-1
Submodule deps/renderers updated: cde869941c...d43c43015a
Vendored
+1
-1
Submodule deps/verifiers updated: 5406ebcfe3...185b67da24
+21
-3
@@ -28,7 +28,7 @@ impl = "custom" # or "hf" to force the HF path
|
||||
| GLM-5 / GLM-5.2 (`glm_moe_dsa`) | `zai-org/GLM-5`, `zai-org/GLM-5-FP8`, `zai-org/GLM-5.2`, `zai-org/GLM-5.2-FP8` | ✅ | ✅ |
|
||||
| Qwen3 MoE | `Qwen/Qwen3-30B-A3B`, … | ✅ | ✅ |
|
||||
| Qwen3.5 MoE | `Qwen/Qwen3.5-35B-A3B`, … | ✅ | ✅ |
|
||||
| Qwen3 / Qwen3.5 VLMs | see [Multimodal training](#multimodal-training) | MoE only | ❌ |
|
||||
| Qwen3 / Qwen3.5 VLMs | see [Multimodal training](#multimodal-training) | MoE only | ✅ |
|
||||
| Laguna | `poolside/Laguna-XS.2` | ✅ | ✅ |
|
||||
| MiniMax M2 | `MiniMax/MiniMax-M2` | ✅ | ✅ |
|
||||
| Nemotron H | `nvidia/Nemotron-3-Nano-30B-A3B`, … | ✅ | ❌ |
|
||||
@@ -49,12 +49,30 @@ Dense linear precision and routed-expert precision are configured independently.
|
||||
- `type = "fp8"` — DeepGEMM FP8 blockwise linears (requires SM90+).
|
||||
- `type = "mxfp8"` — torchao MXFP8 linears (requires SM100). `recipe` is `mxfp8_rceil` or `mxfp8_rceil_wgrad_with_hp`.
|
||||
|
||||
`[trainer.model.moe.compute]` selects routed-expert grouped GEMMs independently:
|
||||
`[trainer.model.moe.compute]` selects routed-expert compute independently:
|
||||
|
||||
- `type = "bf16"` (default)
|
||||
- `type = "bf16"` (default), with `backend = "torch"` (default) or `"sonicmoe"`.
|
||||
- `type = "deepgemm_fp8"` (requires DeepGEMM and SM90+)
|
||||
- `type = "mxfp8"` (requires `prime-kernels`, torchao, and SM100)
|
||||
|
||||
SonicMoE uses the upstream `sonic-moe` package (`uv sync --extra sonic-moe`) for fused BF16 expert computation. The supported model is Qwen3 MoE with the `gate_up` model fusion enabled. Backend selection requires fused gate/up weights, standard SwiGLU, and bias-free experts; incompatible expert structures raise an error during setup. It uses the same router and local, torch EP, or DeepEP dispatch as other compute backends:
|
||||
|
||||
```toml
|
||||
[trainer.model]
|
||||
name = "Qwen/Qwen3-30B-A3B"
|
||||
ep = 2
|
||||
|
||||
[trainer.model.fusions]
|
||||
enabled = ["gate_up"]
|
||||
|
||||
[trainer.model.moe.compute]
|
||||
type = "bf16"
|
||||
backend = "sonicmoe"
|
||||
|
||||
[trainer.model.moe.dispatch]
|
||||
type = "torch"
|
||||
```
|
||||
|
||||
```toml
|
||||
[trainer.model.quantization]
|
||||
type = "mxfp8"
|
||||
|
||||
@@ -549,6 +549,8 @@ Hand-coded renderers ship for `qwen3`, `qwen3-vl`, `qwen3.5`, `glm-5`, `glm-4.5`
|
||||
name = "auto" # detect from tokenizer; pass an explicit name for fine-tunes
|
||||
```
|
||||
|
||||
A renderer outside the `renderers` package loads as a custom renderer: `name = "custom"` with `import_path = "my_module.Class"` (or `path/to/file.py:Class`), see [Custom renderers](training.md#dataset-format).
|
||||
|
||||
For the full design rationale (failure modes ruled out, empirical token-identity comparison against `apply_chat_template`, when to write a hand-coded renderer), see [the renderers writeup on the Prime Intellect blog](https://www.primeintellect.ai/blog/renderers) — the canonical reference.
|
||||
|
||||
### Discontinuous Trajectories
|
||||
|
||||
@@ -185,8 +185,10 @@ env.taskset.id = "math"
|
||||
group_size = 32 # this source's own value wins over the group's 16
|
||||
|
||||
[orchestrator.eval.env]
|
||||
retries.max_retries = 3
|
||||
retries.include = ["ProviderError", "SandboxError"]
|
||||
retries.rules = [
|
||||
{type = "ProviderError", max_retries = 3},
|
||||
{type = "SandboxError", max_retries = 3},
|
||||
]
|
||||
timeout.episode = 7200
|
||||
|
||||
[orchestrator.eval.select] # evaluate 128 tasks of each taskset
|
||||
|
||||
+26
-3
@@ -150,9 +150,15 @@ Two accepted layouts:
|
||||
- **Prompt-completion**: a HF dataset with `prompt` and `completion` columns ([TRL format](https://huggingface.co/docs/trl/en/dataset_formats#prompt-completion)). The trainer masks out the prompt and computes loss only over the completion.
|
||||
- **Messages**: a HF dataset with a single `messages` column containing a list of chat turns. The trainer interprets the whole conversation as one sample, applies role-based loss masking, and trains over all assistant turns.
|
||||
|
||||
If both columns are present, `messages` takes precedence.
|
||||
If both columns are present, `messages` takes precedence. A dataset that stores these under other names maps them in `[data.columns]`; the trainer renames the columns at load time:
|
||||
|
||||
**Tool definitions and renderer controls.** For tool-use SFT, add a `tools` column (OpenAI function-calling format) or `tool_defs` ([`verifiers`](https://github.com/PrimeIntellect-ai/verifiers) rollout format). Each row's value can be either a list of dicts or a JSON-encoded string of a list — both are accepted, and `tool_defs` rows are auto-converted to OAI shape before being passed into the renderer.
|
||||
```toml
|
||||
[data.columns]
|
||||
messages = "conversation"
|
||||
tools = "schemas"
|
||||
```
|
||||
|
||||
**Tool definitions and renderer controls.** For tool-use SFT, add a `tools` column in OpenAI function-calling format. Each row's value can be either a list of dicts or a JSON-encoded string of a list.
|
||||
|
||||
Renderer-backed SFT reads template controls from the typed `[renderer]` config in the SFT TOML. For example:
|
||||
|
||||
@@ -162,10 +168,27 @@ name = "qwen3"
|
||||
enable_thinking = false
|
||||
```
|
||||
|
||||
A `reasoning_effort` column in the dataset sets the renderer's `reasoning_effort` field per row, on top of the `[renderer]` config. The column requires a typed renderer that has that field (for example `gpt-oss`, `qwen3.8`, `deepseek-v4`); rows with a null value use the configured renderer unchanged. This lets one run mix reasoning efforts, with the `[renderer]` value as the default for rows that do not set one.
|
||||
Dataset columns can set renderer template controls per row, on top of the `[renderer]` config. `[data.columns.renderer]` maps renderer fields to columns and defaults to `reasoning_effort = "reasoning_effort"`, so a `reasoning_effort` column sets that field on renderers that have it (for example `gpt-oss`, `qwen3.8`, `deepseek-v4`). Rows with a null value use the configured renderer unchanged. This lets one run mix reasoning efforts, with the `[renderer]` value as the default for rows that do not set one:
|
||||
|
||||
```toml
|
||||
# The renderer field is reasoning_effort; this dataset stores it in an effort column.
|
||||
[data.columns.renderer]
|
||||
reasoning_effort = "effort"
|
||||
```
|
||||
|
||||
If a model needs another template control, add it to that model's renderer config in `renderers` (for example a new field on the relevant `*RendererConfig`) and consume it in the renderer implementation.
|
||||
|
||||
**Custom renderers.** A renderer can also live outside the `renderers` package. Set `name = "custom"` and point `import_path` at the class, as `my_module.Class` or `path/to/file.py:Class`; relative file paths resolve against the launch directory. The class sets `config_class` to its own `BaseRendererConfig` subclass, which validates the remaining `[renderer]` keys and declares its template controls:
|
||||
|
||||
```toml
|
||||
[renderer]
|
||||
name = "custom"
|
||||
import_path = "my_renderers.glm53_no_thinking.NoThinkingGLM53Renderer"
|
||||
clear_thinking = true
|
||||
```
|
||||
|
||||
The same config selects the renderer for RL under `[orchestrator.renderer]`. The [`renderers` README](https://github.com/PrimeIntellect-ai/renderers#custom-renderers) shows the class behind this example.
|
||||
|
||||
**Renderer-backed tokenization.** SFT tokenization is renderer-only. The [`renderers`](algorithms.md#renderers) package owns message-to-token conversion and loss attribution end-to-end, so position-dependent chat templates (for example templates that strip past `<think>` blocks across user turns) do not corrupt the loss mask. `[renderer]` defaults to `name = "auto"`; set a typed renderer config only when you need model-specific template controls. Hand-coded renderers ship for Qwen3, Qwen3.5, GLM-5, GLM-4.5, Kimi K2/K2.5, MiniMax M2, DeepSeek V3, Nemotron 3, GPT-OSS, and VLM families such as Qwen3-VL/Qwen3.5.
|
||||
|
||||
**VLM training requires a custom PrimeRL implementation.** Training a model with `[model.vlm]` set (SFT or RL) requires `model.impl = "custom"` and only works for models with a registered PrimeRL VLM class (currently Qwen3.5 dense and MoE).
|
||||
|
||||
@@ -24,6 +24,9 @@ decode_nodes_per_replica = 8
|
||||
num_decode_replicas = 1
|
||||
|
||||
[deployment.prefill_env_vars]
|
||||
# vLLM >= 0.29 auto-enables breakable CUDA graphs for GLM-5 (GlmMoeDsaForCausalLM); capturing
|
||||
# the DeepEP high-throughput prefill dispatch then fails ("DeepEP error: timeout (dispatch CPU)").
|
||||
"VLLM_USE_BREAKABLE_CUDAGRAPH" = "0"
|
||||
"VLLM_ENABLE_MOE_DP_CHUNK" = "0"
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
@@ -6,6 +6,11 @@ prefill_nodes_per_replica = 4
|
||||
decode_nodes_per_replica = 2
|
||||
gpus_per_node = 8
|
||||
|
||||
[deployment.prefill_env_vars]
|
||||
# vLLM >= 0.29 auto-enables breakable CUDA graphs for GLM-5 (GlmMoeDsaForCausalLM); capturing
|
||||
# the DeepEP high-throughput prefill dispatch then fails ("DeepEP error: timeout (dispatch CPU)").
|
||||
"VLLM_USE_BREAKABLE_CUDAGRAPH" = "0"
|
||||
|
||||
[slurm]
|
||||
job_name = "glm5"
|
||||
partition = "cluster"
|
||||
|
||||
@@ -41,6 +41,9 @@ num_decode_replicas = 1
|
||||
# skip warmup for faster start in cost of some jit overhead early
|
||||
# ucx needs to be set else random segfaults, vllm can't autoset before importing for some reason
|
||||
[inference.deployment.prefill_env_vars]
|
||||
# vLLM >= 0.29 auto-enables breakable CUDA graphs for GLM-5 (GlmMoeDsaForCausalLM); capturing
|
||||
# the DeepEP high-throughput prefill dispatch then fails ("DeepEP error: timeout (dispatch CPU)").
|
||||
"VLLM_USE_BREAKABLE_CUDAGRAPH" = "0"
|
||||
"VLLM_ENABLE_MOE_DP_CHUNK" = "0"
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
@@ -7,6 +7,7 @@ RL on the 30B-A3B MoE across three domains: math, SWE, and agentic tool use. The
|
||||
| [`math.toml`](math.toml) | `i3_math` | `aime2025` (every 25 steps) | `subprocess` — runs locally, no sandbox | 2 train + 2 infer nodes |
|
||||
| [`swe.toml`](swe.toml) | `r2e-gym` (`bash` harness) | `swebench-verified` (every 25 steps) | sandbox (Prime Intellect by default) | 2 train + 2 infer nodes |
|
||||
| [`tool.toml`](tool.toml) | `general-agent` (colocated tools) | — | `modal` | 1 train + 1 infer node |
|
||||
| [`sft/h200/`](sft/h200) | SFT on `PrimeIntellect/INTELLECT-3-SFT-10K` (math) | — | — | 2 train nodes |
|
||||
|
||||
`tool.toml` is the odd one out: 400 steps, `group_size = 16`, checkpoints every 50 steps with `keep_last = 1`, and inference at `dp = 2` / `tp = 4`. `math.toml` and `swe.toml` run 512-task batches with checkpoints every 100 steps.
|
||||
|
||||
@@ -105,3 +106,20 @@ uv run python tools/convert_dcp_to_bf16.py /shared/outputs/qwen30b/qwen30b-math/
|
||||
```
|
||||
|
||||
See [Training](../../../docs/training.md) for the full knobs and metrics reference, and [Scaling](../../../docs/scaling.md) for SLURM and multi-node details.
|
||||
|
||||
## SFT
|
||||
|
||||
The SFT configs live under [`sft/h200/`](sft/h200). They are tuned for two 8-GPU H200 nodes and train only (no inference nodes). Combine the base config with a data overlay:
|
||||
|
||||
```bash
|
||||
uv run sft @ examples/advanced/qwen3-30b-a3b/sft/h200/base.toml @ examples/advanced/qwen3-30b-a3b/sft/h200/math-10k.toml \
|
||||
--output-dir /shared/outputs/qwen30b \
|
||||
--run.name qwen30b-sft-math
|
||||
```
|
||||
|
||||
This starts an SFT run with the following setup:
|
||||
|
||||
- The model is `Qwen/Qwen3-30B-A3B-Instruct-2507`, trained with the custom MoE implementation, expert parallelism (`ep = 8`), full activation checkpointing with offloading, and AdamW.
|
||||
- The data is `PrimeIntellect/INTELLECT-3-SFT-10K` (math split), at a 32k sequence length with a batch of 16 samples per step.
|
||||
|
||||
For a fake-data dry run, add [`fake.toml`](sft/h200/fake.toml) instead of the data overlay. `base.toml` sets `[slurm] partition = "all"` and `HF_HOME = "/home/huggingface"`. Change both to match your cluster. For longer contexts, raise `data.seq_len` and set `model.cp` to split each sequence across GPUs. You can monitor the SFT run with the same dashboard.
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
clean = true
|
||||
|
||||
[env_vars]
|
||||
HF_HOME = "/home/huggingface"
|
||||
TRITON_CACHE_DIR = "/tmp/.cache/triton_cache"
|
||||
|
||||
[model]
|
||||
name = "Qwen/Qwen3-30B-A3B-Instruct-2507"
|
||||
impl = "custom"
|
||||
attn = "flash_attention_3"
|
||||
ep = 8
|
||||
|
||||
[model.ac]
|
||||
freq = 1
|
||||
|
||||
[model.ac_offloading]
|
||||
max_inflight_activations = 5
|
||||
|
||||
[optim]
|
||||
type = "adamw"
|
||||
lr = 1e-5
|
||||
weight_decay = 0.01
|
||||
|
||||
[scheduler]
|
||||
type = "linear"
|
||||
warmup_steps = 50
|
||||
decay_steps = 0
|
||||
|
||||
[deployment]
|
||||
type = "multi_node"
|
||||
num_train_nodes = 2
|
||||
|
||||
[slurm]
|
||||
job_name = "qwen30b-sft"
|
||||
partition = "all"
|
||||
@@ -0,0 +1,8 @@
|
||||
[model.debug]
|
||||
force_balanced_routing = true
|
||||
|
||||
[data]
|
||||
type = "fake"
|
||||
batch_size = 16
|
||||
micro_batch_size = 1
|
||||
seq_len = 32768
|
||||
@@ -0,0 +1,7 @@
|
||||
[data]
|
||||
type = "sft"
|
||||
name = "PrimeIntellect/INTELLECT-3-SFT-10K"
|
||||
splits = ["math"]
|
||||
batch_size = 16
|
||||
micro_batch_size = 1
|
||||
seq_len = 32768
|
||||
@@ -85,6 +85,25 @@ class LossMaskConfig(BaseConfig):
|
||||
"""Tool messages contribute to the loss."""
|
||||
|
||||
|
||||
class SFTColumnsConfig(BaseConfig):
|
||||
"""Dataset columns the trainer reads. Set a field to read a column under another name."""
|
||||
|
||||
messages: str = "messages"
|
||||
"""Column with the whole chat as a list of OpenAI chat messages."""
|
||||
|
||||
prompt: str = "prompt"
|
||||
"""Column with the prompt as a list of OpenAI chat messages, read with ``completion`` when a row has no messages."""
|
||||
|
||||
completion: str = "completion"
|
||||
"""Column with the completion as a list of OpenAI chat messages."""
|
||||
|
||||
tools: str = "tools"
|
||||
"""Column with the tool schemas in OpenAI function-calling format."""
|
||||
|
||||
renderer: dict[str, str] = {"reasoning_effort": "reasoning_effort"}
|
||||
"""Per-sample renderer arguments as ``renderer field = dataset column``, e.g. ``reasoning_effort = "effort"``. A row's non-null value overrides the ``[renderer]`` setting; rows and datasets without the column use it unchanged."""
|
||||
|
||||
|
||||
class SFTDataConfig(BaseDataConfig):
|
||||
type: Literal["sft"] = "sft"
|
||||
|
||||
@@ -112,6 +131,9 @@ class SFTDataConfig(BaseDataConfig):
|
||||
seed: int = 0
|
||||
"""Random seed for shuffling. Re-shuffled per epoch by adding the epoch count to the seed."""
|
||||
|
||||
columns: SFTColumnsConfig = SFTColumnsConfig()
|
||||
"""Columns that carry per-sample renderer arguments."""
|
||||
|
||||
# Configuring
|
||||
loss_mask: LossMaskConfig = LossMaskConfig()
|
||||
"""Which message types contribute to the loss."""
|
||||
|
||||
@@ -212,9 +212,11 @@ class MoEComputeConfigBase(BaseConfig):
|
||||
|
||||
|
||||
class BF16MoEComputeConfig(MoEComputeConfigBase):
|
||||
"""Run routed-expert grouped GEMMs in bfloat16."""
|
||||
"""Run routed experts in bfloat16."""
|
||||
|
||||
type: Literal["bf16"] = "bf16"
|
||||
backend: Literal["torch", "sonicmoe"] = "torch"
|
||||
"""Expert compute implementation."""
|
||||
|
||||
|
||||
class DeepGemmFP8MoEComputeConfig(MoEComputeConfigBase):
|
||||
|
||||
@@ -97,6 +97,7 @@ disagg = [
|
||||
quack = [
|
||||
"quack-kernels>=0.4.1 ; sys_platform == 'linux'",
|
||||
]
|
||||
sonic-moe = ["sonic-moe ; sys_platform == 'linux'"]
|
||||
# Prebuilt `prime-kernels` wheels from a release (see the `kernels` skill). Compiled for
|
||||
# sm_100a; on other GPUs the package installs fine and reports its kernels unavailable.
|
||||
kernels = [
|
||||
@@ -107,6 +108,7 @@ all = [
|
||||
"prime-rl[flash-attn]",
|
||||
"prime-rl[disagg]",
|
||||
"prime-rl[quack]",
|
||||
"prime-rl[sonic-moe]",
|
||||
"prime-rl[flash-attn-3]",
|
||||
"prime-rl[flash-attn-cute]",
|
||||
]
|
||||
@@ -268,6 +270,8 @@ torchao = [
|
||||
{ url = "https://github.com/PrimeIntellect-ai/prime-kernels/releases/download/v0.1.1/torchao-0.18.0+git5f2baf9d5-cp310-abi3-linux_aarch64.whl", marker = "platform_machine == 'aarch64'" },
|
||||
]
|
||||
dion = { git = "https://github.com/samsja/dion.git", rev = "6f9242d" }
|
||||
sonic-moe = { git = "https://github.com/S1ro1/sonic-moe", rev = "0bf06ac" }
|
||||
quack-kernels = { git = "https://github.com/S1ro1/quack", rev = "f62009f" }
|
||||
flash-attn-4 = { git = "https://github.com/Dao-AILab/flash-attention.git", subdirectory = "flash_attn/cute", rev = "0251105" }
|
||||
vllm-router = [
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.2/vllm_router-0.2.2-cp38-abi3-manylinux_2_28_x86_64.whl", marker = "platform_machine == 'x86_64'" },
|
||||
|
||||
@@ -1015,8 +1015,15 @@ def timeline_lane(
|
||||
starts = [span["started_at"] for span in spans if span.get("started_at") is not None]
|
||||
ends = [span["ended_at"] for span in spans if span.get("ended_at") is not None]
|
||||
started = started_at if started_at is not None else min(starts or ends, default=None)
|
||||
terminal = next(
|
||||
(span["status"] for span in lifecycle if span["status"] in {"cancelled", "failed", "timeout"}),
|
||||
None,
|
||||
)
|
||||
status = (
|
||||
("completed" if all(span["status"] == "completed" for span in lifecycle + activities) else "running")
|
||||
(
|
||||
terminal
|
||||
or ("completed" if all(span["status"] == "completed" for span in lifecycle + activities) else "running")
|
||||
)
|
||||
if branch
|
||||
else timeline_status(trace)
|
||||
)
|
||||
@@ -1207,6 +1214,13 @@ def semantic_context_lanes(
|
||||
|
||||
ordered_components = sorted(components, key=lambda component: (component_start(component), component))
|
||||
cross_edges = [edge for edge in edges if component_for[edge["source_node"]] != component_for[edge["target_node"]]]
|
||||
# subagent_failed (child -> parent) marks its source; subagent_cancel (parent -> child) its target.
|
||||
context_outcome = {}
|
||||
for edge in cross_edges:
|
||||
if edge["type"] == "subagent_failed":
|
||||
context_outcome[component_for[edge["source_node"]]] = "failed"
|
||||
elif edge["type"] == "subagent_cancel":
|
||||
context_outcome[component_for[edge["target_node"]]] = "cancelled"
|
||||
created_components = {
|
||||
component_for[edge["target_node"]]
|
||||
for edge in cross_edges
|
||||
@@ -1276,6 +1290,10 @@ def semantic_context_lanes(
|
||||
default=None,
|
||||
)
|
||||
completed = bool(trace.get("is_completed"))
|
||||
# A cancelled/failed context is done even if the trace as a whole is not.
|
||||
outcome = context_outcome.get(component)
|
||||
status = outcome or ("completed" if completed else "running")
|
||||
ended_at = end if (outcome is not None or completed) else None
|
||||
label = f"{agent_label} · context {context_index}"
|
||||
lifecycle = (
|
||||
[
|
||||
@@ -1284,8 +1302,8 @@ def semantic_context_lanes(
|
||||
"label": label,
|
||||
"track": "lifecycle",
|
||||
"started_at": start,
|
||||
"ended_at": end if completed else None,
|
||||
"status": "completed" if completed else "running",
|
||||
"ended_at": ended_at,
|
||||
"status": status,
|
||||
}
|
||||
]
|
||||
if start != float("inf")
|
||||
@@ -1304,6 +1322,8 @@ def semantic_context_lanes(
|
||||
"agent": agent_label,
|
||||
"index": context_index,
|
||||
}
|
||||
if outcome is not None:
|
||||
lane["context"]["outcome"] = outcome
|
||||
if component in unlinked_components:
|
||||
lane["context"]["unlinked"] = True
|
||||
if component in attempt_by_component:
|
||||
|
||||
@@ -4769,6 +4769,8 @@ function semanticEdgeKind(type) {
|
||||
if (type === "continuation") return "continuation";
|
||||
if (type === "subagent_call") return "subagent-call";
|
||||
if (type === "subagent_return") return "subagent-return";
|
||||
if (type === "subagent_cancel") return "subagent-cancel";
|
||||
if (type === "subagent_failed") return "subagent-failed";
|
||||
if (type === "compaction_attempt") return "compaction-attempt";
|
||||
if (type === "compaction") return "compaction";
|
||||
return "custom";
|
||||
@@ -5266,6 +5268,8 @@ function renderSemanticGraph() {
|
||||
continuation: "#767676",
|
||||
"subagent-call": "#4a9eff",
|
||||
"subagent-return": "#ff6b4a",
|
||||
"subagent-cancel": "#ff4539",
|
||||
"subagent-failed": "#ff4539",
|
||||
"compaction-attempt": "#b7a6fa",
|
||||
compaction: "#b7a6fa",
|
||||
custom: "#b6ff3c",
|
||||
|
||||
@@ -923,6 +923,8 @@ mark.hit {
|
||||
}
|
||||
.tl-edge-key i.subagent-call { border-color: var(--infra); }
|
||||
.tl-edge-key i.subagent-return { border-color: var(--risk); }
|
||||
.tl-edge-key i.subagent-cancel { border-color: var(--negative); border-top-style: dashed; }
|
||||
.tl-edge-key i.subagent-failed { border-color: var(--negative); }
|
||||
.tl-edge-key i.compaction-attempt { border-color: var(--chart-2); border-top-style: dotted; }
|
||||
.tl-edge-key i.compaction { border-color: var(--chart-2); border-top-style: dashed; }
|
||||
.tl-edge-key i.custom { border-color: var(--accent); border-top-style: dotted; }
|
||||
@@ -973,6 +975,7 @@ mark.hit {
|
||||
.tl-state { border: 1px solid var(--grey-3); padding: 1px 5px; white-space: nowrap; }
|
||||
.tl-state.completed { color: var(--positive); }
|
||||
.tl-state.failed { color: var(--negative); }
|
||||
.tl-state.cancelled { color: var(--negative); }
|
||||
.tl-state.timeout { color: var(--timeout); }
|
||||
.tl-state.running { color: var(--infra); }
|
||||
.tl-tooltip {
|
||||
@@ -1044,6 +1047,8 @@ mark.hit {
|
||||
.sg-edge.continuation { opacity: 0.34; }
|
||||
.sg-edge.subagent-call { stroke: var(--infra); stroke-width: 2.2; opacity: 0.9; }
|
||||
.sg-edge.subagent-return { stroke: var(--risk); stroke-width: 2.2; opacity: 0.9; }
|
||||
.sg-edge.subagent-cancel { stroke: var(--negative); stroke-width: 2.2; opacity: 0.9; stroke-dasharray: 5 3; }
|
||||
.sg-edge.subagent-failed { stroke: var(--negative); stroke-width: 2.2; opacity: 0.9; }
|
||||
.sg-edge.compaction-attempt { stroke: var(--chart-2); stroke-dasharray: 2 4; opacity: 0.66; }
|
||||
.sg-edge.compaction { stroke: var(--chart-2); stroke-dasharray: 5 4; opacity: 0.9; }
|
||||
.sg-edge.custom { stroke: var(--accent); stroke-dasharray: 2 4; opacity: 0.9; }
|
||||
|
||||
@@ -252,6 +252,9 @@ srun --kill-on-bad-exit=1 bash -s <<'LAUNCH_SH'
|
||||
PORT=$PREFILL_PORT
|
||||
HEAD_HOST="${HOSTNAMES[$((REPLICA_BASE + SUB_REPLICA * NODES_PER_PREFILL_REPLICA))]}"
|
||||
|
||||
# vLLM >= 0.29 auto-enables breakable CUDA graphs; capturing the DeepEP
|
||||
# high-throughput internode dispatch then fails ("timeout (dispatch CPU)").
|
||||
export VLLM_USE_BREAKABLE_CUDAGRAPH=0
|
||||
{% for key, value in prefill_env_vars.items() %}
|
||||
export {{ key }}="{{ value }}"
|
||||
{% endfor %}
|
||||
|
||||
@@ -396,6 +396,9 @@ if [ "$SLURM_PROCID" -lt "$NUM_INFER_NODES" ]; then
|
||||
PORT=$PREFILL_PORT
|
||||
START_RANK=$((ROLE_RANK * INFERENCE_DP_LOCAL))
|
||||
HEAD_HOST="${HOSTNAMES[$((REPLICA_BASE + SUB_REPLICA * NODES_PER_PREFILL_REPLICA))]}"
|
||||
# vLLM >= 0.29 auto-enables breakable CUDA graphs; capturing the DeepEP
|
||||
# high-throughput internode dispatch then fails ("timeout (dispatch CPU)").
|
||||
export VLLM_USE_BREAKABLE_CUDAGRAPH=0
|
||||
{% for key, value in prefill_env_vars.items() %}
|
||||
export {{ key }}="{{ value }}"
|
||||
{% endfor %}
|
||||
|
||||
@@ -69,6 +69,9 @@ DEFAULT_SELECTIVE_SAVE_OPERATIONS = frozenset(
|
||||
"prime_rl::fp8_blockwise_mm",
|
||||
"prime_rl::grouped_fp8_gemm",
|
||||
"prime_rl::sparse_mla",
|
||||
"quack::gemm_act_out",
|
||||
"quack::gemm_gated_out",
|
||||
"quack::gemm_out",
|
||||
}
|
||||
)
|
||||
# An operation target matches one qualified operator name, while a namespace
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the BSD-style license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
from collections.abc import Callable
|
||||
from functools import partial
|
||||
from types import ModuleType
|
||||
from typing import TYPE_CHECKING, Protocol
|
||||
|
||||
import torch
|
||||
from torch.distributed.tensor import DTensor
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from prime_rl.trainer.models.layers.moe import GroupedExperts
|
||||
|
||||
|
||||
class ExpertCompute(Protocol):
|
||||
token_group_alignment: int
|
||||
|
||||
def validate(self, experts: "GroupedExperts") -> None: ...
|
||||
|
||||
def __call__(
|
||||
self, experts: "GroupedExperts", x: torch.Tensor, num_tokens_per_expert: torch.Tensor
|
||||
) -> torch.Tensor: ...
|
||||
|
||||
|
||||
def broadcast_expert_bias(
|
||||
bias: torch.Tensor,
|
||||
num_tokens_per_expert: torch.Tensor,
|
||||
target_rows: int,
|
||||
) -> torch.Tensor:
|
||||
repeats = num_tokens_per_expert.to(torch.int64)
|
||||
padding_rows = repeats.new_tensor(target_rows) - repeats.sum()
|
||||
return torch.repeat_interleave(
|
||||
torch.cat((bias, bias.new_zeros((1, bias.shape[1])))),
|
||||
torch.cat((repeats, padding_rows.unsqueeze(0))),
|
||||
dim=0,
|
||||
output_size=target_rows,
|
||||
)
|
||||
|
||||
|
||||
class GroupedGemmExpertCompute:
|
||||
def __init__(
|
||||
self,
|
||||
gemm: Callable[[torch.Tensor, torch.Tensor, torch.Tensor], torch.Tensor],
|
||||
token_group_alignment: int = 8,
|
||||
) -> None:
|
||||
self.gemm = gemm
|
||||
self.token_group_alignment = token_group_alignment
|
||||
|
||||
def validate(self, experts: "GroupedExperts") -> None:
|
||||
"""The shared forward handles the experts' activation, biases, and weight layout."""
|
||||
|
||||
def __call__(self, experts: "GroupedExperts", x: torch.Tensor, num_tokens_per_expert: torch.Tensor) -> torch.Tensor:
|
||||
assert x.dim() == 2
|
||||
|
||||
def to_local(tensor: torch.Tensor) -> torch.Tensor:
|
||||
return tensor.to_local() if isinstance(tensor, DTensor) else tensor
|
||||
|
||||
offsets = torch.cumsum(num_tokens_per_expert, dim=0, dtype=torch.int32)
|
||||
x_bf16 = x.bfloat16()
|
||||
|
||||
if experts.gate_up_proj is None:
|
||||
up_proj = to_local(experts.up_proj).transpose(-2, -1)
|
||||
up = self.gemm(x_bf16, up_proj.bfloat16(), offsets)
|
||||
|
||||
gate = None
|
||||
if experts.gate_proj is not None:
|
||||
gate_proj = to_local(experts.gate_proj).transpose(-2, -1)
|
||||
gate = self.gemm(x_bf16, gate_proj.bfloat16(), offsets)
|
||||
else:
|
||||
gate_up_proj = to_local(experts.gate_up_proj).transpose(-2, -1)
|
||||
gate_up = self.gemm(x_bf16, gate_up_proj.bfloat16(), offsets)
|
||||
gate, up = gate_up.chunk(2, dim=-1)
|
||||
|
||||
if experts.up_proj_bias is not None:
|
||||
up_proj_bias = to_local(experts.up_proj_bias)
|
||||
up = up + broadcast_expert_bias(up_proj_bias, num_tokens_per_expert, up.shape[0]).bfloat16()
|
||||
|
||||
if gate is not None and experts.gate_proj_bias is not None:
|
||||
gate_proj_bias = to_local(experts.gate_proj_bias)
|
||||
gate = gate + broadcast_expert_bias(gate_proj_bias, num_tokens_per_expert, gate.shape[0]).bfloat16()
|
||||
|
||||
hidden = experts.activation.apply(gate, up)
|
||||
down_proj = to_local(experts.down_proj).transpose(-2, -1)
|
||||
output = self.gemm(hidden, down_proj.bfloat16(), offsets)
|
||||
if experts.down_proj_bias is not None:
|
||||
down_proj_bias = to_local(experts.down_proj_bias)
|
||||
output = output + broadcast_expert_bias(down_proj_bias, num_tokens_per_expert, output.shape[0]).bfloat16()
|
||||
return output.type_as(x)
|
||||
|
||||
|
||||
class BF16ExpertCompute(GroupedGemmExpertCompute):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(torch._grouped_mm)
|
||||
|
||||
|
||||
class DeepGemmFP8ExpertCompute(GroupedGemmExpertCompute):
|
||||
def __init__(self) -> None:
|
||||
from prime_rl.trainer.models.layers.fp8_grouped_gemm import grouped_fp8_gemm
|
||||
|
||||
super().__init__(grouped_fp8_gemm)
|
||||
|
||||
|
||||
class MXFP8ExpertCompute(GroupedGemmExpertCompute):
|
||||
def __init__(self, kernel: ModuleType, high_precision_wgrad: bool) -> None:
|
||||
super().__init__(
|
||||
partial(kernel.grouped_gemm, high_precision_wgrad=high_precision_wgrad),
|
||||
token_group_alignment=kernel.TOKEN_GROUP_ALIGNMENT,
|
||||
)
|
||||
@@ -1,68 +0,0 @@
|
||||
from dataclasses import dataclass
|
||||
from types import ModuleType
|
||||
from typing import Protocol
|
||||
|
||||
import torch
|
||||
|
||||
|
||||
class GroupedGemm(Protocol):
|
||||
token_group_alignment: int
|
||||
|
||||
def __call__(
|
||||
self,
|
||||
x: torch.Tensor,
|
||||
weight_t: torch.Tensor,
|
||||
*,
|
||||
offs: torch.Tensor,
|
||||
) -> torch.Tensor: ...
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BF16GroupedGemm:
|
||||
token_group_alignment: int = 8
|
||||
|
||||
def __call__(
|
||||
self,
|
||||
x: torch.Tensor,
|
||||
weight_t: torch.Tensor,
|
||||
*,
|
||||
offs: torch.Tensor,
|
||||
) -> torch.Tensor:
|
||||
return torch._grouped_mm(x, weight_t, offs=offs)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class DeepGemmFP8GroupedGemm:
|
||||
token_group_alignment: int = 8
|
||||
|
||||
def __call__(
|
||||
self,
|
||||
x: torch.Tensor,
|
||||
weight_t: torch.Tensor,
|
||||
*,
|
||||
offs: torch.Tensor,
|
||||
) -> torch.Tensor:
|
||||
from prime_rl.trainer.models.layers.fp8_grouped_gemm import grouped_fp8_gemm
|
||||
|
||||
return grouped_fp8_gemm(x, weight_t, offs)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MXFP8GroupedGemm:
|
||||
kernel: ModuleType
|
||||
high_precision_wgrad: bool
|
||||
token_group_alignment: int
|
||||
|
||||
def __call__(
|
||||
self,
|
||||
x: torch.Tensor,
|
||||
weight_t: torch.Tensor,
|
||||
*,
|
||||
offs: torch.Tensor,
|
||||
) -> torch.Tensor:
|
||||
return self.kernel.grouped_gemm(
|
||||
x,
|
||||
weight_t,
|
||||
offs,
|
||||
high_precision_wgrad=self.high_precision_wgrad,
|
||||
)
|
||||
@@ -5,11 +5,9 @@ from torch import nn
|
||||
from torch.distributed.tensor import DTensor
|
||||
|
||||
from prime_rl.trainer.models.layers.activations import ClampedSwiglu
|
||||
from prime_rl.trainer.models.layers.expert_compute import broadcast_expert_bias
|
||||
from prime_rl.trainer.models.layers.lora.base import MultiLoRAModule, get_lora_num_tokens, get_multilora_scaling
|
||||
from prime_rl.trainer.models.layers.moe import (
|
||||
GroupedExperts,
|
||||
broadcast_expert_bias,
|
||||
)
|
||||
from prime_rl.trainer.models.layers.moe import GroupedExperts
|
||||
|
||||
|
||||
def _run_lora_grouped_mm(
|
||||
|
||||
@@ -10,12 +10,11 @@ from typing import Literal
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
from torch import nn
|
||||
from torch.distributed.tensor import DTensor
|
||||
|
||||
from prime_rl.trainer.distributed.token_dispatcher import LocalTokenDispatcher, TokenDispatcher
|
||||
from prime_rl.trainer.models.fusions import fuse_gate_up_projections
|
||||
from prime_rl.trainer.models.layers.activations import ActivationDispatch, ActivationType
|
||||
from prime_rl.trainer.models.layers.grouped_gemm import BF16GroupedGemm, GroupedGemm
|
||||
from prime_rl.trainer.models.layers.expert_compute import BF16ExpertCompute, ExpertCompute
|
||||
from prime_rl.trainer.models.layers.mlp import ExpertType, FeedForward
|
||||
|
||||
ScoreFuncType = Literal["softmax", "sigmoid", "topk_softmax"]
|
||||
@@ -67,21 +66,6 @@ class MoEArgs:
|
||||
ActivationDispatch[self.activation]
|
||||
|
||||
|
||||
def broadcast_expert_bias(
|
||||
bias: torch.Tensor,
|
||||
num_tokens_per_expert: torch.Tensor,
|
||||
target_rows: int,
|
||||
) -> torch.Tensor:
|
||||
repeats = num_tokens_per_expert.to(torch.int64)
|
||||
padding_rows = repeats.new_tensor(target_rows) - repeats.sum()
|
||||
return torch.repeat_interleave(
|
||||
torch.cat((bias, bias.new_zeros((1, bias.shape[1])))),
|
||||
torch.cat((repeats, padding_rows.unsqueeze(0))),
|
||||
dim=0,
|
||||
output_size=target_rows,
|
||||
)
|
||||
|
||||
|
||||
class GroupedExperts(nn.Module):
|
||||
supported_fusions = {"gate_up": fuse_gate_up_projections}
|
||||
|
||||
@@ -94,7 +78,7 @@ class GroupedExperts(nn.Module):
|
||||
expert_type: ExpertType = "gated",
|
||||
activation: ActivationType = "silu",
|
||||
bias: bool = False,
|
||||
grouped_gemm: GroupedGemm | None = None,
|
||||
compute: ExpertCompute | None = None,
|
||||
):
|
||||
super().__init__()
|
||||
self.num_experts = num_experts
|
||||
@@ -109,59 +93,25 @@ class GroupedExperts(nn.Module):
|
||||
self.up_proj_bias = nn.Parameter(torch.empty(num_experts, hidden_dim)) if bias else None
|
||||
self.down_proj_bias = nn.Parameter(torch.empty(num_experts, dim)) if bias else None
|
||||
|
||||
self.grouped_gemm = grouped_gemm or BF16GroupedGemm()
|
||||
self.activation = ActivationDispatch[activation]
|
||||
if expert_type == "non_gated":
|
||||
self.supported_fusions = {}
|
||||
self.set_compute(compute or BF16ExpertCompute())
|
||||
|
||||
def set_compute(self, compute: ExpertCompute) -> None:
|
||||
compute.validate(self)
|
||||
self.compute = compute
|
||||
|
||||
@property
|
||||
def token_group_alignment(self) -> int:
|
||||
return self.grouped_gemm.token_group_alignment
|
||||
|
||||
def set_grouped_gemm(self, grouped_gemm: GroupedGemm) -> None:
|
||||
self.grouped_gemm = grouped_gemm
|
||||
return self.compute.token_group_alignment
|
||||
|
||||
def forward(
|
||||
self,
|
||||
x: torch.Tensor,
|
||||
num_tokens_per_expert: torch.Tensor,
|
||||
) -> torch.Tensor:
|
||||
assert x.dim() == 2
|
||||
|
||||
def to_local(tensor: torch.Tensor) -> torch.Tensor:
|
||||
return tensor.to_local() if isinstance(tensor, DTensor) else tensor
|
||||
|
||||
offsets = torch.cumsum(num_tokens_per_expert, dim=0, dtype=torch.int32)
|
||||
x_bf16 = x.bfloat16()
|
||||
|
||||
if self.gate_up_proj is None:
|
||||
up_proj = to_local(self.up_proj).transpose(-2, -1)
|
||||
up = self.grouped_gemm(x_bf16, up_proj.bfloat16(), offs=offsets)
|
||||
|
||||
gate = None
|
||||
if self.gate_proj is not None:
|
||||
gate_proj = to_local(self.gate_proj).transpose(-2, -1)
|
||||
gate = self.grouped_gemm(x_bf16, gate_proj.bfloat16(), offs=offsets)
|
||||
else:
|
||||
gate_up_proj = to_local(self.gate_up_proj).transpose(-2, -1)
|
||||
gate_up = self.grouped_gemm(x_bf16, gate_up_proj.bfloat16(), offs=offsets)
|
||||
gate, up = gate_up.chunk(2, dim=-1)
|
||||
|
||||
if self.up_proj_bias is not None:
|
||||
up_proj_bias = to_local(self.up_proj_bias)
|
||||
up = up + broadcast_expert_bias(up_proj_bias, num_tokens_per_expert, up.shape[0]).bfloat16()
|
||||
|
||||
if gate is not None and self.gate_proj_bias is not None:
|
||||
gate_proj_bias = to_local(self.gate_proj_bias)
|
||||
gate = gate + broadcast_expert_bias(gate_proj_bias, num_tokens_per_expert, gate.shape[0]).bfloat16()
|
||||
|
||||
hidden = self.activation.apply(gate, up)
|
||||
down_proj = to_local(self.down_proj).transpose(-2, -1)
|
||||
output = self.grouped_gemm(hidden, down_proj.bfloat16(), offs=offsets)
|
||||
if self.down_proj_bias is not None:
|
||||
down_proj_bias = to_local(self.down_proj_bias)
|
||||
output = output + broadcast_expert_bias(down_proj_bias, num_tokens_per_expert, output.shape[0]).bfloat16()
|
||||
return output.type_as(x)
|
||||
return self.compute(self, x, num_tokens_per_expert)
|
||||
|
||||
def init_weights(self, init_std: float):
|
||||
if self.gate_up_proj is None:
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import torch
|
||||
from sonicmoe import moe_general_routing_inputs
|
||||
from sonicmoe.enums import ActivationType
|
||||
from torch.distributed.tensor import DTensor
|
||||
|
||||
from prime_rl.trainer.models.layers.activations import Silu
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from prime_rl.trainer.models.layers.moe import GroupedExperts
|
||||
|
||||
|
||||
class SonicMoEExpertCompute:
|
||||
token_group_alignment = 8
|
||||
|
||||
def validate(self, experts: "GroupedExperts") -> None:
|
||||
if experts.gate_up_proj is None:
|
||||
raise ValueError(
|
||||
"SonicMoE requires gated experts with fused gate/up projections. Enable the gate_up fusion."
|
||||
)
|
||||
if experts.activation is not Silu:
|
||||
raise ValueError(
|
||||
"SonicMoE requires standard SwiGLU (silu); custom or clamped activations are not supported."
|
||||
)
|
||||
if any(bias is not None for bias in (experts.gate_proj_bias, experts.up_proj_bias, experts.down_proj_bias)):
|
||||
raise ValueError("SonicMoE requires bias-free experts.")
|
||||
|
||||
def __call__(self, experts: "GroupedExperts", x: torch.Tensor, num_tokens_per_expert: torch.Tensor) -> torch.Tensor:
|
||||
gate_up = experts.gate_up_proj
|
||||
down = experts.down_proj
|
||||
if isinstance(gate_up, DTensor):
|
||||
gate_up = gate_up.to_local()
|
||||
down = down.to_local()
|
||||
|
||||
token_indices = torch.arange(x.shape[0], dtype=torch.int32, device=x.device)
|
||||
offsets = num_tokens_per_expert.cumsum(0, dtype=torch.int32)
|
||||
expert_indices = torch.searchsorted(offsets, token_indices, right=True)
|
||||
# Dispatch discards the trailing padding beyond the per-expert counts.
|
||||
expert_indices = expert_indices.clamp_max(gate_up.shape[0] - 1).to(torch.int32)
|
||||
output, _ = moe_general_routing_inputs(
|
||||
x=x.bfloat16(),
|
||||
router_scores=torch.ones(x.shape[0], dtype=torch.float32, device=x.device),
|
||||
token_indices=token_indices,
|
||||
expert_indices=expert_indices,
|
||||
w1=gate_up.bfloat16().permute(1, 2, 0),
|
||||
b1=None,
|
||||
w2=down.bfloat16().permute(1, 2, 0),
|
||||
b2=None,
|
||||
E=gate_up.shape[0],
|
||||
stream_id=0,
|
||||
activation_type=ActivationType.SWIGLU,
|
||||
concat_layout=True,
|
||||
)
|
||||
return output.type_as(x)
|
||||
@@ -19,11 +19,11 @@ from prime_rl.trainer.distributed.token_dispatcher import (
|
||||
MXFP8TorchTokenDispatcher,
|
||||
TorchTokenDispatcher,
|
||||
)
|
||||
from prime_rl.trainer.models.layers.grouped_gemm import (
|
||||
BF16GroupedGemm,
|
||||
DeepGemmFP8GroupedGemm,
|
||||
GroupedGemm,
|
||||
MXFP8GroupedGemm,
|
||||
from prime_rl.trainer.models.layers.expert_compute import (
|
||||
BF16ExpertCompute,
|
||||
DeepGemmFP8ExpertCompute,
|
||||
ExpertCompute,
|
||||
MXFP8ExpertCompute,
|
||||
)
|
||||
from prime_rl.trainer.models.layers.moe import MoE
|
||||
from prime_rl.trainer.parallel_dims import ParallelDims
|
||||
@@ -31,10 +31,14 @@ from prime_rl.utils.logger import get_logger
|
||||
from prime_rl.utils.vlm import get_language_model
|
||||
|
||||
|
||||
def _resolve_grouped_gemm(config: ModelConfig) -> GroupedGemm:
|
||||
def _resolve_expert_compute(config: ModelConfig) -> ExpertCompute:
|
||||
compute = config.moe.compute
|
||||
if isinstance(compute, BF16MoEComputeConfig):
|
||||
return BF16GroupedGemm()
|
||||
if compute.backend == "sonicmoe":
|
||||
from prime_rl.trainer.models.layers.sonic_moe import SonicMoEExpertCompute
|
||||
|
||||
return SonicMoEExpertCompute()
|
||||
return BF16ExpertCompute()
|
||||
if isinstance(compute, DeepGemmFP8MoEComputeConfig):
|
||||
if importlib.util.find_spec("deep_gemm") is None:
|
||||
raise RuntimeError("DeepGEMM FP8 expert compute requires the deep-gemm package.")
|
||||
@@ -43,15 +47,14 @@ def _resolve_grouped_gemm(config: ModelConfig) -> GroupedGemm:
|
||||
raise RuntimeError(
|
||||
f"DeepGEMM FP8 expert compute requires SM90 or newer, but this device is SM{capability[0]}{capability[1]}."
|
||||
)
|
||||
return DeepGemmFP8GroupedGemm()
|
||||
return DeepGemmFP8ExpertCompute()
|
||||
if isinstance(compute, MXFP8MoEComputeConfig):
|
||||
import prime_kernels
|
||||
|
||||
kernel = prime_kernels.load("mxfp8_moe")
|
||||
return MXFP8GroupedGemm(
|
||||
return MXFP8ExpertCompute(
|
||||
kernel=kernel,
|
||||
high_precision_wgrad=compute.recipe == "mxfp8_rceil_wgrad_with_hp",
|
||||
token_group_alignment=kernel.TOKEN_GROUP_ALIGNMENT,
|
||||
)
|
||||
raise TypeError(f"Unsupported MoE compute config: {type(compute).__name__}")
|
||||
|
||||
@@ -77,37 +80,37 @@ def configure_moe_runtime(model: nn.Module, config: ModelConfig, parallel_dims:
|
||||
if isinstance(module, MoE)
|
||||
}
|
||||
get_logger().debug(f"Selected model layers for MoE compute: {sorted(selected_layers)}")
|
||||
bf16_grouped_gemm = BF16GroupedGemm()
|
||||
selected_grouped_gemm = _resolve_grouped_gemm(config) if selected_moes else bf16_grouped_gemm
|
||||
bf16_compute = BF16ExpertCompute()
|
||||
selected_compute = _resolve_expert_compute(config) if selected_moes else bf16_compute
|
||||
ep_mesh = parallel_dims.get_mesh("ep") if parallel_dims.ep_enabled else None
|
||||
dispatch = config.moe.dispatch
|
||||
|
||||
for moe in moe_layers:
|
||||
grouped_gemm = selected_grouped_gemm if moe in selected_moes else bf16_grouped_gemm
|
||||
compute = selected_compute if moe in selected_moes else bf16_compute
|
||||
if ep_mesh is not None and moe.experts.num_experts % parallel_dims.ep:
|
||||
raise ValueError(
|
||||
f"MoE expert count {moe.experts.num_experts} must be divisible by model.ep={parallel_dims.ep}."
|
||||
)
|
||||
moe.experts.set_grouped_gemm(grouped_gemm)
|
||||
moe.experts.set_compute(compute)
|
||||
if ep_mesh is None:
|
||||
token_dispatcher = LocalTokenDispatcher(
|
||||
num_experts=moe.experts.num_experts,
|
||||
top_k=moe.router.top_k,
|
||||
token_group_alignment=grouped_gemm.token_group_alignment,
|
||||
token_group_alignment=compute.token_group_alignment,
|
||||
)
|
||||
elif isinstance(dispatch, TorchMoEDispatchConfig):
|
||||
if dispatch.transport == "mxfp8" and isinstance(grouped_gemm, MXFP8GroupedGemm):
|
||||
if dispatch.transport == "mxfp8" and isinstance(compute, MXFP8ExpertCompute):
|
||||
token_dispatcher = MXFP8TorchTokenDispatcher(
|
||||
num_experts=moe.experts.num_experts,
|
||||
top_k=moe.router.top_k,
|
||||
token_group_alignment=grouped_gemm.token_group_alignment,
|
||||
token_group_alignment=compute.token_group_alignment,
|
||||
group=ep_mesh.get_group(),
|
||||
)
|
||||
else:
|
||||
token_dispatcher = TorchTokenDispatcher(
|
||||
num_experts=moe.experts.num_experts,
|
||||
top_k=moe.router.top_k,
|
||||
token_group_alignment=grouped_gemm.token_group_alignment,
|
||||
token_group_alignment=compute.token_group_alignment,
|
||||
group=ep_mesh.get_group(),
|
||||
)
|
||||
elif isinstance(dispatch, DeepEPMoEDispatchConfig):
|
||||
@@ -115,7 +118,7 @@ def configure_moe_runtime(model: nn.Module, config: ModelConfig, parallel_dims:
|
||||
|
||||
token_dispatcher = DeepEPTokenDispatcher(
|
||||
num_experts=moe.experts.num_experts,
|
||||
token_group_alignment=grouped_gemm.token_group_alignment,
|
||||
token_group_alignment=compute.token_group_alignment,
|
||||
group=ep_mesh.get_group(),
|
||||
num_sms=dispatch.num_sms,
|
||||
token_chunk_size=dispatch.token_chunk_size,
|
||||
@@ -128,6 +131,6 @@ def configure_moe_runtime(model: nn.Module, config: ModelConfig, parallel_dims:
|
||||
parallelize_module(moe.experts, device_mesh=ep_mesh, parallelize_plan=ExpertWeightParallel())
|
||||
|
||||
get_logger().info(
|
||||
f"Configured {len(selected_moes)}/{len(moe_layers)} MoE layers with compute={config.moe.compute.type}, "
|
||||
f"Configured {len(selected_moes)}/{len(moe_layers)} MoE layers with compute={type(selected_compute).__name__}, "
|
||||
f"apply_to={config.moe.compute.apply_to}, fallback=bf16, dispatch={config.moe.dispatch.type}, ep={parallel_dims.ep}"
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ import torch
|
||||
from datasets import Dataset, interleave_datasets, load_dataset
|
||||
from huggingface_hub import snapshot_download
|
||||
from jaxtyping import Bool, Int
|
||||
from renderers import AutoRendererConfig, RendererConfig
|
||||
from renderers import AutoRendererConfig, RendererConfig, merge_chat_template_kwargs
|
||||
from renderers.base import MultiModalData, PlaceholderRange, Renderer, build_training_sample, create_renderer
|
||||
from torch import Tensor
|
||||
from torch.distributed.checkpoint.stateful import Stateful
|
||||
@@ -18,7 +18,7 @@ from torch.utils.data import IterableDataset, get_worker_info
|
||||
from torchdata.stateful_dataloader import StatefulDataLoader
|
||||
from transformers.tokenization_utils import PreTrainedTokenizer
|
||||
|
||||
from prime_rl.configs.sft import DataConfig, LossMaskConfig, SFTDataConfig
|
||||
from prime_rl.configs.sft import DataConfig, LossMaskConfig, SFTColumnsConfig, SFTDataConfig
|
||||
from prime_rl.trainer.world import get_world
|
||||
from prime_rl.utils.chat_template import deserialize_tool_calls, normalize_messages
|
||||
from prime_rl.utils.logger import get_logger
|
||||
@@ -209,37 +209,41 @@ def _truncate_mm_data(mm: MultiModalData, cut: int) -> MultiModalData:
|
||||
return MultiModalData(mm_hashes=new_hashes, mm_placeholders=new_placeholders, mm_items=new_items)
|
||||
|
||||
|
||||
def with_reasoning_effort(config: RendererConfig, reasoning_effort: Any) -> RendererConfig:
|
||||
"""Copy ``config`` with its ``reasoning_effort`` field set, validated by the config class."""
|
||||
if isinstance(config, AutoRendererConfig):
|
||||
raise ValueError(
|
||||
"A reasoning_effort column requires a typed renderer config (e.g. [renderer] name = 'qwen3.8'), "
|
||||
"not renderer.name = 'auto'"
|
||||
)
|
||||
if "reasoning_effort" not in type(config).model_fields:
|
||||
raise ValueError(f"Renderer {config.name!r} has no reasoning_effort field, but a row sets {reasoning_effort!r}")
|
||||
return type(config).model_validate({**config.model_dump(), "reasoning_effort": reasoning_effort})
|
||||
|
||||
|
||||
class RendererResolver:
|
||||
"""Picks the renderer for a dataset row.
|
||||
|
||||
A ``reasoning_effort`` column overrides the configured renderer's field of
|
||||
the same name per row. Renderer configs are frozen, so renderers are cached
|
||||
``columns`` maps renderer fields to dataset columns; a row's non-null
|
||||
values override the configured renderer's fields, validated as
|
||||
chat-template kwargs. Renderer configs are frozen, so renderers are cached
|
||||
per config and rows that resolve to the same config share one instance.
|
||||
"""
|
||||
|
||||
def __init__(self, tokenizer: PreTrainedTokenizer, config: RendererConfig, processor: Any | None = None):
|
||||
def __init__(
|
||||
self,
|
||||
tokenizer: PreTrainedTokenizer,
|
||||
config: RendererConfig,
|
||||
processor: Any | None = None,
|
||||
columns: dict[str, str] | None = None,
|
||||
):
|
||||
self.tokenizer = tokenizer
|
||||
self.config = config
|
||||
self.processor = processor
|
||||
self.columns = SFTColumnsConfig().renderer if columns is None else columns
|
||||
self.renderers: dict[RendererConfig, Renderer] = {}
|
||||
|
||||
def resolve_config(self, example: dict) -> RendererConfig:
|
||||
kwargs = {field: example[column] for field, column in self.columns.items() if example.get(column) is not None}
|
||||
if not kwargs:
|
||||
return self.config
|
||||
if isinstance(self.config, AutoRendererConfig):
|
||||
raise ValueError(
|
||||
f"Per-sample renderer arguments {sorted(kwargs)} require a typed renderer config "
|
||||
"(e.g. [renderer] name = 'qwen3.8'), not renderer.name = 'auto'"
|
||||
)
|
||||
return merge_chat_template_kwargs(self.config, kwargs)
|
||||
|
||||
def __call__(self, example: dict) -> Renderer:
|
||||
config = self.config
|
||||
reasoning_effort = example.get("reasoning_effort")
|
||||
if reasoning_effort is not None:
|
||||
config = with_reasoning_effort(config, reasoning_effort)
|
||||
config = self.resolve_config(example)
|
||||
renderer = self.renderers.get(config)
|
||||
if renderer is None:
|
||||
renderer = create_renderer(self.tokenizer, config)
|
||||
@@ -264,12 +268,21 @@ class SFTDataset(StatefulIterableDataset):
|
||||
max_examples: int | None = None,
|
||||
max_epochs: int | None = None,
|
||||
multimodal: bool = False,
|
||||
columns: SFTColumnsConfig = SFTColumnsConfig(),
|
||||
):
|
||||
super().__init__(non_dp_size)
|
||||
self.logger = get_logger()
|
||||
self.dataset = dataset
|
||||
self.num_examples = len(self.dataset)
|
||||
self.renderers = renderers
|
||||
self.columns = columns
|
||||
# Default names are optional: a dataset carries either messages or
|
||||
# prompt/completion, and tools only for tool use. A name set in the
|
||||
# config must exist.
|
||||
for field in ("messages", "prompt", "completion", "tools"):
|
||||
column = getattr(columns, field)
|
||||
if column != field and column not in dataset.column_names:
|
||||
raise ValueError(f"data.columns.{field} is {column!r}, but the dataset has only {dataset.column_names}")
|
||||
self.shuffle = shuffle
|
||||
self.seed = seed
|
||||
self.seq_len = seq_len
|
||||
@@ -289,16 +302,17 @@ class SFTDataset(StatefulIterableDataset):
|
||||
# as a whole-chat training sample with an empty prompt. Null-check rather
|
||||
# than key-check: Arrow schema union adds `messages: null` to
|
||||
# prompt/completion rows whenever other rows have a `messages` column.
|
||||
if example.get("messages") is not None:
|
||||
messages = normalize_messages(example["messages"], default_role="assistant")
|
||||
elif example.get("prompt") is not None and example.get("completion") is not None:
|
||||
messages = normalize_messages(example["prompt"], default_role="user") + normalize_messages(
|
||||
example["completion"], default_role="assistant"
|
||||
columns = self.columns
|
||||
if example.get(columns.messages) is not None:
|
||||
messages = normalize_messages(example[columns.messages], default_role="assistant")
|
||||
elif example.get(columns.prompt) is not None and example.get(columns.completion) is not None:
|
||||
messages = normalize_messages(example[columns.prompt], default_role="user") + normalize_messages(
|
||||
example[columns.completion], default_role="assistant"
|
||||
)
|
||||
else:
|
||||
raise ValueError(
|
||||
"All examples in the dataset must have either a 'messages' column "
|
||||
"or both 'prompt' and 'completion' columns for SFT"
|
||||
f"All examples in the dataset must have either a {columns.messages!r} column "
|
||||
f"or both {columns.prompt!r} and {columns.completion!r} columns for SFT"
|
||||
)
|
||||
|
||||
# Strip nulls before deserializing so genuine nulls inside tool-call
|
||||
@@ -308,30 +322,11 @@ class SFTDataset(StatefulIterableDataset):
|
||||
|
||||
messages = resolve_messages(example)
|
||||
|
||||
# Parse available tools, if present - assumes OAI format. Accepts either
|
||||
# `tools` or `tool_defs` (the verifiers rollout format), as either a
|
||||
# JSON-encoded string of a list or a list of dicts; verifiers-shaped
|
||||
# tools are converted to OAI form for the chat template.
|
||||
raw_tools = example.get("tools", example.get("tool_defs"))
|
||||
if not raw_tools:
|
||||
tools = []
|
||||
else:
|
||||
if isinstance(raw_tools, str):
|
||||
raw_tools = json.loads(raw_tools)
|
||||
tools = [
|
||||
t
|
||||
if isinstance(t, dict) and t.get("type") == "function" and "function" in t
|
||||
else {
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": t.get("name"),
|
||||
"description": t.get("description"),
|
||||
"parameters": t.get("parameters"),
|
||||
**({} if t.get("strict") is None else {"strict": t["strict"]}),
|
||||
},
|
||||
}
|
||||
for t in raw_tools
|
||||
]
|
||||
# Tool schemas in OpenAI function-calling format, as a list of dicts or a
|
||||
# JSON-encoded string of one.
|
||||
tools = example.get(self.columns.tools) or []
|
||||
if isinstance(tools, str):
|
||||
tools = json.loads(tools)
|
||||
|
||||
def should_mask(message: dict) -> bool:
|
||||
assert "role" in message, "Message must have a role"
|
||||
@@ -741,7 +736,7 @@ def setup_dataset(
|
||||
raise ValueError("SFT data requires a renderer config.")
|
||||
if raw_dataset is None:
|
||||
raw_dataset = load_sft_dataset(config)
|
||||
renderers = RendererResolver(tokenizer, renderer_config, processor=processor)
|
||||
renderers = RendererResolver(tokenizer, renderer_config, processor=processor, columns=config.columns.renderer)
|
||||
return SFTDataset(
|
||||
raw_dataset,
|
||||
renderers,
|
||||
@@ -752,6 +747,7 @@ def setup_dataset(
|
||||
non_dp_size=non_dp_size,
|
||||
max_epochs=max_epochs,
|
||||
multimodal=multimodal,
|
||||
columns=config.columns,
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Invalid dataset type: {config.type}")
|
||||
|
||||
@@ -30,6 +30,7 @@ from prime_rl.trainer.model import (
|
||||
get_global_moe_stats,
|
||||
get_load_balance_stats,
|
||||
is_tt_moe_model,
|
||||
reshard_module,
|
||||
setup_processor,
|
||||
setup_tokenizer,
|
||||
setup_model,
|
||||
@@ -494,6 +495,10 @@ def train(config: SFTConfig):
|
||||
# optimizer step (so eval_on_start evaluates untrained weights)
|
||||
if run_validation_this_step:
|
||||
run_validation(progress.step)
|
||||
# The no-grad validation forward leaves the [lm_head, norm] FSDP2 group unsharded (it
|
||||
# opts out of reshard_after_forward), so clip_grad_norm_ below would skip its grad-less
|
||||
# unsharded parameters. Reshard so clipping sees every gradient.
|
||||
reshard_module(model)
|
||||
|
||||
# Compute the global mean loss for logging.
|
||||
dist.all_reduce(step_loss_sum, op=dist.ReduceOp.SUM, group=dp_cp_group)
|
||||
|
||||
@@ -6,6 +6,7 @@ import pytest
|
||||
import tomli_w
|
||||
from pydantic import BaseModel, Field, ValidationError
|
||||
from pydantic_config import ConfigFileError
|
||||
from renderers import custom_renderer_config
|
||||
|
||||
from prime_rl.configs.env_server import EnvServerConfig
|
||||
from prime_rl.configs.eval import EvalConfig, SFTOnlineEvalConfig
|
||||
@@ -211,6 +212,7 @@ def test_moe_runtime_defaults_are_independent_from_dense_quantization():
|
||||
|
||||
assert config.quantization is not None and config.quantization.type == "mxfp8"
|
||||
assert config.moe.compute.type == "bf16"
|
||||
assert config.moe.compute.backend == "torch"
|
||||
assert config.moe.dispatch.type == "torch"
|
||||
assert config.moe.dispatch.transport == "bf16"
|
||||
|
||||
@@ -218,6 +220,11 @@ def test_moe_runtime_defaults_are_independent_from_dense_quantization():
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
[
|
||||
{"ep": 2, "moe": {"compute": {"type": "bf16", "backend": "sonicmoe"}}},
|
||||
{
|
||||
"ep": 2,
|
||||
"moe": {"compute": {"type": "bf16", "backend": "sonicmoe"}, "dispatch": {"type": "deepep"}},
|
||||
},
|
||||
{"moe": {"compute": {"type": "deepgemm_fp8"}}},
|
||||
{"moe": {"compute": {"type": "mxfp8", "recipe": "mxfp8_rceil_wgrad_with_hp"}}},
|
||||
{"ep": 2, "moe": {"dispatch": {"type": "deepep", "num_sms": 16, "token_chunk_size": 1024}}},
|
||||
@@ -1031,3 +1038,79 @@ def test_combined_replay_uses_v2_runner(monkeypatch):
|
||||
assert config.enable_return_sampling_mask is True
|
||||
assert config.vllm.enable_return_routed_experts is True
|
||||
assert os.environ["VLLM_USE_V2_MODEL_RUNNER"] == "1"
|
||||
|
||||
|
||||
CUSTOM_RENDERER_SOURCE = """
|
||||
from typing import Literal
|
||||
|
||||
from renderers.configs import BaseRendererConfig
|
||||
|
||||
|
||||
class InstructedRendererConfig(BaseRendererConfig):
|
||||
name: Literal["instructed"] = "instructed"
|
||||
_template_fields = frozenset({"instruction"})
|
||||
|
||||
instruction: str = "Think step by step."
|
||||
|
||||
|
||||
class InstructedRenderer:
|
||||
config_class = InstructedRendererConfig
|
||||
"""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def custom_renderer_import_path(tmp_path):
|
||||
path = tmp_path / "instructed_renderer.py"
|
||||
path.write_text(CUSTOM_RENDERER_SOURCE)
|
||||
return f"{path}:InstructedRenderer"
|
||||
|
||||
|
||||
def test_sft_config_accepts_custom_renderer(tmp_path, custom_renderer_import_path):
|
||||
config_file = tmp_path / "sft.toml"
|
||||
config_file.write_text(
|
||||
tomli_w.dumps(
|
||||
{
|
||||
"model": {"name": "PrimeIntellect/Qwen3-0.6B"},
|
||||
"data": {"name": "willcb/R1-reverse-wikipedia-paragraphs-v1-1000"},
|
||||
"renderer": {"name": "custom", "import_path": custom_renderer_import_path, "instruction": "Be brief."},
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
config = cli(SFTConfig, args=["@", str(config_file)])
|
||||
|
||||
assert config.renderer.name == "custom"
|
||||
assert custom_renderer_config(config.renderer).name == "instructed"
|
||||
assert custom_renderer_config(config.renderer).instruction == "Be brief."
|
||||
|
||||
|
||||
def test_orchestrator_config_accepts_custom_renderer(tmp_path, custom_renderer_import_path):
|
||||
config_file = tmp_path / "orch.toml"
|
||||
config_file.write_text(
|
||||
tomli_w.dumps(
|
||||
{
|
||||
"model": {"name": "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"},
|
||||
"renderer": {"name": "custom", "import_path": custom_renderer_import_path},
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
config = cli(OrchestratorConfig, args=["@", str(config_file)])
|
||||
|
||||
assert config.renderer.name == "custom"
|
||||
assert custom_renderer_config(config.renderer).instruction == "Think step by step."
|
||||
|
||||
|
||||
def test_custom_renderer_rejects_unknown_fields(tmp_path, custom_renderer_import_path):
|
||||
config_file = tmp_path / "sft.toml"
|
||||
config_file.write_text(
|
||||
tomli_w.dumps(
|
||||
{
|
||||
"model": {"name": "PrimeIntellect/Qwen3-0.6B"},
|
||||
"renderer": {"name": "custom", "import_path": custom_renderer_import_path, "depth": 3},
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
with pytest.raises(ConfigFileError, match="depth"):
|
||||
cli(SFTConfig, args=["@", str(config_file)])
|
||||
|
||||
@@ -274,3 +274,34 @@ def test_semantic_timeline_labels_unrecoverable_components_as_unlinked() -> None
|
||||
"index": 0,
|
||||
"unlinked": True,
|
||||
}
|
||||
|
||||
|
||||
def test_semantic_timeline_marks_cancelled_and_failed_subagents() -> None:
|
||||
# A parent spawns three subagents: A returns, B is cancelled (parent -> child subagent_cancel),
|
||||
# C fails on return (child -> parent subagent_failed).
|
||||
nodes = [
|
||||
_node(None, 0.0),
|
||||
_node(0, 1.0), # parent's spawning turn
|
||||
_node(0, 2.0, [{"node": 1, "type": "subagent_call"}]), # A
|
||||
_node(0, 2.1, [{"node": 1, "type": "subagent_call"}, {"node": 5, "type": "subagent_cancel"}]), # B
|
||||
_node(0, 2.2, [{"node": 1, "type": "subagent_call"}]), # C
|
||||
_node(
|
||||
1,
|
||||
6.0,
|
||||
[
|
||||
{"node": 1, "type": "continuation"},
|
||||
{"node": 2, "type": "subagent_return"}, # A returned
|
||||
{"node": 4, "type": "subagent_failed"}, # C failed on return
|
||||
],
|
||||
),
|
||||
]
|
||||
calls = [_call(1, 0.5, 1.0), _call(2, 2.0, 3.0), _call(3, 2.1, 5.0), _call(4, 2.2, 3.2), _call(5, 5.6, 6.0)]
|
||||
timeline = project_episode_timeline(_episode(nodes, calls))
|
||||
|
||||
status = {lane["label"]: lane["status"] for lane in timeline["semantic_lanes"]}
|
||||
assert status["subagent 1 · context 0"] == "completed"
|
||||
assert status["subagent 2 · context 0"] == "cancelled"
|
||||
assert status["subagent 3 · context 0"] == "failed"
|
||||
cancelled = next(l for l in timeline["semantic_lanes"] if l["label"] == "subagent 2 · context 0")
|
||||
assert cancelled["context"]["outcome"] == "cancelled"
|
||||
assert "subagent_cancel" in {e["type"] for e in timeline["semantic_edges"]}
|
||||
|
||||
@@ -5,8 +5,10 @@ import torch.nn.functional as F
|
||||
from prime_rl.configs.trainer import ModelConfig
|
||||
from prime_rl.trainer.distributed.token_dispatcher import LocalTokenDispatcher
|
||||
from prime_rl.trainer.model import is_tt_moe_model
|
||||
from prime_rl.trainer.models.deepseek_v4.moe import DeepseekV4Experts
|
||||
from prime_rl.trainer.models.fusions import fuse_gate_up_projections
|
||||
from prime_rl.trainer.models.layers.activations import ActivationDispatch
|
||||
from prime_rl.trainer.models.layers.grouped_gemm import BF16GroupedGemm
|
||||
from prime_rl.trainer.models.layers.expert_compute import BF16ExpertCompute, GroupedGemmExpertCompute
|
||||
from prime_rl.trainer.models.layers.mlp import FeedForward
|
||||
from prime_rl.trainer.models.layers.moe import (
|
||||
GroupedExperts,
|
||||
@@ -40,24 +42,56 @@ def test_moe_detection_for_text_and_vlm(config_cls, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("selection", [[], [0], "0%", "50%"])
|
||||
def test_unselected_moe_uses_bf16_without_loading_quantization_backend(selection):
|
||||
@pytest.mark.parametrize("compute", [{"type": "mxfp8"}, {"type": "bf16", "backend": "sonicmoe"}])
|
||||
def test_unselected_moe_uses_bf16_without_loading_compute_backend(selection, compute):
|
||||
moe = MoE.from_args(MoEArgs(num_experts=2), dim=4, hidden_dim=8, shared_expert=None)
|
||||
parameters = dict(moe.named_parameters())
|
||||
model = torch.nn.Module()
|
||||
model.model = torch.nn.Module()
|
||||
model.model.layers = torch.nn.ModuleList([torch.nn.Identity(), moe])
|
||||
config = ModelConfig.model_validate({"moe": {"compute": {"type": "mxfp8", "apply_to": selection}}})
|
||||
config = ModelConfig.model_validate({"moe": {"compute": {**compute, "apply_to": selection}}})
|
||||
dims = ParallelDims(dp_replicate=1, dp_shard=1, cp=1, pp=1, ep=1, world_size=1)
|
||||
|
||||
configure_moe_runtime(model, config, dims)
|
||||
|
||||
assert isinstance(moe.experts.grouped_gemm, BF16GroupedGemm)
|
||||
assert isinstance(moe.experts.compute, BF16ExpertCompute)
|
||||
assert isinstance(moe.token_dispatcher, LocalTokenDispatcher)
|
||||
assert moe.token_dispatcher.token_group_alignment == moe.experts.grouped_gemm.token_group_alignment
|
||||
assert moe.token_dispatcher.token_group_alignment == moe.experts.compute.token_group_alignment
|
||||
assert all(moe.get_parameter(name) is parameter for name, parameter in parameters.items())
|
||||
|
||||
|
||||
def _grouped_mm_reference(x: torch.Tensor, weights: torch.Tensor, *, offs: torch.Tensor) -> torch.Tensor:
|
||||
@pytest.mark.parametrize(
|
||||
("expert_cls", "kwargs", "fused", "error"),
|
||||
[
|
||||
pytest.param(GroupedExperts, {}, True, None, id="swiglu"),
|
||||
pytest.param(GroupedExperts, {}, False, "fused gate/up", id="unfused"),
|
||||
pytest.param(GroupedExperts, {"expert_type": "non_gated"}, False, "gated experts", id="non-gated"),
|
||||
pytest.param(GroupedExperts, {"activation": "relu2"}, True, "standard SwiGLU", id="relu2"),
|
||||
pytest.param(GroupedExperts, {"activation": "clamped_swiglu"}, True, "standard SwiGLU", id="clamped-swiglu"),
|
||||
pytest.param(GroupedExperts, {"bias": True}, True, "bias-free", id="bias"),
|
||||
pytest.param(DeepseekV4Experts, {"swiglu_limit": 10.0}, True, "standard SwiGLU", id="deepseek-v4"),
|
||||
],
|
||||
)
|
||||
def test_set_compute_validates_sonic_expert_structure(expert_cls, kwargs, fused, error):
|
||||
pytest.importorskip("sonicmoe")
|
||||
from prime_rl.trainer.models.layers.sonic_moe import SonicMoEExpertCompute
|
||||
|
||||
experts = expert_cls(dim=4, hidden_dim=8, num_experts=2, **kwargs)
|
||||
if fused:
|
||||
fuse_gate_up_projections(experts)
|
||||
original_compute = experts.compute
|
||||
compute = SonicMoEExpertCompute()
|
||||
|
||||
if error is not None:
|
||||
with pytest.raises(ValueError, match=error):
|
||||
experts.set_compute(compute)
|
||||
assert experts.compute is original_compute
|
||||
else:
|
||||
experts.set_compute(compute)
|
||||
assert experts.compute is compute
|
||||
|
||||
|
||||
def _grouped_mm_reference(x: torch.Tensor, weights: torch.Tensor, offs: torch.Tensor) -> torch.Tensor:
|
||||
outputs = []
|
||||
start = 0
|
||||
for expert, end in enumerate(offs.tolist()):
|
||||
@@ -66,13 +100,6 @@ def _grouped_mm_reference(x: torch.Tensor, weights: torch.Tensor, *, offs: torch
|
||||
return torch.cat(outputs)
|
||||
|
||||
|
||||
class ReferenceGroupedGemm:
|
||||
token_group_alignment = 1
|
||||
|
||||
def __call__(self, x: torch.Tensor, weights: torch.Tensor, *, offs: torch.Tensor) -> torch.Tensor:
|
||||
return _grouped_mm_reference(x, weights, offs=offs)
|
||||
|
||||
|
||||
def _scaled_square_experts(x: torch.Tensor, counts: torch.Tensor) -> torch.Tensor:
|
||||
output = torch.zeros_like(x)
|
||||
scales = torch.repeat_interleave(torch.arange(1, len(counts) + 1, dtype=x.dtype), counts)
|
||||
@@ -149,8 +176,9 @@ def test_expert_type_and_activation_are_independent(expert_type, activation):
|
||||
expert_type=expert_type,
|
||||
activation=activation,
|
||||
bias=True,
|
||||
grouped_gemm=ReferenceGroupedGemm(),
|
||||
)
|
||||
experts.set_compute(GroupedGemmExpertCompute(_grouped_mm_reference, token_group_alignment=1))
|
||||
assert experts.token_group_alignment == 1
|
||||
experts.init_weights(0.02)
|
||||
|
||||
has_gate = expert_type == "gated"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
from collections import Counter
|
||||
|
||||
import pytest
|
||||
@@ -485,3 +486,111 @@ def test_cat_dataset_packs_text_and_multimodal_samples_together():
|
||||
assert text_pack["seq_lens"] == [5]
|
||||
assert text_pack["mm_kwargs"] is None
|
||||
assert text_pack["mm_token_type_ids"] is None
|
||||
|
||||
|
||||
CUSTOM_RENDERER_SOURCE = """
|
||||
from typing import Literal
|
||||
|
||||
from renderers.base import RenderedTokens
|
||||
from renderers.configs import BaseRendererConfig
|
||||
|
||||
|
||||
class EffortRendererConfig(BaseRendererConfig):
|
||||
name: Literal["effort"] = "effort"
|
||||
_template_fields = frozenset({"reasoning_effort"})
|
||||
|
||||
reasoning_effort: Literal["low", "high"] = "low"
|
||||
|
||||
|
||||
class EffortRenderer:
|
||||
config_class = EffortRendererConfig
|
||||
|
||||
def __init__(self, tokenizer, config):
|
||||
self.config = config
|
||||
|
||||
def render(self, messages, **kwargs):
|
||||
return RenderedTokens(token_ids=[0, 1], message_indices=[-1, 0], sampled_mask=[False, True])
|
||||
|
||||
def get_stop_token_ids(self):
|
||||
return [1]
|
||||
"""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def custom_renderer_config(tmp_path):
|
||||
from renderers import CustomRendererConfig
|
||||
|
||||
path = tmp_path / "effort_renderer.py"
|
||||
path.write_text(CUSTOM_RENDERER_SOURCE)
|
||||
return CustomRendererConfig(import_path=f"{path}:EffortRenderer")
|
||||
|
||||
|
||||
def test_renderer_resolver_applies_renderer_columns_to_custom_renderer(custom_renderer_config):
|
||||
resolver = sft_data.RendererResolver(tokenizer=None, config=custom_renderer_config)
|
||||
|
||||
default = resolver({"messages": [], "reasoning_effort": None})
|
||||
high = resolver({"messages": [], "reasoning_effort": "high"})
|
||||
|
||||
assert default.config.reasoning_effort == "low"
|
||||
assert high.config.reasoning_effort == "high"
|
||||
assert resolver({"messages": [], "reasoning_effort": "high"}) is high
|
||||
with pytest.raises(ValueError):
|
||||
resolver({"messages": [], "reasoning_effort": "medium"})
|
||||
|
||||
|
||||
def test_renderer_resolver_reads_mapped_columns(custom_renderer_config):
|
||||
resolver = sft_data.RendererResolver(
|
||||
tokenizer=None, config=custom_renderer_config, columns={"reasoning_effort": "effort"}
|
||||
)
|
||||
|
||||
assert resolver({"effort": "high", "reasoning_effort": "low"}).config.reasoning_effort == "high"
|
||||
assert resolver({"reasoning_effort": "high"}).config.reasoning_effort == "low"
|
||||
|
||||
|
||||
def test_renderer_resolver_rejects_renderer_columns_without_the_field():
|
||||
from renderers import PrimeQwen3RendererConfig
|
||||
|
||||
resolver = sft_data.RendererResolver(tokenizer=None, config=PrimeQwen3RendererConfig())
|
||||
|
||||
with pytest.raises(ValueError, match="reasoning_effort"):
|
||||
resolver({"messages": [], "reasoning_effort": "high"})
|
||||
|
||||
|
||||
def test_sft_dataset_reads_mapped_message_columns(dummy_renderer):
|
||||
from prime_rl.configs.sft import SFTColumnsConfig
|
||||
|
||||
dataset = Dataset.from_list([{"conversation": [{"role": "assistant", "content": "a0"}]}])
|
||||
|
||||
sample = next(
|
||||
iter(SFTDataset(dataset, lambda _: dummy_renderer, columns=SFTColumnsConfig(messages="conversation")))
|
||||
)
|
||||
assert sample["input_ids"] == [_BOS_TOKEN_ID, *_sample_token_ids("a0")]
|
||||
assert sample["target_ids"] == [*_sample_token_ids("a0"), _STOP_TOKEN_ID]
|
||||
|
||||
with pytest.raises(ValueError, match="'messages' column"):
|
||||
next(iter(SFTDataset(dataset, lambda _: dummy_renderer)))
|
||||
with pytest.raises(ValueError, match="data.columns.prompt"):
|
||||
SFTDataset(dataset, lambda _: dummy_renderer, columns=SFTColumnsConfig(prompt="question"))
|
||||
|
||||
|
||||
def test_sft_dataset_passes_tools_through_from_the_mapped_column(dummy_renderer):
|
||||
from prime_rl.configs.sft import SFTColumnsConfig
|
||||
|
||||
tools = [{"type": "function", "function": {"name": "lookup", "parameters": {"type": "object"}}}]
|
||||
dataset = Dataset.from_list(
|
||||
[{"messages": [{"role": "assistant", "content": "a0"}], "schemas": json.dumps(tools), "tools": []}]
|
||||
)
|
||||
seen: list = []
|
||||
|
||||
class RecordingRenderer:
|
||||
def render(self, messages, tools=None, **kwargs):
|
||||
seen.append(tools)
|
||||
return dummy_renderer.render(messages)
|
||||
|
||||
def get_stop_token_ids(self):
|
||||
return dummy_renderer.get_stop_token_ids()
|
||||
|
||||
next(iter(SFTDataset(dataset, lambda _: RecordingRenderer())))
|
||||
next(iter(SFTDataset(dataset, lambda _: RecordingRenderer(), columns=SFTColumnsConfig(tools="schemas"))))
|
||||
|
||||
assert seen == [[], tools]
|
||||
|
||||
@@ -17,26 +17,26 @@ exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for
|
||||
exclude-newer-span = "P7D"
|
||||
|
||||
[options.exclude-newer-package]
|
||||
deep-ep = false
|
||||
deep-gemm = false
|
||||
verifiers = false
|
||||
prime-pydantic-config = false
|
||||
harbor = "2026-08-11T00:00:00Z"
|
||||
prime-traces = false
|
||||
vllm-router = false
|
||||
dion = false
|
||||
fastokens = false
|
||||
flash-attn-3 = false
|
||||
harbor = "2026-08-11T00:00:00Z"
|
||||
nixl-cu13 = false
|
||||
prime = false
|
||||
prime-evals = false
|
||||
prime-kernels = false
|
||||
prime-pydantic-config = false
|
||||
prime-runs = false
|
||||
prime-sandboxes = false
|
||||
prime-traces = false
|
||||
flash-attn-3 = false
|
||||
prime-tunnel = false
|
||||
renderers = false
|
||||
tokenspeed-mla = false
|
||||
deep-gemm = false
|
||||
prime-evals = false
|
||||
torchao = false
|
||||
verifiers = false
|
||||
vllm-router = false
|
||||
tokenspeed-mla = false
|
||||
nixl-cu13 = false
|
||||
deep-ep = false
|
||||
prime-sandboxes = false
|
||||
renderers = false
|
||||
prime-kernels = false
|
||||
prime = false
|
||||
|
||||
[manifest]
|
||||
members = [
|
||||
@@ -68,6 +68,7 @@ members = [
|
||||
"graphwalks",
|
||||
"gsm8k",
|
||||
"hle",
|
||||
"hle-diamond",
|
||||
"humaneval",
|
||||
"i3-code",
|
||||
"i3-logic",
|
||||
@@ -107,16 +108,17 @@ members = [
|
||||
"patterned-needle-in-haystack",
|
||||
"pi-deepswe",
|
||||
"pi-officeqa-pro-v2",
|
||||
"pi-programbench",
|
||||
"pi-terminal-bench-2",
|
||||
"pinchbench",
|
||||
"prime-rl",
|
||||
"programbench-env",
|
||||
"prolog",
|
||||
"proofnet",
|
||||
"proposer-solver",
|
||||
"proverbench",
|
||||
"putnambench",
|
||||
"r2e-gym",
|
||||
"recursive-task-synthesis",
|
||||
"redsearcher",
|
||||
"reverse-text",
|
||||
"s1-deepresearch",
|
||||
@@ -2264,6 +2266,25 @@ requires-dist = [
|
||||
{ name = "verifiers", specifier = ">=0.3.1" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hle-diamond"
|
||||
version = "0.1.0"
|
||||
source = { editable = "deps/prime-envs/environments/knowledge/hle_diamond" }
|
||||
dependencies = [
|
||||
{ name = "datasets" },
|
||||
{ name = "httpx" },
|
||||
{ name = "pillow" },
|
||||
{ name = "verifiers" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "datasets", specifier = ">=4" },
|
||||
{ name = "httpx", specifier = ">=0.28" },
|
||||
{ name = "pillow", specifier = ">=12.3.0" },
|
||||
{ name = "verifiers", specifier = ">=0.3.2.dev160" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hpack"
|
||||
version = "4.2.0"
|
||||
@@ -2878,15 +2899,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437, upload-time = "2025-09-08T01:34:57.871Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "junitparser"
|
||||
version = "5.0.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/12/ed/063362ed6c5e39273879ba3db91da13b00551c6277de6842e45ab55a1a22/junitparser-5.0.1.tar.gz", hash = "sha256:45d100ca35ce5e2596c1f251de5e0f9411827aa93edaba7ad2d8eef423eecdd0", size = 12051, upload-time = "2026-06-05T03:55:55.888Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e5/32/15c6dd4267d530c38ca8b661c8322d201a6766087efd81ef81d3456e3cad/junitparser-5.0.1-py3-none-any.whl", hash = "sha256:019410471ac82c6b49c3cd500b930b3f39a5dae34e5ca5d5f719c4dcd9bb7e9a", size = 15014, upload-time = "2026-06-05T03:55:54.478Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jupyter-client"
|
||||
version = "8.8.0"
|
||||
@@ -4674,6 +4686,17 @@ requires-dist = [
|
||||
{ name = "verifiers", specifier = ">=0.3.1" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pi-programbench"
|
||||
version = "0.1.0"
|
||||
source = { editable = "deps/prime-envs/environments/code/pi_programbench" }
|
||||
dependencies = [
|
||||
{ name = "verifiers", extra = ["harbor"] },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [{ name = "verifiers", extras = ["harbor"], specifier = ">=0.3.2.dev165" }]
|
||||
|
||||
[[package]]
|
||||
name = "pi-terminal-bench-2"
|
||||
version = "0.1.0"
|
||||
@@ -4687,17 +4710,15 @@ requires-dist = [{ name = "verifiers", extras = ["harbor"], specifier = ">=0.3.1
|
||||
|
||||
[[package]]
|
||||
name = "pillow"
|
||||
version = "12.2.0"
|
||||
version = "12.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/8c/21/c2bcdd5906101a30244eaffc1b6e6ce71a31bd0742a01eb89e660ebfac2d/pillow-12.2.0.tar.gz", hash = "sha256:a830b1a40919539d07806aa58e1b114df53ddd43213d9c8b75847eee6c0182b5", size = 46987819, upload-time = "2026-04-01T14:46:17.687Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/1c/3d/bb7fca845737cf9d7dbde16ed1843984665ff2e0a518f5db43e77ec540b9/pillow-12.3.0.tar.gz", hash = "sha256:3b8182a766685eaa002637e28b4ec8d6b18819a0c71f579bf0dbaa5830297cce", size = 47025035, upload-time = "2026-07-01T11:56:38.965Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d8/95/0a351b9289c2b5cbde0bacd4a83ebc44023e835490a727b2a3bd60ddc0f4/pillow-12.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f3f40b3c5a968281fd507d519e444c35f0ff171237f4fdde090dd60699458421", size = 4695490, upload-time = "2026-04-01T14:43:15.584Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/de/af/4e8e6869cbed569d43c416fad3dc4ecb944cb5d9492defaed89ddd6fe871/pillow-12.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:03e7e372d5240cc23e9f07deca4d775c0817bffc641b01e9c3af208dbd300987", size = 6284462, upload-time = "2026-04-01T14:43:18.268Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/9e/c05e19657fd57841e476be1ab46c4d501bffbadbafdc31a6d665f8b737b6/pillow-12.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b86024e52a1b269467a802258c25521e6d742349d760728092e1bc2d135b4d76", size = 8094744, upload-time = "2026-04-01T14:43:20.716Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2b/54/1789c455ed10176066b6e7e6da1b01e50e36f94ba584dc68d9eebfe9156d/pillow-12.2.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7371b48c4fa448d20d2714c9a1f775a81155050d383333e0a6c15b1123dda005", size = 6398371, upload-time = "2026-04-01T14:43:23.443Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/43/e3/fdc657359e919462369869f1c9f0e973f353f9a9ee295a39b1fea8ee1a77/pillow-12.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:62f5409336adb0663b7caa0da5c7d9e7bdbaae9ce761d34669420c2a801b2780", size = 7087215, upload-time = "2026-04-01T14:43:26.758Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8b/f8/2f6825e441d5b1959d2ca5adec984210f1ec086435b0ed5f52c19b3b8a6e/pillow-12.2.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:01afa7cf67f74f09523699b4e88c73fb55c13346d212a59a2db1f86b0a63e8c5", size = 6509783, upload-time = "2026-04-01T14:43:29.56Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/67/f9/029a27095ad20f854f9dba026b3ea6428548316e057e6fc3545409e86651/pillow-12.2.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fc3d34d4a8fbec3e88a79b92e5465e0f9b842b628675850d860b8bd300b159f5", size = 7212112, upload-time = "2026-04-01T14:43:32.091Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d8/66/9a386a92561f402389a4fc70c18838bf6d35eb5eb5c6850b4b2dc64f5048/pillow-12.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ffd0c5368496f41b0944be820fcb7a838aa6e623d250b01acf2643939c3f99d7", size = 4780323, upload-time = "2026-07-01T11:54:09.351Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/25/27/ac8f99618ffd3dde21db0f4d4b1d2ab00c0880595bfd17df103f7f39fd0c/pillow-12.3.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d9c7f76c0673154f044e9d78c8655fb4213f6ca31a836df48b40fe5d187717b9", size = 6266838, upload-time = "2026-07-01T11:54:11.71Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/84/21/a35af28dcc61f37ed850a2d64c65c701321dfbf25085e469d5559360cbbf/pillow-12.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:78cb2c6865a35ab8ff8b75fd122f6033b92a62c82801110e48ddd6c936a45d91", size = 6940830, upload-time = "2026-07-01T11:54:13.732Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/eb/51/8b08617af3ad95e33ce6d7dd2c99ed6c8298f7fb131636303956be022e25/pillow-12.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e491916b378fba47242221bb9ead245211b70d504f495d105d17b14a24b4907c", size = 6344383, upload-time = "2026-07-01T11:54:15.756Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1d/72/cf78ac9780bb93c28328f408973845a309d4d145041665f734572ced1b52/pillow-12.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:0dd2064cbc55aaec028ef5fbb60fa47bb6c3e7918e07ff17935284b227a9d2df", size = 7052934, upload-time = "2026-07-01T11:54:17.721Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4964,6 +4985,7 @@ all = [
|
||||
{ name = "nvidia-ml-py", marker = "sys_platform == 'linux'" },
|
||||
{ name = "quack-kernels", marker = "sys_platform == 'linux'" },
|
||||
{ name = "ring-flash-attn", marker = "sys_platform == 'linux'" },
|
||||
{ name = "sonic-moe", marker = "sys_platform == 'linux'" },
|
||||
{ name = "tilelang" },
|
||||
{ name = "torch", version = "2.13.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'linux'" },
|
||||
{ name = "torch", version = "2.13.0+cu130", source = { registry = "https://download.pytorch.org/whl/cu130" }, marker = "sys_platform == 'linux'" },
|
||||
@@ -5033,6 +5055,9 @@ kernels = [
|
||||
quack = [
|
||||
{ name = "quack-kernels", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
sonic-moe = [
|
||||
{ name = "sonic-moe", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
|
||||
[package.dev-dependencies]
|
||||
dev = [
|
||||
@@ -5093,6 +5118,7 @@ requires-dist = [
|
||||
{ name = "prime-rl", extras = ["flash-attn-cute"], marker = "extra == 'all'" },
|
||||
{ name = "prime-rl", extras = ["gpu"], marker = "extra == 'all'" },
|
||||
{ name = "prime-rl", extras = ["quack"], marker = "extra == 'all'" },
|
||||
{ name = "prime-rl", extras = ["sonic-moe"], marker = "extra == 'all'" },
|
||||
{ name = "prime-rl-configs", editable = "packages/prime-rl-configs" },
|
||||
{ name = "prime-runs", extras = ["train"], specifier = ">=0.1.3" },
|
||||
{ name = "prometheus-client", specifier = ">=0.20.0" },
|
||||
@@ -5101,11 +5127,12 @@ requires-dist = [
|
||||
{ name = "pybase64", specifier = ">=1.4.2" },
|
||||
{ name = "pyzmq", specifier = ">=27.1.0" },
|
||||
{ name = "pyzstd", specifier = ">=0.16.2" },
|
||||
{ name = "quack-kernels", marker = "sys_platform == 'linux' and extra == 'quack'", specifier = ">=0.4.1" },
|
||||
{ name = "quack-kernels", marker = "sys_platform == 'linux' and extra == 'quack'", git = "https://github.com/S1ro1/quack?rev=f62009f" },
|
||||
{ name = "renderers", extras = ["multimodal"], editable = "deps/renderers" },
|
||||
{ name = "rich", specifier = ">=14.0.0" },
|
||||
{ name = "ring-flash-attn", marker = "sys_platform == 'linux' and extra == 'gpu'", specifier = ">=0.1.8" },
|
||||
{ name = "setproctitle", specifier = ">=1.3.0" },
|
||||
{ name = "sonic-moe", marker = "sys_platform == 'linux' and extra == 'sonic-moe'", git = "https://github.com/S1ro1/sonic-moe?rev=0bf06ac" },
|
||||
{ name = "tenacity", specifier = ">=8.2.0" },
|
||||
{ name = "tilelang", marker = "sys_platform == 'linux' and extra == 'gpu'", specifier = ">=0.1.8" },
|
||||
{ name = "torch", marker = "sys_platform == 'linux' and extra == 'gpu'", specifier = ">=2.13.0", index = "https://download.pytorch.org/whl/cu130" },
|
||||
@@ -5129,7 +5156,7 @@ requires-dist = [
|
||||
{ name = "wandb", specifier = ">=0.26.1" },
|
||||
{ name = "wandb-workspaces", specifier = ">=0.4.3" },
|
||||
]
|
||||
provides-extras = ["gpu", "dashboard", "dynamo", "flash-attn", "flash-attn-3", "flash-attn-cute", "disagg", "quack", "kernels", "all"]
|
||||
provides-extras = ["gpu", "dashboard", "dynamo", "flash-attn", "flash-attn-3", "flash-attn-cute", "disagg", "quack", "sonic-moe", "kernels", "all"]
|
||||
|
||||
[package.metadata.requires-dev]
|
||||
dev = [
|
||||
@@ -5230,44 +5257,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d0/7f/6ea38563db9414ed208758de6e8dc557b20e245787e42568f89531fc6717/prime_tunnel-0.1.11-py3-none-any.whl", hash = "sha256:19c5e02e389e5e61fff1507f07c46db9b05ad01424ff3b6a0cbe66187c957f61", size = 16676, upload-time = "2026-09-04T17:09:24.157Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "programbench"
|
||||
version = "1.2.3"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "huggingface-hub", version = "1.16.1", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'linux'" },
|
||||
{ name = "huggingface-hub", version = "1.32.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform == 'linux'" },
|
||||
{ name = "jinja2" },
|
||||
{ name = "junitparser" },
|
||||
{ name = "pydantic" },
|
||||
{ name = "pyyaml" },
|
||||
{ name = "rich" },
|
||||
{ name = "tqdm" },
|
||||
{ name = "typer" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/81/bd/6b9c812af45f35b1389110dcd9a10275281d9e31783a5b8e092e5e157558/programbench-1.2.3.tar.gz", hash = "sha256:adfd70c9bb2f840fb8e917bbf6694eaa0c9056b7ded9c4705289533c92a4c44a", size = 3291509, upload-time = "2026-06-29T15:25:39.889Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/b5/6f/43682764ca319706a599de89a0675cbe499a4fb351dc9a7b143a7a447803/programbench-1.2.3-py3-none-any.whl", hash = "sha256:214b1e16a5f62b3b0fb45d0b4beb6f5eb5958705ca9200b135c3fa0fc20d8ecd", size = 3446421, upload-time = "2026-06-29T15:25:38.297Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "programbench-env"
|
||||
version = "0.2.0"
|
||||
source = { editable = "deps/prime-envs/environments/code/programbench_env" }
|
||||
dependencies = [
|
||||
{ name = "huggingface-hub", version = "1.16.1", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'linux'" },
|
||||
{ name = "huggingface-hub", version = "1.32.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform == 'linux'" },
|
||||
{ name = "programbench" },
|
||||
{ name = "verifiers" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "huggingface-hub", specifier = ">=0.20" },
|
||||
{ name = "programbench", specifier = ">=1.0.2" },
|
||||
{ name = "verifiers", specifier = ">=0.3.1" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prolog"
|
||||
version = "0.5.1"
|
||||
@@ -5891,7 +5880,7 @@ wheels = [
|
||||
[[package]]
|
||||
name = "quack-kernels"
|
||||
version = "0.6.5"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
source = { git = "https://github.com/S1ro1/quack?rev=f62009f#f62009fae5bf325c50d2a17adc7e3397be672dd6" }
|
||||
dependencies = [
|
||||
{ name = "apache-tvm-ffi" },
|
||||
{ name = "einops" },
|
||||
@@ -5899,10 +5888,6 @@ dependencies = [
|
||||
{ name = "torch", version = "2.13.0+cu130", source = { registry = "https://download.pytorch.org/whl/cu130" } },
|
||||
{ name = "torch-c-dlpack-ext" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/5f/18/6c2a20d00dff254f154fb3b951f4e5a0377a60122c17385e5f08d5f5b5e1/quack_kernels-0.6.5.tar.gz", hash = "sha256:dd9405a4a6fa35fc3a5a18fe35b46a14b0bf7e3ad9fe2451903e355047ac471d", size = 846876, upload-time = "2026-09-11T05:08:20.621Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/73/d8/f5e56c38b286308d115a171e3c5c44f24e9d03980c3cfd22588df40261fa/quack_kernels-0.6.5-py3-none-any.whl", hash = "sha256:df1ddd31366c82eb9692fe087c671209189dcbde53c909c81a865d4ee66b158d", size = 729615, upload-time = "2026-09-11T05:08:19.306Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "qwen-agent"
|
||||
@@ -5977,6 +5962,23 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/13/60/164246615e8b059f6d53d34648a0784260421ec98a07eb1e45160f063221/realtime-2.31.0-py3-none-any.whl", hash = "sha256:f6e494b53d6a6e80b6efcee6711c8dd40413a52e766271de1bce8ced6c36cc1d", size = 22374, upload-time = "2026-06-04T13:37:21.162Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "recursive-task-synthesis"
|
||||
version = "0.1.2"
|
||||
source = { editable = "deps/prime-envs/environments/terminal/recursive_task_synthesis" }
|
||||
dependencies = [
|
||||
{ name = "httpx" },
|
||||
{ name = "pyarrow" },
|
||||
{ name = "verifiers", extra = ["harbor"] },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "httpx", specifier = ">=0.27" },
|
||||
{ name = "pyarrow", specifier = ">=17" },
|
||||
{ name = "verifiers", extras = ["harbor"], specifier = ">=0.3.1" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redsearcher"
|
||||
version = "0.1.0"
|
||||
@@ -6442,6 +6444,15 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sonic-moe"
|
||||
version = "0.1.2.post1"
|
||||
source = { git = "https://github.com/S1ro1/sonic-moe?rev=0bf06ac#0bf06ac7bf5b0800a7202743c1fb5722ed004350" }
|
||||
dependencies = [
|
||||
{ name = "quack-kernels" },
|
||||
{ name = "torch", version = "2.13.0+cu130", source = { registry = "https://download.pytorch.org/whl/cu130" } },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "soundfile"
|
||||
version = "0.14.0"
|
||||
@@ -6744,14 +6755,14 @@ requires-dist = [{ name = "verifiers", extras = ["harbor"], specifier = ">=0.3.1
|
||||
|
||||
[[package]]
|
||||
name = "swebench-pro"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = { editable = "deps/prime-envs/environments/swe/swebench_pro" }
|
||||
dependencies = [
|
||||
{ name = "verifiers", extra = ["harbor"] },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [{ name = "verifiers", extras = ["harbor"], specifier = ">=0.3.2.dev137" }]
|
||||
requires-dist = [{ name = "verifiers", extras = ["harbor"], specifier = ">=0.3.2.dev139" }]
|
||||
|
||||
[[package]]
|
||||
name = "swebench-verified"
|
||||
|
||||
Reference in New Issue
Block a user