fix: align sampler batch size with decode batch size#474
Open
rebel-daeyang wants to merge 6 commits intodevfrom
Open
fix: align sampler batch size with decode batch size#474rebel-daeyang wants to merge 6 commits intodevfrom
rebel-daeyang wants to merge 6 commits intodevfrom
Conversation
…RBLN-SW/vllm-rbln into sampler_batch_size_to_decode_batch_size
rebel-ykchoi
requested changes
Mar 26, 2026
Comment on lines
1926
to
1956
| # compile sampler for all possible decode batches | ||
| max_decode_batch = self.bucketing_manager.decode_batch_buckets[-1] | ||
| for decode_batch in range(1, max_decode_batch + 1): | ||
| dummy_decode_requests = [] | ||
| dummy_decode_num_scheduled_tokens = {} | ||
| for _ in range(decode_batch): | ||
| self._add_dummy_requests( | ||
| requests=dummy_decode_requests, | ||
| num_scheduled_tokens=dummy_decode_num_scheduled_tokens, | ||
| total_tokens=decode_max_seq_len, | ||
| num_computed_tokens=decode_max_seq_len, | ||
| num_kv_cache_groups=num_kv_cache_groups, | ||
| sampling_params=None | ||
| if self.is_pooling_model | ||
| else SamplingParams(temperature=0.0), | ||
| pooling_params=PoolingParams( | ||
| task=self.get_supported_pooling_tasks()[0] | ||
| ) | ||
| if self.is_pooling_model | ||
| else None, | ||
| ) | ||
| so, cso = self._make_dummy_scheduler_outputs( | ||
| dummy_decode_requests, | ||
| dummy_decode_num_scheduled_tokens, | ||
| num_kv_cache_groups, | ||
| ) | ||
| current_intermediate_tensors = self.decode_intermediate_tensors.get( | ||
| decode_batch | ||
| ) | ||
| assert current_intermediate_tensors is not None | ||
| self._execute_dummy_requests(so, cso, current_intermediate_tensors) |
Contributor
There was a problem hiding this comment.
Please, remove the code for compiling the sampler every num_tokens in the decode stage as it is no longer necessary.
Author
|
I noticed that applying this PR removes logits slicing for CPU tensor inputs, which leads to a decrease in sampler performance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Summary of Changes
Previously, the decoder output logits were sliced before being passed to the sampler. However, performing slicing operations on rbln device tensors triggers unnecessary d2h and h2d transfers, leading to a significant increase in latency.
To resolve this performance issue, this PR removes the logits slicing logic and updates the sampler to accept the full logits, matching the decode batch size.
📌 Related Issues / Tickets
✅ Type of Change
release)feature)model)core)fix)perf)refactor)docs)other): please describe🧪 How to Test
.........📸 Screenshots / Logs (if applicable)
📋 Checklist
💬 Notes
Verified outputs for 1~64 batch size, temperature/top_p/top_k, chunked prefill with llama3.2 model.
Verified outputs for medusa, lora (eagle3 fails as before).
rbln device tensor input does not yet support speculative decoding or LoRA.
Request for Review: Please check for potential issues regarding Speculative Decoding, LoRA, or MoE models.