nemo_automodel.components.models.minimax_m3_vl.msa_bindings

View as Markdown

Bindings to official MiniMax-AI/MSA (the revision the msa extra pins) and to the local SM100 backward.

kernels() is the one place MSA reaches outside this package. It binds the four official entry points and the local backward launcher on first use, applies the two compatibility patches the pin needs, and caches the bundle for the process. Nothing is imported while this module loads, so it imports on any host; a host without the msa extra learns so from UnavailableError at the first call and never earlier, which is the contract the CI import walker checks.

Two unrelated kinds of patch live here, and they must not be confused:

  • _patch_fmax changes numerical behaviour — it rebinds a scalar helper so the CuTe DSL 4.6.2 binding is used instead of one that only exists under an older CUDA flavour.
  • _patch_jit_gencode changes build behaviour only — it drops a device target the local nvcc cannot parse. It never touches what the compiled kernels compute.

Both are removed once the pinned MSA revision carries the fix upstream.

Module Contents

Classes

NameDescription
MSAKernelsThe launchers MSA calls: the official CSR builder, flat forward, scorer and planner, and the local backward.

Functions

NameDescription
_nvcc_releaseReturn the (major, minor) release of the nvcc that MSA’s JIT will invoke.
_patch_fmaxPatch only the loaded MSA-owned utils before JIT; preserve fp32, third operand and loc/ip.
_patch_jit_gencodeDrop the sm_103a target from MSA’s own JIT flags when the local nvcc cannot parse it.
kernelsBind the MSA launchers once per process, patching the official package on the way.

Data

_BACKWARD_MODULE

_MIN_SM103A_NVCC

_MSA_IMPORT_ERROR

_SM103A_TARGET

API

class nemo_automodel.components.models.minimax_m3_vl.msa_bindings.MSAKernels(
build_k2q_csr: collections.abc.Callable[..., typing.Any],
sparse_atten_func: collections.abc.Callable[..., typing.Any],
fmha_sm100: collections.abc.Callable[..., typing.Any],
fmha_sm100_plan: collections.abc.Callable[..., typing.Any],
run_backward: collections.abc.Callable[..., typing.Any]
)
Dataclass

The launchers MSA calls: the official CSR builder, flat forward, scorer and planner, and the local backward.

build_k2q_csr
Callable[..., Any]
fmha_sm100
Callable[..., Any]
fmha_sm100_plan
Callable[..., Any]
run_backward
Callable[..., Any]
sparse_atten_func
Callable[..., Any]
nemo_automodel.components.models.minimax_m3_vl.msa_bindings._nvcc_release(
cuda_home: str
) -> tuple[int, int]

Return the (major, minor) release of the nvcc that MSA’s JIT will invoke.

nemo_automodel.components.models.minimax_m3_vl.msa_bindings._patch_fmax(
sparse_module: types.ModuleType
) -> None

Patch only the loaded MSA-owned utils before JIT; preserve fp32, third operand and loc/ip.

nemo_automodel.components.models.minimax_m3_vl.msa_bindings._patch_jit_gencode(
jit_module: types.ModuleType
) -> None

Drop the sm_103a target from MSA’s own JIT flags when the local nvcc cannot parse it.

Parameters:

jit_module
ModuleType

The loaded fmha_sm100.jit module whose _get_nvcc_flags is wrapped.

Raises:

  • ImportError: If the module is not MSA’s own jit, so a name collision cannot silently patch someone else’s compiler flags.
nemo_automodel.components.models.minimax_m3_vl.msa_bindings.kernels() -> nemo_automodel.components.models.minimax_m3_vl.msa_bindings.MSAKernels

Bind the MSA launchers once per process, patching the official package on the way.

The official package and the CuTe DSL are imported here and nowhere earlier; the backward module raises UnavailableError from require_cute_dsl itself when the DSL is missing. A failed bind is not cached, so a later call retries.

Returns: MSAKernels

The five launchers.

Raises:

  • UnavailableError: If the msa extra (official MSA, nvidia-cutlass-dsl and cuda-bindings) is not installed, naming uv sync --extra msa.
  • ImportError: If a conflicting src package or a foreign fmha_sm100.jit shadows the module a patch must own.
nemo_automodel.components.models.minimax_m3_vl.msa_bindings._BACKWARD_MODULE = 'nemo_automodel.components.models.minimax_m3_vl.kernels.msa_backward_sm100'
nemo_automodel.components.models.minimax_m3_vl.msa_bindings._MIN_SM103A_NVCC = (12, 9)
nemo_automodel.components.models.minimax_m3_vl.msa_bindings._MSA_IMPORT_ERROR = "BackendConfig.sparse_attn='msa' requires the fixed fmha-sm100 optional dependen...
nemo_automodel.components.models.minimax_m3_vl.msa_bindings._SM103A_TARGET = '-gencode=arch=compute_103a,code=sm_103a'