Skip to content

Commit

Permalink
Fix the cuda graph capture range for small #max-running-requests (#2359)
Browse files Browse the repository at this point in the history
  • Loading branch information
merrymercy authored and zhyncs committed Dec 6, 2024
1 parent 4a63c18 commit 71e2a27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/sglang/srt/model_executor/cuda_graph_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ def __init__(self, model_runner: "ModelRunner"):
self.capture_bs = list(range(1, 32)) + [64, 128]
else:
self.capture_bs = [1, 2, 4] + [i * 8 for i in range(1, 21)]

if max(self.capture_bs) > model_runner.req_to_token_pool.size:
# In some case (e.g., with a small GPU or --max-running-requests), the #max-running-requests
# is very samll. We add more values here to make sure we capture the maximum bs.
self.capture_bs = list(
sorted(
set(
self.capture_bs
+ [model_runner.req_to_token_pool.size - 1]
+ [model_runner.req_to_token_pool.size]
)
)
)

self.capture_bs = [
bs
for bs in self.capture_bs
Expand Down

0 comments on commit 71e2a27

Please sign in to comment.