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
4 changes: 3 additions & 1 deletion python/sglang/srt/layers/attention/trtllm_mla_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ def init_forward_metadata(self, forward_batch: ForwardBatch):
seq_lens = forward_batch.seq_lens - forward_batch.extend_prefix_lens
cum_seq_lens_q = torch.cat(
(
torch.tensor([0], device=forward_batch.seq_lens.device),
torch.zeros(
1, dtype=torch.int32, device=forward_batch.seq_lens.device
),
Comment on lines +567 to +569
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this change is a good optimization, it also makes the .int() call on line 572 redundant. Since torch.zeros now explicitly creates an int32 tensor, and torch.cumsum on an int32 tensor also returns an int32 tensor, the result of torch.cat will already be int32. The .int() call can be removed for a minor cleanup.

torch.cumsum(seq_lens, dim=0),
)
).int()
Expand Down
Loading