Skip to content

Commit ebcfadc

Browse files
qqjxzxq爱洗澡 qqzhoujiameiBrianPei
authored
[CICD] support Metax MACA workflow (flagos-ai#48)
# Description This PR implements and integrates the **Metax (MACA)** workflow into TransformerEngine-FL. It enables automated CI/CD pipelines, functional training tests, and unit tests specifically optimized for Metax hardware environments. **Key updates in this version:** Successful TE compilation on Metax and alignment with NVIDIA's standard QA workflows. Fixes # (issue_number_if_applicable) ## Type of change - [x] New feature (non-breaking change which adds functionality) - [x] Infra/Build change (changes to CI/CD workflows or build scripts) - [ ] Documentation change - [ ] Bug fix - [ ] Code refactoring ## Changes ### 1. Build & Compilation - **TE Build Completion**: Successfully completed the compilation and build process for TransformerEngine on the Metax platform. - **Workflow Alignment**: Designed the Metax testing workflow based on NVIDIA's `qa-l0-te-cpp-unittest-pytorch-lint` standard to ensure parity with upstream quality gates. ### 2. CI/CD Infrastructure & Test Modules - **Metax Platform Support**: Added `configs/metax.yml` to define Metax-specific runner labels, images, and device configurations. - **Verified Workflow Modules**: The following modules have been implemented and verified on the Metax platform: - **pytorch-lint**: Static code analysis and linting. - **pytorch-debug**: Debug-level build and basic functional verification. - **pytorch-unittest**: Core unit testing for Metax-adapted operators. - **Workflow Modularization**: - Introduced `configs/all_tests_common.yml` and `configs/unit_tests_common.yml` for reusable test logic. - Added `configs/all_tests_metax.yml` as the dedicated entry point for Metax functional testing. ### 3. Environment & Runtime Fixes - **Image Management**: Implemented `image-pull-policy: never` and `--pull never` options to force the use of local registry images (localhost:5000), optimizing startup time in local cluster environments. - **Dynamic Resource Scaling**: - Adapted `torchrun` and training scripts to support dynamic GPU/Accelerator counts (specifically for C500 clusters). - Removed hardcoded GPU host configurations to improve portability across different Metax nodes. ### 4. Cleanup - Removed legacy CUDA/Ascend specific configurations from the Metax workflow path to prevent environment contamination. ## Hardware/Environment Verified - **Platform**: Metax MACA - **Accelerator**: C500 - **Registry**: Local Registry (localhost:5000) --- ## TODO / Next Steps - [ ] Integrate the Metax-specific adaptation workflow into the central platform. - [ ] Generate and upload comprehensive Benchmark and Performance test reports. # Checklist: - [x] I have read and followed the contributing guidelines. - [x] The functionality is complete and verified on Metax hardware. - [x] I have commented my code, particularly in hardware-specific adaptation areas. - [x] My changes generate no new warnings. - [x] I have added/updated tests that prove my feature works on the MACA platform. - [x] New and existing unit tests (Lint, Debug, Unittest) pass locally with Metax environment. --------- Co-authored-by: 爱洗澡 qq <aixizaoqq@aixizaodeMacBook-Air.local> Co-authored-by: zhoujiamei <2867770387@qq.com> Co-authored-by: zhoujiamei <zjm> Co-authored-by: peiyu <peiyu@jinglong.ai>
1 parent 2188137 commit ebcfadc

20 files changed

Lines changed: 1133 additions & 62 deletions

.github/configs/ascend.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Huawei Ascend NPU configuration
2+
image: ascend-infer:ubuntu18.04
3+
labels:
4+
- npu
5+
- ascend
6+
docker_options: |
7+
--device /dev/davinci0
8+
--device /dev/davinci1
9+
--device /dev/davinci2
10+
--device /dev/davinci3
11+
--device /dev/davinci_manager
12+
--device /dev/devmm_svm
13+
--device /dev/hisi_hdc
14+
--volume /usr/local/Ascend/driver:/usr/local/Ascend/driver
15+
--volume /usr/local/Ascend/add-ons:/usr/local/Ascend/add-ons

.github/configs/cuda.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# CUDA Hardware Configuration for TransformerEngine-FL
2+
# Refactored for BAAI DGX A100 Nodes
3+
# This file defines environment variables, volumes, and test filters for TE tests.
4+
5+
hardware_name: cuda
6+
display_name: 'NVIDIA CUDA (A100)'
7+
8+
ci_image: harbor.baai.ac.cn/flagscale/cuda12.8.1-torch2.7.1-python3.10-te2.9:20260209
9+
10+
# Runner labels for self-hosted A100 node
11+
runner_labels:
12+
- self-hosted
13+
- Linux
14+
- X64
15+
- nvidia
16+
- gpu-8
17+
18+
# Container volumes
19+
container_volumes:
20+
- /home/flagscale_cicd/flask/static:/workspace/report
21+
# - .:/opt/transformerengine
22+
# - ./ci_logs:/logs
23+
# - /home/flagscale_cicd/data:/opt/data
24+
25+
# Container options
26+
container_options: >-
27+
--privileged
28+
--gpus all
29+
--shm-size=500g
30+
--ipc=host
31+
--ulimit memlock=-1
32+
--ulimit stack=67108864
33+
--user root
34+
35+
# Device types
36+
device_types:
37+
- a100
38+
39+
# Build environment variables (platform-specific)
40+
build_env:
41+
TE_FL_SKIP_CUDA: '0'
42+
SKIP_CUDA_BUILD: '0'
43+
NVTE_WITH_CUDA: '1'
44+
NVTE_WITH_MACA: '0'
45+
TE_WITH_NCCL: '1'
46+
NVTE_FRAMEWORK: pytorch
47+
CUDA_HOME: /usr/local/cuda-12.8
48+
NVCC: /usr/local/cuda-12.8/bin/nvcc
49+
50+
# Test matrix configuration
51+
test_matrix:
52+
l0_pytorch:
53+
path: 'qa/L0_pytorch_unittest/test.sh'
54+
ignored_tests:
55+
- test_sanity_layernorm_mlp
56+
- test_sanity_gpt
57+
- test_sanity_bert
58+
- test_sanity_T5
59+
- test_sanity_amp_and_nvfuser
60+
- test_sanity_drop_path
61+
- test_layernorm_mlp_accuracy
62+
- test_grouped_linear_accuracy
63+
- test_gpt_accuracy
64+
- test_basic_linear
65+
- test_layer_norm

.github/configs/metax.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Metax Hardware Configuration for TE-FL
2+
# This file defines CI/CD settings for Metax-based testing
3+
# Test configurations are defined in tests/test_utils/config/platforms/metax.yaml
4+
5+
hardware_name: metax
6+
display_name: 'Metax Tests'
7+
8+
ci_image: localhost:5000/megatron-lm-with-te:v1
9+
10+
runner_labels:
11+
- self-hosted
12+
- Linux
13+
- X64
14+
- metax
15+
- dev
16+
17+
container_volumes:
18+
- /nfs/metax_fs:/nfs/metax_fs
19+
- /dev/dri:/dev/dri
20+
- /dev/mxcd:/dev/mxcd
21+
- /dev/infiniband:/dev/infiniband
22+
23+
container_options: >-
24+
--uts=host
25+
--ipc=host
26+
--privileged=true
27+
--group-add video
28+
--shm-size=100gb
29+
--ulimit memlock=-1
30+
--security-opt seccomp=unconfined
31+
--security-opt apparmor=unconfined
32+
--device=/dev/dri
33+
--device=/dev/mxcd
34+
--device=/dev/infiniband
35+
--user root
36+
--ulimit nofile=65535:65535
37+
-e PLATFORM=metax
38+
-e TORCH_DISTRIBUTED_BACKEND=mccl
39+
-e LD_LIBRARY_PATH=/opt/maca/lib:/usr/local/lib:$LD_LIBRARY_PATH
40+
41+
build_env:
42+
TE_FL_SKIP_CUDA: '1'
43+
NVTE_WITH_MACA: '1'
44+
CUDA_HOME: /opt/maca
45+
MACA_HOME: /opt/maca
46+
47+
# Device types to run tests on
48+
device_types:
49+
- c500
50+
51+
# Test matrix configuration
52+
test_matrix:
53+
unit:
54+
devices:
55+
- c500
56+
# Ignored test files for unit tests
57+
# These files will be skipped when running pytest
58+
ignored_tests:
59+
# example: tests/unit_tests/test_example.py
60+
# - tests/unit_tests/test_inference.py
61+
# - tests/unit_tests/test_rl_utils.py
62+
63+
# functional:
64+
# train:
65+
# - device: c500
66+
# task: train
67+
# model: deepseek
68+
# case: tp2_pp2_ep2

.github/configs/template.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Configuration Template
2+
# This file describes the structure for hardware-specific configurations.
3+
#
4+
# Fields:
5+
# - image: Docker image to use for the runner
6+
# - labels: List of labels for the runner
7+
# - docker_options: Additional Docker options for mounting devices, volumes, etc.
8+
#
9+
# Example:
10+
# image: <docker_image>
11+
# labels:
12+
# - <label1>
13+
# - <label2>
14+
# docker_options: |
15+
# --option1 value1
16+
# --option2 value2
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: ascend_tests
2+
3+
on:
4+
# push:
5+
# branches: ["main"]
6+
# pull_request:
7+
# branches: ["main"]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.actor }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
run_tests:
16+
# Package manager and environment settings are read from .github/configs/ascend.yml
17+
uses: ./.github/workflows/all_tests_common.yml
18+
with:
19+
platform: ascend
20+
21+
all_tests:
22+
needs: run_tests
23+
runs-on: ubuntu-latest
24+
if: always()
25+
steps:
26+
- name: Verify workflow status
27+
run: |
28+
if [ "${{ needs.run_tests.result }}" != "success" ]; then
29+
echo "❌ Tests workflow failed"
30+
exit 1
31+
fi
32+
echo "✅ All tests passed!"
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Common All Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
platform:
7+
required: true
8+
type: string
9+
description: Platform name (e.g., cuda, default)
10+
setup_commands:
11+
required: false
12+
type: string
13+
default: ''
14+
15+
jobs:
16+
checkout_and_config:
17+
defaults:
18+
run:
19+
shell: bash
20+
runs-on: ubuntu-latest
21+
outputs:
22+
ci_image: ${{ steps.config.outputs.ci_image }}
23+
runs_on: ${{ steps.config.outputs.runs_on }}
24+
container_volumes: ${{ steps.config.outputs.container_volumes }}
25+
container_options: ${{ steps.config.outputs.container_options }}
26+
device_types: ${{ steps.config.outputs.device_types }}
27+
train_test_matrix: ${{ steps.config.outputs.train_test_matrix }}
28+
ignored_tests: ${{ steps.config.outputs.ignored_tests }}
29+
build_env: ${{ steps.config.outputs.build_env }}
30+
steps:
31+
- name: Checkout source code
32+
uses: actions/checkout@v4
33+
34+
- name: Check if tests should run
35+
id: should_run
36+
run: |
37+
38+
echo "should_run=true" >> $GITHUB_OUTPUT
39+
40+
- name: Load platform configuration
41+
id: config
42+
run: |
43+
set -euo pipefail
44+
45+
PLATFORM="${{ inputs.platform }}"
46+
CONFIG_FILE=".github/configs/${PLATFORM}.yml"
47+
48+
# Install mikefarah/yq (v4) for YAML parsing
49+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_amd64
50+
sudo chmod +x /usr/local/bin/yq
51+
/usr/local/bin/yq --version
52+
echo "Loading configuration from $CONFIG_FILE"
53+
54+
# Read CI image
55+
CI_IMAGE=$(yq '.ci_image' "$CONFIG_FILE")
56+
echo "ci_image=$CI_IMAGE" >> $GITHUB_OUTPUT
57+
58+
# Read runner labels and format as JSON array
59+
RUNS_ON=$(yq '.runner_labels | tojson(0)' "$CONFIG_FILE")
60+
echo "runs_on=$RUNS_ON" >> $GITHUB_OUTPUT
61+
62+
# Read container volumes and format as JSON array
63+
VOLUMES=$(yq '.container_volumes | tojson(0)' "$CONFIG_FILE")
64+
echo "container_volumes=$VOLUMES" >> $GITHUB_OUTPUT
65+
66+
# Read container options
67+
OPTIONS=$(yq '.container_options' "$CONFIG_FILE")
68+
echo "container_options=$OPTIONS" >> $GITHUB_OUTPUT
69+
70+
# Read device types
71+
DEVICE_TYPES=$(yq '.device_types | tojson(0)' "$CONFIG_FILE")
72+
echo "device_types=$DEVICE_TYPES" >> $GITHUB_OUTPUT
73+
74+
# Read test matrix for training
75+
TRAIN_MATRIX=$(yq '.test_matrix.functional.train | tojson(0)' "$CONFIG_FILE")
76+
echo "train_test_matrix=$TRAIN_MATRIX" >> $GITHUB_OUTPUT
77+
78+
# Read ignored tests list from test_matrix.unit (default to empty array if not defined)
79+
IGNORED_TESTS=$(yq '.test_matrix.unit.ignored_tests // [] | tojson(0)' "$CONFIG_FILE")
80+
echo "ignored_tests=$IGNORED_TESTS" >> $GITHUB_OUTPUT
81+
82+
# Read build environment variables (default to empty object if not defined)
83+
BUILD_ENV=$(yq '.build_env // {} | tojson(0)' "$CONFIG_FILE")
84+
echo "build_env=$BUILD_ENV" >> $GITHUB_OUTPUT
85+
86+
unit_tests:
87+
needs: checkout_and_config
88+
strategy:
89+
fail-fast: false
90+
matrix:
91+
device: ${{ fromJson(needs.checkout_and_config.outputs.device_types) }}
92+
uses: ./.github/workflows/unit_tests_common.yml
93+
name: unit_tests
94+
with:
95+
setup_commands: ${{ inputs.setup_commands }}
96+
platform: ${{ inputs.platform }}
97+
device: ${{ matrix.device }}
98+
image: ${{ needs.checkout_and_config.outputs.ci_image }}
99+
runs_on: ${{ needs.checkout_and_config.outputs.runs_on }}
100+
container_volumes: ${{ needs.checkout_and_config.outputs.container_volumes }}
101+
container_options: ${{ needs.checkout_and_config.outputs.container_options }}
102+
ignored_tests: ${{ needs.checkout_and_config.outputs.ignored_tests }}
103+
build_env: ${{ needs.checkout_and_config.outputs.build_env }}
104+
105+
# arguments.py not compatible with megatron-core-fl
106+
# functional_tests:
107+
# needs:
108+
# - checkout_and_config
109+
# if: fromJson(needs.checkout_and_config.outputs.train_test_matrix)[0] != null
110+
# uses: ./.github/workflows/functional_tests_common.yml
111+
# with:
112+
# platform: ${{ inputs.platform }}
113+
# test_matrix: ${{ needs.checkout_and_config.outputs.train_test_matrix }}
114+
# image: ${{ needs.checkout_and_config.outputs.ci_image }}
115+
# runs_on: ${{ needs.checkout_and_config.outputs.runs_on }}
116+
# container_volumes: ${{ needs.checkout_and_config.outputs.container_volumes }}
117+
# container_options: ${{ needs.checkout_and_config.outputs.container_options }}
118+
119+
120+
all_tests_complete:
121+
defaults:
122+
run:
123+
shell: bash
124+
needs:
125+
- checkout_and_config
126+
- unit_tests
127+
# - functional_tests
128+
runs-on: ubuntu-latest
129+
if: always()
130+
steps:
131+
- name: Verify all tests passed
132+
run: |
133+
# Check all test jobs (skip if not run)
134+
failed=false
135+
136+
if [ "${{ needs.unit_tests.result }}" != "success" ]; then
137+
echo "❌ Unit tests failed"
138+
failed=true
139+
fi
140+
141+
# if [ "${{ needs.functional_tests.result }}" != "success" ]; then
142+
# echo "❌ Training functional tests failed"
143+
# failed=true
144+
# fi
145+
146+
if [ "$failed" = "true" ]; then
147+
exit 1
148+
fi
149+
150+
echo "✅ All tests completed successfully!"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: cuda_tests
2+
3+
on:
4+
# push:
5+
# branches: ["main"]
6+
# pull_request:
7+
# branches: ["main"]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.actor }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
run_tests:
16+
# Package manager and environment settings are read from .github/configs/cuda.yml
17+
uses: ./.github/workflows/all_tests_common.yml
18+
with:
19+
platform: cuda
20+
21+
all_tests:
22+
needs: run_tests
23+
runs-on: ubuntu-latest
24+
if: always()
25+
steps:
26+
- name: Verify workflow status
27+
run: |
28+
if [ "${{ needs.run_tests.result }}" != "success" ]; then
29+
echo "❌ Tests workflow failed"
30+
exit 1
31+
fi
32+
echo "✅ All tests passed!"

0 commit comments

Comments
 (0)