Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sendnn_inference/v1/core/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ def check_batch_tkv_limit_cp(self, request: Request, new_req_tkv: int, running)
# Compute the effective token length of the new request
# Rounded up to the nearest block size to account for potential padding
new_req_max_tkv = round_up_to_block_size(new_req_tkv + request.max_tokens - 1)
# Extra block of slack: left-padding can push a sequence's runtime tkv up to
# one block past the scheduler's estimate when the batch re-aligns on admission.
new_req_max_tkv += self.block_size

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dang, yeah my reasoning on only needing to round up was that the padding only happens when a request actually gets to the next block, so if our math is correct here then you'd only get to the next block if some request was going to end inside it, in which case that request would round up and cover all the cases of other requests getting padded to somewhere within that block.

But clearly that reasoning isn't sound 🙃

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought that was okay, but somehow there were still certain workloads that would cause requests passing that violate the constraint. This is a dumb fix, just creating a safety margin, but a this stage I am a bit uncertain what else to do.


# Compute token lengths for all running requests (decode batch)
decode_req_max_tkvs = []
Expand All @@ -551,6 +554,10 @@ def check_batch_tkv_limit_cp(self, request: Request, new_req_tkv: int, running)
dec_req_max_tkv = round_up_to_block_size(
dec_req_tkv + (req.max_tokens - n_generated_output_tokens) - 1
)
# Extra block of slack: left-padding can push a sequence's runtime tkv up to
# one block past the scheduler's estimate when the batch re-aligns on admission.
dec_req_max_tkv += self.block_size

decode_req_max_tkvs.append(dec_req_max_tkv)

# Sort decode requests token lengths in ascending order
Expand Down
Loading