You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
num_return_sequences in non-ampere colab produces nonsense response #144
(Justification for claim "non-ampere": A100 works as expected. V100 does not.)
Snippet of generating code and example output:
# Generating without `num_return_sequences` produces sensible output.
outputs = model.generate(tokenized_chat, max_new_tokens=128, do_sample=True)
pprint.pprint(tokenizer.decode(outputs[0]))
# Generating with `num_return_sequences` produces nonsense.
outputs = model.generate(tokenized_chat, max_new_tokens=128, do_sample=True, num_return_sequences=2)
pprint.pprint(tokenizer.decode(outputs[0]))
('<|system|>\n'
'</s> \n'
'<|user|>\n'
'Please recite the alphabet.</s> \n'
'<|assistant|>\n'
'A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, '
'Z.</s>')
('<|system|>\n'
'</s> \n'
'<|user|>\n'
'Please recite the alphabet.</s> \n'
'<|assistant|>\n'
'A,A B- A - A, Ab- A, a, A, A, A. A, I amp a, A,</s>')
@malcolmsharpe I fixed it! Dumb me when I was trying to make inference 2x faster, I accidentally turned off the non training paths for inference.
So loading the model for inference, then asking "What is a famous tall tower in Paris?" with num_return_sequences = 4:
Likewise, after training telling the model to continue the Fibonnaci sequence:
Hopefully it's fixed! I will be super duper careful from now on on editting the inference section - seems like I need to add tests for inference now on my side before I push any commits!!
@malcolmsharpe Hey again!! I just made inference 2x faster natively :) I also tried it on num_return_sequences and num_beams and batched inference, and are all faster (with no gibberish outputs :)) Just pushed it to the main branch, so it'll be absolutely awesome if you could test it out :))
Call FastLanguageModel.for_inference(model) before doing inference to make it faster :)
Call FastLanguageModel.for_training(model) to revert it back for finetuning.
Thanks. I'm on a different project at the moment, but I'll try it next time I'm using that feature.
A question about switching between inference and training mode: will it work to do that while evaluating during training? (If so, presumably I can switch into inference mode at the start of on_evaluate in my callback, then switch back to training mode at the end?)
Activity
danielhanchen commentedon Jan 30, 2024
@malcolmsharpe Oh my let me check - again apologies from my side!
danielhanchen commentedon Jan 30, 2024
@malcolmsharpe I fixed it! Dumb me when I was trying to make inference 2x faster, I accidentally turned off the non training paths for inference.
So loading the model for inference, then asking "What is a famous tall tower in Paris?" with

num_return_sequences = 4:Likewise, after training telling the model to continue the Fibonnaci sequence:

Hopefully it's fixed! I will be super duper careful from now on on editting the inference section - seems like I need to add tests for inference now on my side before I push any commits!!
Again apologies on the issue! Hope it works!
malcolmsharpe commentedon Jan 30, 2024
It works now. Thanks for the quick fix. (
num_return_sequencesis handy for doing mid-training eval.)danielhanchen commentedon Feb 4, 2024
@malcolmsharpe Hey again!! I just made inference 2x faster natively :) I also tried it on num_return_sequences and num_beams and batched inference, and are all faster (with no gibberish outputs :)) Just pushed it to the main branch, so it'll be absolutely awesome if you could test it out :))
Call
FastLanguageModel.for_inference(model)before doing inference to make it faster :)Call
FastLanguageModel.for_training(model)to revert it back for finetuning.Faster.inference.mp4
malcolmsharpe commentedon Feb 4, 2024
Thanks. I'm on a different project at the moment, but I'll try it next time I'm using that feature.
A question about switching between inference and training mode: will it work to do that while evaluating during training? (If so, presumably I can switch into inference mode at the start of
on_evaluatein my callback, then switch back to training mode at the end?)danielhanchen commentedon Feb 5, 2024
@malcolmsharpe Yep! Like this:
introduce intel GPUs into unsloth-zoo (unslothai#144)
introduce intel GPUs into unsloth-zoo (unslothai#144)
introduce intel GPUs into unsloth-zoo (unslothai#144)
Merge pull request unslothai#144 from unslothai/fix/remove-hardcoded-…