Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Valery Chernov committed Feb 2, 2024
1 parent e58b7d3 commit 01c8fb6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions serve/mlc_serve/model/dummy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
DecodeRequest,
KVCache,
PrefillRequest,
RequestType,
SequenceId,
TextGenerationResult,
)
Expand Down Expand Up @@ -98,18 +97,17 @@ def get_max_new_tokens(self) -> int:
class DummyTextGenerator:
def generate(
self,
requests: list[RequestType],
requests: list[Union[PrefillRequest, DecodeRequest]e],
kv_cache: DummyCache,
) -> list[TextGenerationResult]:
result = []
for req in requests:
# TODO(vvchernov): support other types of Request
if isinstance(req, DecodeRequest):
seq_id = req.sequence_id
request_id = req.sequence_id.request_id
if req.sequence_id.sequence_index > 0:
raise RuntimeError("Multiple generated sequences not supported")
else: # PrefillRequest
else:
seq_id = SequenceId(req.request_id, 0)
request_id = req.request_id

Expand Down
3 changes: 1 addition & 2 deletions serve/mlc_serve/model/model_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ def sample_from_logits(
assert logits.shape[0] == len(requests)

sampling_params = [req.sampling_params for req in requests]
outputs: List[TextGenerationResult] = []

try:
next_tokens, logprob_infos = sample(logits, sampling_params, vocab_size)
assert next_tokens is not None
outputs = []
for i, (sequence_id, new_token) in enumerate(zip(sequence_ids, next_tokens)):
update_tokens_frequency(requests[i], new_token)
outputs = append_text_gen_res(
Expand All @@ -369,7 +369,6 @@ def sample_from_logits(
return outputs
except RuntimeError:
# Fallback to per-token sampling in case some logits values are corrupted.
outputs = []
err_msg = (
"Error from sampling: probability tensor contains either `inf`, `nan`"
" or element < 0"
Expand Down

0 comments on commit 01c8fb6

Please sign in to comment.