nemo_rl.transformers_compat#
Temporary compatibility patches for supported Transformers releases.
The dynamic-module hashing patch can be removed when NeMo RL requires Transformers 5.13.0 or newer. Keep the torch-FX helper until the converted DeepSeek-V3 checkpoint no longer imports the Transformers 4.x API.
Module Contents#
Functions#
Compatibility replacement for the helper removed in Transformers 5. |
|
Restore the legacy helper imported by DeepSeek-V3 remote model code. |
|
Hash dynamic-module sources without losing symlinked snapshot filenames. |
|
Backport the Transformers 5.13 dynamic-module symlink fix. |
Data#
API#
- nemo_rl.transformers_compat.logger#
‘getLogger(…)’
- nemo_rl.transformers_compat._MIN_AFFECTED_TRANSFORMERS_VERSION#
‘5.11.0’
- nemo_rl.transformers_compat._FIXED_TRANSFORMERS_VERSION#
‘5.13.0’
- nemo_rl.transformers_compat._EXPECTED_HASH_FUNCTION_PARAMETERS#
(‘pretrained_model_name_or_path’, ‘resolved_module_file’)
- nemo_rl.transformers_compat._is_torch_fx_available_compat() bool[source]#
Compatibility replacement for the helper removed in Transformers 5.
- nemo_rl.transformers_compat._patch_transformers_torch_fx_compat() bool[source]#
Restore the legacy helper imported by DeepSeek-V3 remote model code.
The converted DeepSeek-V3 checkpoint used by the performance suite embeds model code written for Transformers 4.33.1. That code imports
is_torch_fx_availablefromtransformers.utils.import_utils, but the helper was removed in Transformers 5. Install an equivalent only when the installed Transformers does not provide it already.
- nemo_rl.transformers_compat._compute_local_source_files_hash_with_symlink_fix(
- pretrained_model_name_or_path: str | os.PathLike,
- resolved_module_file: str | os.PathLike,
Hash dynamic-module sources without losing symlinked snapshot filenames.
Adapted from the implementation shipped upstream in Transformers 5.13.0 by https://github.com/huggingface/transformers/pull/46618. Earlier affected releases resolve snapshot file symlinks into
blobs/before locating relative imports, where blob names no longer have the Python module filenames that those imports reference.
- nemo_rl.transformers_compat._patch_transformers_dynamic_module_symlink_cache() bool[source]#
Backport the Transformers 5.13 dynamic-module symlink fix.
Returns
Trueonly when this call installs the patch. Missing Transformers and unaffected versions are intentional no-ops. Remove this patch after upgrading the minimum supported Transformers version to 5.13.0.