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.

Build arguments

ArgumentDefaultDescription
RUNTIME_IMAGE(required)Runtime image ref, e.g. harbor.baai.ac.cn/flagos-runtime/flagos-runtime-hygon-dtk26.04:2.1.2
MEGATRON_VERSION0.17.1megatron-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_PYPIhttps://mirrors.aliyun.com/pypi/simpleAliyun mirror — fallback for all other dependencies.

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.0 Requires-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-hygon-dtk26.04:2.1.2 \
  -f app/megatron/Containerfile .
  

Last updated 15 Aug 2026, 10:13 +0800. history