Update llama.py
This commit is contained in:
parent
a899e9a9f1
commit
100f2a3242
1 changed files with 9 additions and 1 deletions
|
|
@ -1068,6 +1068,7 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
print(1068)
|
||||
pass
|
||||
hidden_states = outputs[0]
|
||||
print(1071)
|
||||
|
||||
bsz, q_len, hd = hidden_states.shape
|
||||
lm_head = self.lm_head.weight
|
||||
|
|
@ -1084,6 +1085,8 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
RETURN_LOGITS = os.environ.get("UNSLOTH_RETURN_LOGITS", "0") == "1"
|
||||
# < 1024 Normal Unsloth uses less VRAM!
|
||||
if bsz*q_len <= 1024: RETURN_LOGITS = True
|
||||
|
||||
print(1089)
|
||||
|
||||
if not RETURN_LOGITS and HAS_CUT_CROSS_ENTROPY and labels is not None:
|
||||
|
||||
|
|
@ -1095,6 +1098,8 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
num_items_in_batch = n_items,
|
||||
logit_softcapping = logit_softcapping,
|
||||
)
|
||||
|
||||
print(1102, loss)
|
||||
if not return_dict:
|
||||
output = (logits,) + outputs[1:]
|
||||
return (loss,) + output if loss is not None else output
|
||||
|
|
@ -1108,6 +1113,7 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
)
|
||||
return output
|
||||
pass
|
||||
print(1116, hidden_states.dtype, hidden_states.shape)
|
||||
logits = self.lm_head(hidden_states.to(dtype))
|
||||
pass
|
||||
|
||||
|
|
@ -1117,6 +1123,7 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
else:
|
||||
raise TypeError("Unsloth: torch_dtype for models is not bfloat16, float16 or float32!")
|
||||
pass
|
||||
print(1126)
|
||||
|
||||
loss = None
|
||||
logit_softcapping = getattr(self.config, "final_logit_softcapping", 0)
|
||||
|
|
@ -1142,6 +1149,7 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
logit_scaling = logit_scaling,
|
||||
n_items = kwargs.get("num_items_in_batch", None) or kwargs.get("n_items", None),
|
||||
)
|
||||
print(1152, loss)
|
||||
else:
|
||||
if logit_scaling != 0:
|
||||
if logits.requires_grad:
|
||||
|
|
@ -1166,7 +1174,7 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
if not return_dict:
|
||||
output = (logits,) + outputs[1:]
|
||||
return (loss,) + output if loss is not None else output
|
||||
|
||||
print(1177, loss, logits.shape, logits.dtype)
|
||||
return CausalLMOutputWithPast(
|
||||
loss=loss,
|
||||
logits=logits,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue