nemo_rl.models.megatron.zero_train_gen_mismatch#
Zero train/generation KL (batch-invariant Megatron): validate the recipe, then enable.
The recipe sets every required value; this module only checks them. Only BF16 (no FP8) is supported.
Module Contents#
Classes#
Collected validation outcome. |
|
At TP size 1, use the log-softmax Megatron Inference uses (bitwise). |
Functions#
Run all zero-KL gates; return violations and non-fatal warnings. |
|
Checks for |
|
Enable MCore’s FA4 path for the pinned |
|
Pin TE FA support and call MCore |
|
Raise if the zero-KL / batch-invariant config is invalid. |
|
The recipe must set every value the preset needs; nothing is rewritten. |
|
Blackwell + FA4 only (mcore extra: flash-attn-4, CuteDSL). Hopper/FA3 not supported. |
|
Reject unsupported architectures using the resolved Bridge provider. |
|
Only BF16 without FP8 is supported, on both the train and generation side. |
Data#
API#
- nemo_rl.models.megatron.zero_train_gen_mismatch.MEGATRON_CORE_REQUIRED_CONFIG_FIELDS#
(‘batch_invariant_mode’, ‘batch_invariant_backend’, ‘batch_invariant_collective’, ‘flash_attention_v…
- nemo_rl.models.megatron.zero_train_gen_mismatch.TRANSFORMER_ENGINE_MIN_VERSION#
‘Version(…)’
- nemo_rl.models.megatron.zero_train_gen_mismatch.FLASH_ATTN_MIN_VERSION#
‘Version(…)’
- nemo_rl.models.megatron.zero_train_gen_mismatch.CUTEDSL_MIN_VERSION#
‘Version(…)’
- nemo_rl.models.megatron.zero_train_gen_mismatch._ZERO_KL_MEGATRON_REQUIRED: dict[str, Any]#
None
- nemo_rl.models.megatron.zero_train_gen_mismatch._ZERO_KL_GENERATION_REQUIRED: dict[str, Any]#
None
- nemo_rl.models.megatron.zero_train_gen_mismatch._TE_NATIVE_ENV_VARS#
None
- class nemo_rl.models.megatron.zero_train_gen_mismatch.ZeroTrainGenValidation#
Collected validation outcome.
- violations: list[str]#
‘field(…)’
- warnings: list[str]#
‘field(…)’
- raise_if_invalid(header: str) None#
- emit_warnings() None#
- nemo_rl.models.megatron.zero_train_gen_mismatch.validate_zero_train_gen_mismatch(
- config: nemo_rl.models.policy.PolicyConfig,
- *,
- check_packages: bool = True,
- check_platform: bool = True,
Run all zero-KL gates; return violations and non-fatal warnings.
- nemo_rl.models.megatron.zero_train_gen_mismatch.validate_batch_invariant_mode(
- config: nemo_rl.models.policy.PolicyConfig,
Checks for
batch_invariant_mode=Truewithout enabling MCore kernels.
- nemo_rl.models.megatron.zero_train_gen_mismatch.allow_installed_flash_attn_4() None#
Enable MCore’s FA4 path for the pinned
flash-attn-4b19.MCore gates
HAVE_FA4on>=4.0.0b20, which needs a newerapache-tvm-ffithan we pin. The call signature is identical.
- class nemo_rl.models.megatron.zero_train_gen_mismatch._Tp1LocalLogprob(original: Any, *, chunked: bool)#
At TP size 1, use the log-softmax Megatron Inference uses (bitwise).
Initialization
- apply(*args: Any) Any#
- nemo_rl.models.megatron.zero_train_gen_mismatch._use_fused_log_softmax_at_tp1() None#
- nemo_rl.models.megatron.zero_train_gen_mismatch.enable_batch_invariant_kernels(
- config: nemo_rl.models.policy.PolicyConfig,
Pin TE FA support and call MCore
enable_batch_invariant_mode.
- nemo_rl.models.megatron.zero_train_gen_mismatch.validate_zero_train_gen_kl(
- config: nemo_rl.models.policy.PolicyConfig,
- *,
- check_environment: bool,
Raise if the zero-KL / batch-invariant config is invalid.
check_environment=Falseruns only the config checks, so the driver can call it before Ray allocates GPUs; workers also check the installed packages and the GPU.
- nemo_rl.models.megatron.zero_train_gen_mismatch._validate_required_values(
- config: nemo_rl.models.policy.PolicyConfig,
- out: nemo_rl.models.megatron.zero_train_gen_mismatch.ZeroTrainGenValidation,
The recipe must set every value the preset needs; nothing is rewritten.
- nemo_rl.models.megatron.zero_train_gen_mismatch._validate_backend(
- config: nemo_rl.models.policy.PolicyConfig,
- out: nemo_rl.models.megatron.zero_train_gen_mismatch.ZeroTrainGenValidation,
- nemo_rl.models.megatron.zero_train_gen_mismatch._validate_platform(
- out: nemo_rl.models.megatron.zero_train_gen_mismatch.ZeroTrainGenValidation,
- *,
- check_device: bool,
Blackwell + FA4 only (mcore extra: flash-attn-4, CuteDSL). Hopper/FA3 not supported.
- nemo_rl.models.megatron.zero_train_gen_mismatch._validate_megatron_core_features( ) None#
- nemo_rl.models.megatron.zero_train_gen_mismatch._package_version(dist_name: str) packaging.version.Version | None#
- nemo_rl.models.megatron.zero_train_gen_mismatch._first_package_version(
- dist_names: tuple[str, ...],
- nemo_rl.models.megatron.zero_train_gen_mismatch._validate_packages( ) None#
- nemo_rl.models.megatron.zero_train_gen_mismatch.validate_zero_train_gen_model_provider(
- config: nemo_rl.models.policy.PolicyConfig,
- model_cfg: Any,
Reject unsupported architectures using the resolved Bridge provider.
- nemo_rl.models.megatron.zero_train_gen_mismatch._validate_precision(
- config: nemo_rl.models.policy.PolicyConfig,
- out: nemo_rl.models.megatron.zero_train_gen_mismatch.ZeroTrainGenValidation,
Only BF16 without FP8 is supported, on both the train and generation side.