Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modal_dojo/common/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
parse_inkling_response,
parse_qwen3_6_response,
)
from .deepseek_v41_flash import DeepSeek_V4_1_Flash
from .deepseek_v4_1_flash import DeepSeek_V4_1_Flash
from .gemma4_26b_a4b import Gemma4_26B_A4B
from .glm_4_7 import GLM_4_7
from .glm_5_3_flash import GLM_5_3_Flash, GLM_5_3_Flash_LoRA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Neither the indexer nor Engram is representable as a ``ModelArchitecture``, so
``architecture`` is left ``None`` and the Miles recipe renders upstream's
``scripts/models/deepseek-v4.1.py`` via ``miles_model_name`` — including its
``--spec miles_plugins.models.deepseek_v41.deepseek_v41 get_dsv41_spec``. Same
``--spec miles_plugins.models.deepseek_v4_1.deepseek_v4_1 get_dsv41_spec``. Same
arrangement as ``Qwen3_5_4B_Miles``.

The released checkpoint is fp8; Miles converts it to a bf16 torch_dist
Expand Down
2 changes: 1 addition & 1 deletion modal_dojo/common/models/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from ..framework import Framework
from .base import ModelConfig
from .deepseek_v41_flash import DeepSeek_V4_1_Flash
from .deepseek_v4_1_flash import DeepSeek_V4_1_Flash
from .gemma4_26b_a4b import Gemma4_26B_A4B
from .glm_4_7 import GLM_4_7
from .glm_5_3_flash import GLM_5_3_Flash_LoRA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ def _patch_file(path: Path) -> None:
print(f"Patched {path.name} with advantage-distribution reporting")


# radixark/miles#3248 moved log_utils.py under training_utils/metrics/.
_CANDIDATES = (
Path("/root/miles/miles/backends/training_utils/metrics/log_utils.py"),
Path("/root/miles/miles/backends/training_utils/log_utils.py"),
)


def main() -> None:
_patch_file(Path("/root/miles/miles/backends/training_utils/log_utils.py"))
_patch_file(next((p for p in _CANDIDATES if p.exists()), _CANDIDATES[-1]))


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
through cuMemCreate, which cannot reclaim that cache. Miles calls onload_kv
immediately after the checksum, so return the scratch memory to CUDA first.

Image: radixark/miles:dsv41-h200-ea751aac8
SGLang: 7e74b31b2668934cf89dbe15188a010fda381aba
Image: radixark/miles:dev-202610082133
SGLang: b84bec5761a6cdc8b1df86b9b89ead80a7a9bb02
"""

from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Use 64-bit offsets when SGLang hashes DeepSeek's large weight tensors.

The H200 image's post-sync checksum audit hashes every model tensor. Its
The image's post-sync checksum audit hashes every model tensor. Its
Triton hash kernel multiplies a signed 32-bit program ID by the tile size,
overflowing beyond 2**31 uint32 words (8 GiB) and reading invalid addresses.
Promote before multiplication; the intentional uint32 hash mixing stays intact.

Image: radixark/miles:dsv41-h200-ea751aac8
SGLang: 7e74b31b2668934cf89dbe15188a010fda381aba
Image: radixark/miles:dev-202610082133
SGLang: b84bec5761a6cdc8b1df86b9b89ead80a7a9bb02
"""

from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

Executed at image-build time via ``python3 <this file>``.

Image: radixark/miles:dsv41-h200-ea751aac8
SGLang: 7e74b31b2668934cf89dbe15188a010fda381aba
Image: radixark/miles:dev-202610082133
SGLang: b84bec5761a6cdc8b1df86b9b89ead80a7a9bb02
"""

import pathlib
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Wait for asynchronous router registration in the DeepSeek V4.1 image.
"""Wait for asynchronous router registration for the DeepSeek V4.1 recipe.

Miles' SGLangRouterApiClient treats HTTP 202 as completed registration. The
router is still discovering engine metadata at that point; a following weight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

Executed at image-build time via ``python3 <this file>``.

Image: radixark/miles:dsv41-h200-ea751aac8
SGLang: 7e74b31b2668934cf89dbe15188a010fda381aba
Image: radixark/miles:dev-202610082133
SGLang: b84bec5761a6cdc8b1df86b9b89ead80a7a9bb02
"""

import pathlib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@

from pathlib import Path

OLD = "str(round(g[0].get_reward_value(args), 1))"
NEW = "str(round(float(g[0].get_reward_value(args)), 1))"
# radixark/miles#3722 hoisted the reward into ``uniform_rewards`` but still
# buckets an int 1 as "1" and a float 1.0 as "1.0".
_ANCHORS = (
(
"str(round(g[0].get_reward_value(args), 1))",
"str(round(float(g[0].get_reward_value(args)), 1))",
),
(
"str(round(reward, 1)) for reward in uniform_rewards",
"str(round(float(reward), 1)) for reward in uniform_rewards",
),
)


def patch_source(source: str) -> str:
if NEW in source:
return source
if source.count(OLD) != 1:
raise ValueError("Miles zero-std reward bucket anchor changed")
return source.replace(OLD, NEW, 1)
for old, new in _ANCHORS:
if new in source:
return source
if source.count(old) == 1:
return source.replace(old, new, 1)
raise ValueError("Miles zero-std reward bucket anchor changed")


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion modal_dojo/train_recipes/miles_recipe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from modal_dojo.train_recipes.miles_recipe.recipe import MilesRecipe
from modal_dojo.train_recipes.miles_recipe.deepseek_v41_flash import (
from modal_dojo.train_recipes.miles_recipe.deepseek_v4_1_flash import (
DeepSeek_V4_1_Flash_Recipe,
)
from modal_dojo.train_recipes.miles_recipe.gemma4_26b_a4b import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""DeepSeek-V4.1-Flash GRPO recipe, ported from upstream's ``run_deepseek_v41.py``."""
"""DeepSeek-V4.1-Flash GRPO recipe, ported from upstream's ``run_deepseek_v4_1.py``."""

from dataclasses import field
from pathlib import Path
Expand All @@ -11,11 +11,10 @@
from modal_dojo.common.patches import encode_patch
from modal_dojo.train_recipes.miles_recipe.recipe import MilesRecipe

# The dedicated amd64/H200 image includes the DeepSeek sources together:
# miles ea751aac8, sglang 7e74b31b2, and Megatron-LM b0b23e198.
# Keep those bundled revisions instead of overlaying the older PR head and
# the arm64 deepseek-v41 image's SGLang tree. The named tag is outside miles'
# automatic dev/PR tag cleanup; the digest also prevents tag updates drifting.
# The standard multi-arch dev image carries DeepSeek-V4.1 on miles main:
# miles f5757caab (with the radixark/miles#3605-#3634 kernel stack),
# sglang-miles b84bec576, and Megatron-LM fd15ee20a. The digest pins it, since
# miles prunes old dated dev tags and the tag could otherwise drift.

# Node-local disk: 768 GiB stages the params-only save (~1.1 TB bf16 over 8
# nodes, so ~140 GB a node); 1.5 TiB holds the NVMe-streamed optimizer
Expand Down Expand Up @@ -43,12 +42,12 @@

# Build-time shims for gaps in the bundled sources; see each script's docstring.
_PATCHES = (
"patch_deepseek_v41_router_registration",
"patch_deepseek_v41_checksum_audit",
"patch_deepseek_v41_checksum_cache",
"patch_deepseek_v41_checksum_offsets",
"patch_deepseek_v41_fp4_dequant_block",
"patch_deepseek_v41_vision_topk_capture",
"patch_deepseek_v4_1_router_registration",
"patch_deepseek_v4_1_checksum_audit",
"patch_deepseek_v4_1_checksum_cache",
"patch_deepseek_v4_1_checksum_offsets",
"patch_deepseek_v4_1_fp4_dequant_block",
"patch_deepseek_v4_1_vision_topk_capture",
)


Expand All @@ -66,8 +65,8 @@ class DeepSeek_V4_1_Flash_Recipe(MilesRecipe):
model_config_class: ClassVar[type[ModelConfig]] = DeepSeek_V4_1_Flash

docker_image: str = (
"radixark/miles:dsv41-h200-ea751aac8@sha256:"
"eff12eb317af7021f637ab6bf21359164e27274ca07a3b2b3754dfa4c5d1bd66"
"radixark/miles:dev-202610082133@sha256:"
"9cf2ed11d587af9884c75344681cf4100b8025eb357cb4d09a063823d4d81975"
)
image_run_commands: list[str] = field(default_factory=_image_patches)
gpu_type: str = "H200"
Expand All @@ -80,7 +79,7 @@ class DeepSeek_V4_1_Flash_Recipe(MilesRecipe):
# ${MODEL_ARGS[@]} verbatim — including its --spec for the V4.1 layer spec.
miles_model_name: str = "deepseek-v4.1"
# Selects miles' megatron→HF weight mapping (miles/backends/megatron_utils/
# megatron_to_hf/deepseekv41.py).
# megatron_to_hf/deepseekv4_1.py).
model_name: str = "deepseekv41"
# Selects the miles (not sglang) V4.1 training implementation.
dsv4_impl: str = "miles"
Expand Down Expand Up @@ -115,6 +114,9 @@ class DeepSeek_V4_1_Flash_Recipe(MilesRecipe):
"SGLANG_HEALTH_CHECK_TIMEOUT": "900",
"SGLANG_DG_CACHE_DIR_PER_PROCESS": "1",
"SGLANG_OPT_FP8_WO_A_GEMM": "0",
# Upstream: the compensated mHC weight split caches derived weights
# that online weight updates cannot refresh.
"SGLANG_OPT_DEEPGEMM_HC_PRENORM": "0",
"SGLANG_OPT_FUSE_WQA_WKV": "0",
"SGLANG_DISABLE_MULTIMEM_AG": "1",
# Frozen Engram tables are omitted from weight sync. Keep them in
Expand All @@ -132,7 +134,7 @@ class DeepSeek_V4_1_Flash_Recipe(MilesRecipe):

# ── Checkpoints ──────────────────────────────────────────────────────────
# "raw" turns on the HF → torch_dist conversion that upstream runs as
# `run_deepseek_v41.py prepare-spmd`; miles then loads it as ref_load.
# `run_deepseek_v4_1.py prepare-spmd`; miles then loads it as ref_load.
megatron_to_hf_mode: str = "raw"
ref_load: str = "/checkpoints/DeepSeek-V4.1-Flash_torch_dist"

Expand Down
2 changes: 1 addition & 1 deletion modal_dojo/train_recipes/miles_recipe/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def train_async(self) -> bool:

@classmethod
def get_base_recipe(cls, model_config: ModelConfig) -> "MilesRecipe | None":
from modal_dojo.train_recipes.miles_recipe.deepseek_v41_flash import (
from modal_dojo.train_recipes.miles_recipe.deepseek_v4_1_flash import (
DeepSeek_V4_1_Flash_Recipe,
)
from modal_dojo.train_recipes.miles_recipe.gemma4_26b_a4b import (
Expand Down
Loading