Fix GPT OSS (#3154)
* Fix mamba * Update loader.py * Update vision.py * Update loader.py * Filter vLLM standby logs (#3131) * filter vLLM standby logs * safeguard standby logger patch * Update unsloth/models/_utils.py * Update unsloth/models/_utils.py * Update unsloth/models/_utils.py --------- Co-authored-by: Daniel Han <danielhanchen@gmail.com> * Update loader.py * Add scaler * Update llama.py * Update _utils.py * Versioning * GPT OSS fix * GPT OSS fix * Update loader.py * Update vision.py * Update vision.py * Update loader.py --------- Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com>
This commit is contained in:
parent
b914f252d3
commit
86a2725cb6
2 changed files with 13 additions and 2 deletions
|
|
@ -68,6 +68,7 @@ __all__ = [
|
|||
"patch_fast_lora",
|
||||
"validate_loftq_config",
|
||||
"RaiseUninitialized",
|
||||
"dequantize_module_weight",
|
||||
]
|
||||
|
||||
import torch
|
||||
|
|
@ -724,6 +725,7 @@ pass
|
|||
# Weirdly LoraLayer.update_layer downcasts PEFT layers to float16??
|
||||
# For mixed precision, we need it to be in float32 not float16.
|
||||
from peft import __version__ as peft_version
|
||||
from peft.utils.integrations import dequantize_module_weight
|
||||
if Version(peft_version) < Version("0.12.0"):
|
||||
from peft.tuners.lora.layer import LoraLayer
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -618,9 +618,18 @@ class FastModel(FastBaseModel):
|
|||
os.environ["UNSLOTH_FORCE_CUSTOM_DTYPE"] = \
|
||||
"all;None;None;"\
|
||||
"x = 'gate_up_proj_bias'\n"\
|
||||
"if hasattr(module, x): setattr(module, x, torch.nn.Parameter(getattr(module, x).to(torch.float32)) if isinstance(getattr(module, x), torch.nn.Parameter) else getattr(module, x).to(torch.float32))\n"\
|
||||
"if hasattr(module, x): "\
|
||||
"setattr(module, x, torch.nn.Parameter(getattr(module, x).to(torch.float32)) if isinstance(getattr(module, x), torch.nn.Parameter) else getattr(module, x).to(torch.float32))\n"\
|
||||
"x = 'down_proj_bias'\n"\
|
||||
"if hasattr(module, x): setattr(module, x, torch.nn.Parameter(getattr(module, x).to(torch.float32)) if isinstance(getattr(module, x), torch.nn.Parameter) else getattr(module, x).to(torch.float32))\n;"
|
||||
";"
|
||||
else:
|
||||
# Set down projection compute dtype to be float32 for float16 machines
|
||||
os.environ["UNSLOTH_FORCE_CUSTOM_DTYPE"] = \
|
||||
"all;None;None;"\
|
||||
"if 'down_projs' in name and hasattr(module, 'compute_dtype') and "\
|
||||
"torch.amax(dequantize_module_weight(module)) >= 1024:"\
|
||||
"module._pre_set_compute_dtype = torch.float32\n"\
|
||||
";"
|
||||
else:
|
||||
for check_model_name in DISABLE_COMPILE_MODEL_NAMES:
|
||||
if check_model_name in lowered_model_name:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue