Skip to content

Primus v26.4#172

Merged
gargrahul merged 2 commits into
ROCm:developfrom
gargrahul:gargrahul/primus_v26.4
Jun 30, 2026
Merged

Primus v26.4#172
gargrahul merged 2 commits into
ROCm:developfrom
gargrahul:gargrahul/primus_v26.4

Conversation

@gargrahul

Copy link
Copy Markdown
Collaborator

Add llama3.1 8B mxfp4/mxfp8 examples.
Update READMEs with torchtitan and Megatron.
Move to Rock based pytorch docker images. Modified logic to detect device type for rock images

Add llama3.1 8B mxfp4/mxfp8 examples.
Update READMEs with torchtitan and Megatron.
Move to Rock based pytorch docker images. Modified logic to detect device type for rock images
Copilot AI review requested due to automatic review settings June 29, 2026 20:10
@gargrahul
gargrahul requested a review from amathews-amd as a code owner June 29, 2026 20:10

Copilot AI left a comment

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.

Pull request overview

Updates the MAD/Primus benchmark and training tooling to align with Primus v26.4 (new base images), adds Llama 3.1 8B MXFP8/MXFP4 example coverage, and improves AMD device/ROCm CLI detection across Python and shell entrypoints (including ROCm SDK-in-venv layouts).

Changes:

  • Bump AMD training Docker base images to rocm/primus:v26.4 and refresh benchmark READMEs with updated component versions + new MXFP examples.
  • Add robust ROCm CLI discovery (ROCM_PATH/venv _rocm_sdk_devel/classic /opt/rocm) and use it for device detection and GPU enumeration.
  • Expand Primus Megatron-LM scripts to include MXFP8/MXFP4 options (with MI35x-specific handling).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tools/utils.py Adds get_rocm_bin_dir() and uses it for AMD GPU vendor detection, GPU count, and arch detection.
tools/run_models.py Adjusts AMD GPU info collection inside containers to be resilient to ROCm tool locations.
scripts/pytorch_train/pytorch_benchmark_report.sh Makes ROCm device detection work with ROCM_PATH/venv tool layouts via resolved ROCM_BIN.
scripts/primus/pytorch_train/primus_pytorch_benchmark_report.sh Same ROCm device detection update for Primus PyTorch benchmark report flow.
scripts/primus/megatron-lm/run.sh Adds ROCm CLI resolution + updates datatype selection (including MXFP8/MXFP4) per model/device.
scripts/primus/megatron-lm/primus_megatron-lm_benchmark_setup.sh Extends setup to patch in log parsing + Zebra-Llama FLOPs robustness changes.
scripts/primus/megatron-lm/primus_megatron-lm_benchmark_report.sh Adds MXFP datatype support + ROCm CLI resolution; adjusts training invocation for MXFP4.
scripts/megatron-lm/megatron-lm_benchmark_report.sh Aligns ROCm device detection with ROCM_PATH/venv tool layouts.
scripts/kvcache_transfer_bench/backends/common/utils.py Allows ROCm version discovery from ROCM_PATH in addition to /opt/rocm.
scripts/common/rocm_paths.sh Introduces a shared ROCm CLI resolution snippet for benchmark scripts.
docker/pytorch_train.ubuntu.amd.Dockerfile Bumps base image from v26.3 to v26.4.
docker/primus_pytorch_train.ubuntu.amd.Dockerfile Bumps base image from v26.3 to v26.4.
docker/primus_megatron_train.ubuntu.amd.Dockerfile Bumps base image from v26.3 to v26.4.
docker/megatron_train.ubuntu.amd.Dockerfile Switches base image to rocm/primus:v26.4.
benchmark/pytorch_train/README.md Updates referenced image tag + component versions for v26.4.
benchmark/megatron_lm/README.md Updates v26.4 versions and adds MXFP8/MXFP4 usage examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +142 to 145
elif [[ "$model" == "GPT-OSS-20B" || "$model" == "GPT-OSS-120B" || "$model" == "Qwen-3-30B" || "$model" == "Qwen-3-235B" ]]; then
datatypes=("BF16" "FP8")
elif [[ "$model" == "GPT-OSS-20B" || "$model" == "GPT-OSS-120B" || "$model" == "Qwen-3-30B" || "$model" == "Qwen-3-235B" ]]; then
datatypes=("BF16" "FP8")
+ LOG_INFO "[direct] Using Megatron log parser"
+
+ num_warmup=$(grep -m1 'lr_warmup_iters' "${TRAIN_LOG}" | sed -En 's/.*lr_warmup_iters[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
+ num_warmup=$(grep 'lr_warmup_iters' "${TRAIN_LOG}" | sed -En 's/.*lr_warmup_iters[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
+ LOG_INFO "[direct] Using Torchtitan log parser"
+
+ num_warmup=$(grep 'lr_scheduler.warmup_steps' "${TRAIN_LOG}" | sed -En 's/.*lr_scheduler.warmup_steps[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
+ num_warmup=$(grep 'lr_scheduler.warmup_steps' ${TRAIN_LOG} | sed -En 's/.*lr_scheduler.warmup_steps[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
+ LOG_INFO "[direct] Using Megatron log parser"
+
+ num_warmup=$(grep -m 1 'lr_warmup_iters' "${TRAIN_LOG}" | sed -En 's/.*lr_warmup_iters[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
+ num_warmup=$(grep 'lr_warmup_iters' "${TRAIN_LOG}" | sed -En 's/.*lr_warmup_iters[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
+ LOG_INFO "[direct] Using Torchtitan log parser"
+
+ num_warmup=$(grep -m 1 'lr_scheduler.warmup_steps' ${TRAIN_LOG} | sed -En 's/.*lr_scheduler.warmup_steps[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
+ num_warmup=$(grep 'lr_scheduler.warmup_steps' ${TRAIN_LOG} | sed -En 's/.*lr_scheduler.warmup_steps[^:]*:[[:space:]]*([0-9,]+).*/\1/p' | tr -d ',' 2>/dev/null)
Comment on lines +196 to +198
if [[ "$DATATYPE" == "MXFP8" || "$DATATYPE" == "MXFP4" ]]; then
echo "Error: Datatype $DATATYPE is not supported for $MODEL_REPO on $DEVICE. Only supported on MI355X/MI350X."
else
Comment on lines 876 to 879
bash runner/primus-cli direct \
--log_file /tmp/primus_$MODEL_REPO.log \
-- train pretrain \
--config $EXP 2>&1 | tee -a $TRAIN_LOG
Comment thread benchmark/megatron_lm/README.md Outdated
git clone --recurse-submodules https://github.com/AMD-AGI/Primus.git
cd Primus/
git checkout release/v26.3
git checkout 236cfa9

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.

Why not release/v26.4 or tag v26.4.0?

Signed-off-by: Gene Der Su <e870252314@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants