[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
9a1504d327
commit
cf68eade4f
3 changed files with 34 additions and 12 deletions
|
|
@ -282,9 +282,14 @@ class SyntheticDataKit:
|
|||
# Fall back to the metrics endpoint if available.
|
||||
try:
|
||||
import urllib.request
|
||||
with urllib.request.urlopen("http://localhost:8000/metrics", timeout = 2) as resp:
|
||||
|
||||
with urllib.request.urlopen(
|
||||
"http://localhost:8000/metrics", timeout = 2
|
||||
) as resp:
|
||||
if getattr(resp, "status", None) == 200:
|
||||
print("vLLM metrics endpoint detected; proceeding without ready log.")
|
||||
print(
|
||||
"vLLM metrics endpoint detected; proceeding without ready log."
|
||||
)
|
||||
ready = True
|
||||
except Exception:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ __all__ = [
|
|||
]
|
||||
|
||||
import torch
|
||||
|
||||
UNSLOTH_SFT_VLM_FIX = True
|
||||
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union
|
||||
import inspect
|
||||
|
|
@ -229,7 +230,9 @@ def PatchRL(FastLanguageModel):
|
|||
continue
|
||||
if hasattr(current_trainer, unwrap):
|
||||
try:
|
||||
setattr(current_trainer, unwrap, unsloth_unwrap_model_for_generation)
|
||||
setattr(
|
||||
current_trainer, unwrap, unsloth_unwrap_model_for_generation
|
||||
)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
|
|
@ -1229,16 +1232,24 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer", module_prefix = "trl.t
|
|||
|
||||
# Patch Trainer
|
||||
try:
|
||||
setattr(trl, RLTrainer_name, getattr(created_module, f"Unsloth{RLTrainer_name}"))
|
||||
setattr(
|
||||
trl, RLTrainer_name, getattr(created_module, f"Unsloth{RLTrainer_name}")
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
root_module = importlib.import_module(module_prefix)
|
||||
setattr(root_module, RLTrainer_name, getattr(created_module, f"Unsloth{RLTrainer_name}"))
|
||||
setattr(
|
||||
root_module,
|
||||
RLTrainer_name,
|
||||
getattr(created_module, f"Unsloth{RLTrainer_name}"),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
setattr(trainer, RLTrainer_name, getattr(created_module, f"Unsloth{RLTrainer_name}"))
|
||||
setattr(
|
||||
trainer, RLTrainer_name, getattr(created_module, f"Unsloth{RLTrainer_name}")
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
@ -1249,11 +1260,17 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer", module_prefix = "trl.t
|
|||
pass
|
||||
try:
|
||||
root_module = importlib.import_module(module_prefix)
|
||||
setattr(root_module, RLConfig_name, getattr(created_module, f"Unsloth{RLConfig_name}"))
|
||||
setattr(
|
||||
root_module,
|
||||
RLConfig_name,
|
||||
getattr(created_module, f"Unsloth{RLConfig_name}"),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
setattr(trainer, RLConfig_name, getattr(created_module, f"Unsloth{RLConfig_name}"))
|
||||
setattr(
|
||||
trainer, RLConfig_name, getattr(created_module, f"Unsloth{RLConfig_name}")
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -420,7 +420,9 @@ def _patch_trl_trainer():
|
|||
trl_trainers = set(
|
||||
x[: -len("Trainer")] for x in trl_classes if x.endswith("Trainer")
|
||||
)
|
||||
trl_configs = set(x[: -len("Config")] for x in trl_classes if x.endswith("Config"))
|
||||
trl_configs = set(
|
||||
x[: -len("Config")] for x in trl_classes if x.endswith("Config")
|
||||
)
|
||||
trl_bases = list(trl_trainers & trl_configs)
|
||||
|
||||
for base in trl_bases:
|
||||
|
|
@ -458,9 +460,7 @@ def _patch_trl_trainer():
|
|||
for mod in pkgutil.iter_modules(trl_experimental.__path__):
|
||||
if mod.name.endswith("_trainer"):
|
||||
try:
|
||||
submod = importlib.import_module(
|
||||
f"trl.experimental.{mod.name}"
|
||||
)
|
||||
submod = importlib.import_module(f"trl.experimental.{mod.name}")
|
||||
_patch_trl_module(submod)
|
||||
except Exception:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue