Skip to content

megatron

Megatron / NeMo integration for Stained Glass noise training.

This subpackage ports the Stained Glass noise-distillation stack onto NVIDIA Megatron-Core / Megatron-Bridge. It targets the NeMo container runtime (nvcr.io/nvidia/nemo:26.06.00); the heavy Megatron dependencies are provided by that image rather than installed from PyPI (see Dockerfile.megatron and requirements/megatron.txt).

Supported topology: tensor parallel (TP) + context parallel (CP). Pipeline parallel (PP) is not supported.

Importing this subpackage is always safe, even without the Megatron runtime: heavy imports are deferred (PEP 562) until a Megatron-backed symbol is accessed, at which point a clear ImportError is raised if the runtime is missing. Use is_megatron_available to probe the environment without triggering an error.

Functions:

Name Description
is_megatron_available

Return whether the Megatron/NeMo runtime is available in this environment.

missing_modules

Return the required Megatron modules that are not importable here.

require_megatron

Raise a helpful error if the Megatron/NeMo runtime is unavailable.

__dir__

__dir__() -> list[str]

Return the package's public attributes, including lazy exports.

Returns:

Type Description
list[str]

The sorted union of eagerly-defined names and lazy export names.

__getattr__

__getattr__(name: str) -> Any

Lazily import Megatron-backed public symbols (PEP 562).

Parameters:

Name Type Description Default

name

str

The attribute being accessed on this package.

required

Returns:

Type Description
Any

The requested attribute, imported from its backing submodule.

Raises:

Type Description
ImportError

If the symbol requires the Megatron runtime and it is unavailable.

AttributeError

If name is not a known export.

is_megatron_available

is_megatron_available() -> bool

Return whether the Megatron/NeMo runtime is available in this environment.

Returns:

Type Description
bool

True if every module in REQUIRED_MODULES is importable.

missing_modules

missing_modules() -> tuple[str, ...]

Return the required Megatron modules that are not importable here.

Returns:

Type Description
tuple[str, ...]

The subset of REQUIRED_MODULES that cannot be located in the

tuple[str, ...]

current environment, in declaration order.

require_megatron

require_megatron() -> None

Raise a helpful error if the Megatron/NeMo runtime is unavailable.

Raises:

Type Description
ImportError

If any module in REQUIRED_MODULES cannot be located, with an actionable message pointing at the NeMo container.