[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
b98b1b64f6
commit
c7175debd1
3 changed files with 11 additions and 4 deletions
|
|
@ -24,6 +24,7 @@ def _load_model(model_name, load_in_4bit = True):
|
|||
"""Load model, raising SkipTest if the model cannot be loaded."""
|
||||
try:
|
||||
from unsloth import FastLanguageModel
|
||||
|
||||
model, tokenizer = FastLanguageModel.from_pretrained(
|
||||
model_name = model_name,
|
||||
max_seq_length = 2048,
|
||||
|
|
|
|||
|
|
@ -227,10 +227,10 @@ def _slice_position_ids(position_ids, input_ids):
|
|||
return None
|
||||
if position_ids.dim() == 2:
|
||||
if position_ids.shape[1] > input_ids.shape[1]:
|
||||
position_ids = position_ids[:, -input_ids.shape[1]:]
|
||||
position_ids = position_ids[:, -input_ids.shape[1] :]
|
||||
elif position_ids.dim() == 1:
|
||||
if position_ids.shape[0] > input_ids.shape[1]:
|
||||
position_ids = position_ids[-input_ids.shape[1]:]
|
||||
position_ids = position_ids[-input_ids.shape[1] :]
|
||||
return position_ids
|
||||
|
||||
|
||||
|
|
@ -1492,7 +1492,11 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
attention_mask = attention_mask,
|
||||
**kwargs,
|
||||
)
|
||||
elif past_key_values is not None and input_ids is not None and input_ids.shape[1] > 1:
|
||||
elif (
|
||||
past_key_values is not None
|
||||
and input_ids is not None
|
||||
and input_ids.shape[1] > 1
|
||||
):
|
||||
# Multi-token prefill with user-provided KV cache. The fast inference
|
||||
# path only supports single-token decoding (q_len == 1), so fall
|
||||
# through to the regular model forward which handles arbitrary lengths.
|
||||
|
|
|
|||
|
|
@ -265,7 +265,9 @@ def MistralForCausalLM_fast_forward(
|
|||
position_ids = position_ids,
|
||||
attention_mask = attention_mask,
|
||||
)
|
||||
elif past_key_values is not None and input_ids is not None and input_ids.shape[1] > 1:
|
||||
elif (
|
||||
past_key_values is not None and input_ids is not None and input_ids.shape[1] > 1
|
||||
):
|
||||
# Multi-token prefill with user-provided KV cache
|
||||
self.model._has_no_labels = labels is None
|
||||
outputs = self.model(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue