scope flash-attn+qlora fix correctly, scope to llama, add comment
This commit is contained in:
@@ -333,13 +333,15 @@ def load_model(
|
|||||||
model, use_gradient_checkpointing=cfg.gradient_checkpointing
|
model, use_gradient_checkpointing=cfg.gradient_checkpointing
|
||||||
)
|
)
|
||||||
|
|
||||||
if cfg.flash_attention:
|
# LlamaRMSNorm layers are in fp32 after kit call, so we need to
|
||||||
for name, module in model.named_modules():
|
# convert them back to fp16/bf16 for flash-attn compatibility.
|
||||||
if "norm" in name:
|
if cfg.flash_attention and cfg.is_llama_derived_model:
|
||||||
module.to(torch_dtype)
|
for name, module in model.named_modules():
|
||||||
if "lm_head" in name or "embed_tokens" in name:
|
if "norm" in name:
|
||||||
if hasattr(module, "weight"):
|
|
||||||
module.to(torch_dtype)
|
module.to(torch_dtype)
|
||||||
|
if "lm_head" in name or "embed_tokens" in name:
|
||||||
|
if hasattr(module, "weight"):
|
||||||
|
module.to(torch_dtype)
|
||||||
|
|
||||||
model, lora_config = load_adapter(model, cfg, adapter)
|
model, lora_config = load_adapter(model, cfg, adapter)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user