Skip to content
Open
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
15 changes: 15 additions & 0 deletions tests/e2e/megatron/test_glm47_flash/_common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import os
from dataclasses import dataclass

import torch

import miles.utils.external_utils.command_utils as U

MODEL_NAME = "GLM-4.7-Flash"
MODEL_TYPE = "glm4.7-flash"

TIGHT_HOST_MEMORY = bool(int(os.environ.get("MILES_TEST_TIGHT_HOST_MEMORY", "1")))
IS_ROCM = torch.version.hip is not None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Accessing torch.version.hip directly can raise an AttributeError on certain PyTorch builds or older versions where the hip attribute is not defined on the torch.version module. Using getattr is a safer and more robust way to check for ROCm/HIP support.

Suggested change
IS_ROCM = torch.version.hip is not None
IS_ROCM = getattr(torch.version, "hip", None) is not None



@dataclass
Expand Down Expand Up @@ -125,6 +128,8 @@ def build_train_args(case: CaseConfig, *, wandb_file: str) -> str:
"--sglang-speculative-eagle-topk 1 "
"--sglang-speculative-num-draft-tokens 3 "
)
if IS_ROCM:
sglang_args += "--use-miles-router "

if case.use_deepep:
sglang_args += "--sglang-moe-a2a-backend deepep --sglang-deepep-mode auto "
Expand All @@ -134,6 +139,8 @@ def build_train_args(case: CaseConfig, *, wandb_file: str) -> str:
mtp_args = "--enable-mtp-training " "--mtp-loss-scaling-factor 0.2 "

ci_args = "--ci-test "
if IS_ROCM:
ci_args += "--ci-disable-logprobs-checker "

misc_args = (
"--attention-dropout 0.0 "
Expand Down Expand Up @@ -173,8 +180,16 @@ def execute(case: CaseConfig, *, wandb_file: str) -> None:

train_args = build_train_args(case, wandb_file=wandb_file)

extra_env_vars = None
if IS_ROCM:
extra_env_vars = {
"SGLANG_USE_AITER": "0",
"MILES_TEST_R3_THRESHOLD": "1.0",
}

U.execute_train(
train_args=train_args,
num_gpus_per_node=case.num_gpus_per_node,
megatron_model_type=MODEL_TYPE,
extra_env_vars=extra_env_vars,
)