nemo_automodel._transformers.v4_patches.rotary#

Runtime RoPE patches for legacy v4-style remote-code models.

Module Contents#

Functions#

_to_local

Unwrap DTensor to its local shard for numeric checks.

_safe_rope_forward

Drop-in replacement for legacy rotary embedding forward methods.

_is_nemotron_flash_config

should_fix_rotary_embeddings

Return True when the legacy rotary workaround should run.

fix_rotary_embeddings

Patch rotary embeddings to bypass fragile legacy HF runtime behavior.

Data#

API#

nemo_automodel._transformers.v4_patches.rotary.logger#

‘getLogger(…)’

nemo_automodel._transformers.v4_patches.rotary._to_local(t)#

Unwrap DTensor to its local shard for numeric checks.

nemo_automodel._transformers.v4_patches.rotary._safe_rope_forward(self, x, position_ids, **kwargs)#

Drop-in replacement for legacy rotary embedding forward methods.

nemo_automodel._transformers.v4_patches.rotary._is_nemotron_flash_config(cfg)#
nemo_automodel._transformers.v4_patches.rotary.should_fix_rotary_embeddings(model_parts)#

Return True when the legacy rotary workaround should run.

nemo_automodel._transformers.v4_patches.rotary.fix_rotary_embeddings(model_parts)#

Patch rotary embeddings to bypass fragile legacy HF runtime behavior.

nemo_automodel._transformers.v4_patches.rotary.__all__#

[‘fix_rotary_embeddings’, ‘should_fix_rotary_embeddings’]