-
Couldn't load subscription status.
- Fork 31k
[Continous Batching] fix do_Sample=True in continuous batching #40692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, ty!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! perfect 🤗
…ngface#40692) * fix do_Sample=True in continous batching * added test * fix top_p * test * Update examples/pytorch/continuous_batching.py
This pull request introduces improvements to sampling support in continuous batching generation, enhances tensor shape handling for logit processors, and expands test coverage for batch generation with sampling. The main changes are grouped below:
Sampling and Generation Behavior:
batch_generateby settingdo_sample=Trueand configuringtemperatureandtop_pparameters, allowing for more diverse outputs during batch generation.Tensor Shape Handling and Sampling Logic:
continuous_api.pyto handle 3D logits produced by continuous batching, reshaping them as needed for compatibility with logit processors and restoring original shapes after processing._sampleto ensure correct tensor dimensions when sampling tokens, making the method robust for both sampling and greedy decoding.Paged Attention and Integration:
flash_attn_varlen_funcin the attention implementation to ensure compatibility and prevent errors during paged attention forward passes.Testing and Validation:
generated_tokensinstead ofstatic_outputsfor accuracy.test_generate_batch_with_samplingto verify that batch generation with sampling enabled works correctly across different attention implementations and configurations. The test checks for successful completion, non-empty outputs, and actual sampling behavior.