Make input_ids a torch.Tensor (#1568)

This commit is contained in:
Lianmin Zheng
2024-10-04 01:09:59 -07:00
committed by GitHub
parent 114bbc8651
commit 45473d4b2b
3 changed files with 11 additions and 7 deletions
+9 -6
View File
@@ -514,9 +514,10 @@ class ScheduleBatch:
pt += req.extend_input_len
# Set fields
self.input_ids = sum(input_ids, [])
self.req_pool_indices = torch.tensor(req_pool_indices, device="cuda")
self.seq_lens = torch.tensor(seq_lens, device="cuda")
with out_cache_loc.device:
self.input_ids = torch.tensor(sum(input_ids, []), dtype=torch.int32)
self.req_pool_indices = torch.tensor(req_pool_indices)
self.seq_lens = torch.tensor(seq_lens)
self.extend_num_tokens = extend_num_tokens
self.out_cache_loc = out_cache_loc
@@ -536,7 +537,7 @@ class ScheduleBatch:
req.fill_ids = req.origin_input_ids + req.output_ids
req.extend_input_len = 1
input_ids = self.input_ids + running_batch.input_ids
input_ids = torch.cat([self.input_ids, running_batch.input_ids])
out_cache_loc = torch.cat([self.out_cache_loc, running_batch.out_cache_loc])
extend_num_tokens = self.extend_num_tokens + running_bs
@@ -722,7 +723,9 @@ class ScheduleBatch:
for r in self.reqs
]
self.input_ids = input_ids
self.input_ids = torch.tensor(
input_ids, dtype=torch.int32, device=self.seq_lens.device
)
self.seq_lens.add_(1)
# Alloc mem
@@ -824,7 +827,7 @@ class ModelWorkerBatch:
# The forward mode
forward_mode: ForwardMode
# The input ids
input_ids: List[int]
input_ids: torch.Tensor
# The indices of requests in the req_to_token_pool
req_pool_indices: torch.Tensor
# The sequence length