env#

Every MODELOPT_* environment variable ModelOpt reads, each through one accessor.

An accessor reads os.environ when it is called, not at import: a launcher sets these before it starts the workers, and a test may set one after importing ModelOpt, so the live value is what counts. Call one as from modelopt import env then env.ep_degree().

An accessor is named after its variable, lowercased and without MODELOPT_. A blank value reads as unset, and a value the accessor cannot parse raises a ValueError naming the variable. A rule relating a variable to another one or to the run is checked where the value is used.

This module needs only the standard library, so code that must not import torch reads its variables here too. A new variable gets its accessor here: the check-env-knobs pre-commit hook refuses a MODELOPT_* read anywhere else under modelopt/.

Functions

ep_degree

MODELOPT_EP_DEGREE: the expert-parallel degree, a number or auto; unset is auto.

fsdp2_export

MODELOPT_FSDP2_EXPORT: the writer of an FSDP2-sharded export; streaming by default.

fsdp_size

MODELOPT_FSDP_SIZE: the layout of the dense part; unset is auto.

nvfp4_triton_sweep

MODELOPT_NVFP4_TRITON_SWEEP: use the fused Triton NVFP4 scale sweep; on by default.

skip_weight_quant_check

MODELOPT_SKIP_WEIGHT_QUANT_CHECK: skip a check of mtq.quantize; off by default.

tegrouped_compile_weight_loop

MODELOPT_TEGROUPED_COMPILE_WEIGHT_LOOP: compile a weight-quantizer loop; off by default.

ep_degree()#

MODELOPT_EP_DEGREE: the expert-parallel degree, a number or auto; unset is auto.

Return type:

str

fsdp2_export()#

MODELOPT_FSDP2_EXPORT: the writer of an FSDP2-sharded export; streaming by default.

streaming all-gathers each FSDP2 unit on every rank; nogather moves each tensor once, to the one rank that writes it.

Return type:

str

fsdp_size()#

MODELOPT_FSDP_SIZE: the layout of the dense part; unset is auto.

1 replicates it; world, or the world size as a number, FSDP2-shards it over every rank.

Return type:

str

nvfp4_triton_sweep()#

MODELOPT_NVFP4_TRITON_SWEEP: use the fused Triton NVFP4 scale sweep; on by default.

0 makes NVFP4 MSE calibration sweep the scales in PyTorch instead.

Return type:

bool

skip_weight_quant_check()#

MODELOPT_SKIP_WEIGHT_QUANT_CHECK: skip a check of mtq.quantize; off by default.

The check raises when a config asks for weight quantization but enables no weight quantizer.

Return type:

bool

tegrouped_compile_weight_loop()#

MODELOPT_TEGROUPED_COMPILE_WEIGHT_LOOP: compile a weight-quantizer loop; off by default.

1 runs the per-expert weight quantizers of a Transformer Engine grouped linear under torch.compile.

Return type:

bool