[CICD] Unify dependency-coupled CI across accelerator platforms - #1285
Merged
xmhubj merged 95 commits intoSep 15, 2026
Merged
Conversation
- Workaround for Python < 3.12: temporarily patch pyproject.toml - Fix verification logic to properly check megatron/__init__.py - Add detailed logging for debugging
…lows - Add cache restore and runtime installation steps to unit_tests_common.yml - Pass dependency cache keys and configs from all_tests_common.yml - Implement safe_get_world_size() locally for Megatron API compatibility - Reorganize all_tests.yml to group prepare+test jobs per platform This fixes the issue where prepared dependencies were not being used, causing tests to import old system-installed Megatron packages instead of the cached versions.
AlexMa616
requested review from
aoyulong,
heavyrain-lzy and
zhaoyinglia
as code owners
September 8, 2026 05:38
The prepare_dependencies workflow saves cache to relative paths (megatron-lm-fl-install, te-fl-wheel) but unit_tests was trying to restore from absolute paths (/opt/flagscale/deps/*), causing cache misses even when cache exists. Changed unit_tests_common.yml to: - Restore cache to the same relative paths as prepare workflow - Use GITHUB_WORKSPACE-based paths for runtime installation - Add existence checks before running install scripts
install_te_fl_runtime.sh expects TE_FL_WHEEL_DIR environment variable, not TE_FL_INSTALL_DIR.
- kunlunxin: use typing_extensions.override for Python 3.10 compatibility - musa: add onnxscript to TE-FL runtime dependencies - enflame: add onnxscript + patch flash_attn detection for torch_gcu
…nt conflicts - **Enflame**: Remove image pre-installed TE-FL before tests to prevent flash_attn import during pytest collection - **MUSA**: Remove image pre-installed TE-FL to prevent flash_attn import during Megatron-LM-FL installation verification - **MetaX**: Remove both megatron-core and TE-FL from image, plus PYTHONPATH cleanup for /opt/flagscale/deps and /workspace paths Root cause: All platforms have pre-installed old versions of dependencies in their images that take precedence over CI-built latest versions, causing import errors at different stages (build/test collection/runtime). Solution: Explicitly uninstall image pre-installed packages in setup scripts to ensure only CI-built versions are used.
…upport Add megatron-energon[av_decode]~=7.0 to runtime pip packages for all platforms: - Kunlunxin P800 - MUSA - Enflame (燧原) - MetaX Required by: - flagscale/train/megatron/train_qwen35.py - tests/unit_tests/train/megatron/test_qwen35_tokenizer.py - Future multimodal training functionality This resolves the ModuleNotFoundError for megatron.energon module.
Enflame image contains both old megatron-core and transformer-engine that interfere with CI-built versions, causing: - ImportError: cannot import name 'core' from 'megatron' - ModuleNotFoundError: No module named 'flash_attn_2_cuda' Now uninstall both packages, matching MetaX strategy.
Apply consistent dependency management to all platforms: Config changes (add megatron-energon): - CUDA: add megatron-energon[av_decode]~=7.0 - Ascend: add megatron-energon[av_decode]~=7.0 - Hygon: add megatron-energon[av_decode]~=7.0 Setup script changes (uninstall pre-installed deps): - Kunlunxin: uninstall megatron-core + transformer-engine - CUDA: uninstall megatron-core + transformer-engine - Ascend: uninstall megatron-core + transformer-engine - Hygon: uninstall megatron-core + transformer-engine This ensures: 1. All platforms have megatron-energon for qwen35 and multimodal support 2. All platforms uninstall pre-installed deps to avoid version conflicts 3. Consistent behavior across the entire CI pipeline
…brackets
YAML flow-style arrays cannot contain unescaped square brackets.
The package name megatron-energon[av_decode]~=7.0 was causing parser errors.
Changed from:
pip_packages: [flag-gems, sqlalchemy, megatron-energon[av_decode]~=7.0]
To:
pip_packages:
- flag-gems
- sqlalchemy
- "megatron-energon[av_decode]~=7.0"
Fixes 3 unit test failures:
- test_platform_source_refs_use_catalog[metax]
- test_declared_all_images_use_one_python_environment
- test_inference_images_include_serve_dependencies[metax]
Apply same YAML syntax fix as MetaX to avoid parser errors with
square brackets in package names.
Changed from:
pip_packages: [megatron-energon[av_decode]~=7.0]
To:
pip_packages:
- "megatron-energon[av_decode]~=7.0"
Affected files:
- .github/configs/cuda.yml (line 176)
- .github/configs/ascend.yml (line 143)
- .github/configs/hygon.yml (line 146)
- Add compatibility_patches.py to mock flash_attn_2_cuda for non-CUDA platforms - Apply patches in train_gpt.py before any heavy imports - Uninstall site-packages megatron-core before installing from PYTHONPATH - Install TE-FL with --no-deps to prevent pip from downgrading dependencies - Set PYTHONNOUSERSITE=1 to ensure PYTHONPATH priority - Add verification for cuda_graph_config module availability Fixes import errors on Enflame, MUSA, MetaX, and KunLunXin platforms. Prevents Megatron-Core downgrade from 0.18.2 to 0.17.1.
- Add noqa: F401 for flash_attn_2_cuda import check - Apply ruff format for code style consistency
- Move patch application to tests/conftest.py - Ensures flash_attn_2_cuda mock is active before any test module imports - Fixes ModuleNotFoundError in unit tests for Enflame, MUSA, MetaX, KunLunXin Previously patches were only applied in train_gpt.py, but unit tests import megatron modules directly without going through that entry point.
…ority - Place megatron-lm-fl-install at the front of PYTHONPATH - Prevents namespace conflict with flagscale/train/megatron/ - Set PYTHONNOUSERSITE=1 to block user site-packages interference Root cause: Python was finding flagscale/train/megatron/ first when importing 'megatron', which has no 'core' submodule, causing 'ImportError: cannot import name core from megatron'. Fixes: Enflame, KunLunXin ModuleNotFoundError for megatron.core.*
- Place megatron-lm-fl-install at front of PYTHONPATH - Set PYTHONNOUSERSITE=1 to block user site-packages - Mirrors the fix already applied to unit tests Without this, functional tests still have PROJECT_ROOT first, causing the same namespace conflict where flagscale/train/megatron/ shadows the real megatron-core package. Ensures ALL test types (unit, functional, benchmark, hetero_train, etc.) use consistent PYTHONPATH ordering.
AlexMa616
force-pushed
the
feat/dependency-coupling-all-platforms
branch
from
September 14, 2026 04:28
722b969 to
b136034
Compare
- Rename 18 files (6 platforms × 3 types) to include backend type
- Format: {platform}0_6b_tp1_pp1-{backend}.{yaml|json}
- Backend types:
• reference: ascend0, enflame0, musa0
• flagos: hygon0, metax0
• vendor: kunlunxin0
- Update internal references (train/exp_name/exp_dir) to match new names
This makes the TE backend preference explicit in filenames for better clarity.
Update case names in platform configs to include TE backend suffix: - reference: ascend0, enflame0, musa0 - flagos: hygon0, metax0 - vendor: kunlunxin0 This fixes the 'Config not found' error after benchmark file renaming.
- MetaX runner image does not have FlagGems installed - Using flagos backend requires FlagGems dependency - Switch to reference backend to align with other platforms (Ascend, MUSA)
Changes: - Rename metax0_6b_tp1_pp1-flagos.yaml → metax0_6b_tp1_pp1-reference.yaml - Update te_fl_prefer: flagos → reference - Update platform config reference in metax.yaml - Align with other platforms (Ascend, MUSA) using reference backend Reason: - MetaX runner image does not have FlagGems installed - flagos backend requires FlagGems dependency - reference backend works without additional dependencies
- Rename metax0_6b_tp1_pp1-flagos.json → metax0_6b_tp1_pp1-reference.json - Align with config file rename from flagos to reference backend
…tforms [Fix] Ascend get_device_arch_version() return None
zhaoyinglia
approved these changes
Sep 15, 2026
xmhubj
approved these changes
Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unify Megatron-LM-FL and TransformerEngine-FL dependency management and test execution across CUDA, Ascend, Enflame, Hygon, Kunlunxin, MetaX, and MUSA platforms.
Changes
Validation
Notes
This change keeps platform-specific behavior in platform configuration, environment setup, and dedicated workflow layers while preserving the common test runner interface.