Megatron
The Megatron app image is built on top of a flagos-runtime image and
packages a usable megatron-core library for megatron-lm based training.
Ready-to-run images are published per backend — see the Application images catalog or the individual per-backend pages for image references and launch commands.
Build arguments
| Argument | Default | Description |
|---|---|---|
RUNTIME_IMAGE | (required) | Runtime image ref, e.g. harbor.baai.ac.cn/flagos-runtime/flagos-runtime-hygon-dtk26.04:2.1.2 |
MEGATRON_VERSION | 0.17.1 | megatron-core version to install. A wheel of that version must exist on FLAGOS_PYPI. |
FLAGOS_PYPI | "" | Vendor PyPI index — hosts the megatron-core wheel. Searched first. |
EXTRA_PYPI | https://mirrors.aliyun.com/pypi/simple | Aliyun mirror — fallback for all other dependencies. |
APP_DEPS | "" | Vendor-conditional packages for this app (configs.yaml deps_app.{app}), space-separated. Installed before the wheel from the vendor PyPI — index isolation so a vendor package can’t be re-resolved from the mirror. Empty for apps with no vendor packages on this backend. |
APP_ENV | "" | Per-backend app env vars (configs.yaml env.app.{app}), baked into /etc/profile.d/app_env.sh. |
megatron-core wheel
megatron-core’s direct dependency surface is tiny (torch>=2.6.0, numpy,
packaging>=24.2) and the wheel keeps those declarations as-is — no repack,
no METADATA surgery. On every supported backend the runtime’s vendor torch is
= 2.7.1, which satisfies the
torch>=2.6.0Requires-Dist, so pip resolves nothing and overwrites nothing.
During pip install, the vendor PyPI is searched first — the wheel is found
and used. All remaining (safe) dependencies are resolved from EXTRA_PYPI.
Torch is already in the runtime venv and satisfies any transitive
constraints, so pip skips it. The install is a single-step
pip install (no --no-deps).
The wheel is built by packaging/megatron/builder/ from the Megatron-LM-FL
fork — inside the backend’s own runtime image, so build env == delivery
env and the single-step install is proven inert at build time (per-Python
cp310/cp311/cp312 wheels — the package ships a compiled helpers_cpp
extension; the fork’s requires-python >=3.12 is relaxed to >=3.10 on the
fly at build time). See packaging/megatron/builder/README.md.
Build example
docker build \
--build-arg RUNTIME_IMAGE=harbor.baai.ac.cn/flagos-runtime/flagos-runtime-hygon-dtk26.04:2.1.2 \
--build-arg FLAGOS_PYPI=https://resource.flagos.net/repository/flagos-pypi-hygon/simple \
-t harbor.baai.ac.cn/flagos-app/megatron_training0.17.1-hygon-dtk26.04:2.1.2-0.2.1 \
-f app/megatron/Containerfile.megatron-training .
# RL app: -f app/megatron/Containerfile.rl, tag megatron_rl0.17.1-{vendor}-{backend}:2.1.2-0.2.1
Last updated 23 Aug 2026, 12:04 +0800.