Fix crash when trl.experimental.openenv is unavailable (#3787)

* Guard optional trl.experimental.openenv usage in RL patches

* Simplify optional trl.openenv import handling

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Fizza Mukhtar 2025-12-28 21:23:51 -08:00 committed by GitHub
commit c8b0bada94

View file

@ -949,11 +949,15 @@ def openenv_vllm_reload_weights():
return
if Version(importlib_version("trl")) < Version("0.26.0"):
return
try:
import trl.experimental.openenv.utils as openenv_utils
import trl.experimental.openenv as openenv
except ImportError as e:
logger.info(f"Unsloth: Failed to import trl openenv: {e}")
logger.info(
"Unsloth: trl.experimental.openenv not available — skipping RL openenv patches."
)
return
src = inspect.getsource(openenv_utils.generate_rollout_completions)