nemo_rl.utils.fastokens#
Config-gated integration with the fastokens Rust-backed BPE tokenizer.
Enabling policy.tokenizer.use_fastokens monkey-patches HuggingFace
transformers tokenizers with fastokens’ accelerated encode/decode
implementation (~10x faster BPE encoding). The patch is idempotent — calling it
multiple times in the same process is a no-op after the first successful
application.
The config field controls this NeMo-RL-side patch when no environment override
is set. NRL_USE_FASTOKENS is the top-level NeMo-RL override and is mirrored
to VLLM_USE_FASTOKENS so vLLM workers follow the same setting. A standalone
VLLM_USE_FASTOKENS setting is left for vLLM and does not control this
NeMo-RL-side patch.
See: https://github.com/Atero-ai/fast-tokens
Module Contents#
Functions#
Mirror NeMo-RL’s fastokens override to vLLM’s fastokens flag. |
|
Apply the fastokens monkey-patch when enabled. |
Data#
API#
- nemo_rl.utils.fastokens.logger#
‘getLogger(…)’
- nemo_rl.utils.fastokens._patched#
False
- nemo_rl.utils.fastokens._NRL_ENV_VAR#
‘NRL_USE_FASTOKENS’
- nemo_rl.utils.fastokens._VLLM_ENV_VAR#
‘VLLM_USE_FASTOKENS’