Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
dsikka committed Sep 21, 2023
1 parent 592c81c commit 3a18e5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 15 additions & 5 deletions src/deepsparse/transformers/pipelines/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ def process_engine_outputs(
if streaming:
return self._stream_engine_outputs(engine_outputs, prompts, kwargs)

generated_tokens, generated_logits, finished_reason, *debug = list(*engine_outputs)
generated_tokens, generated_logits, finished_reason, *debug = list(
*engine_outputs
)
sequences = self.tokenizer.batch_decode(
generated_tokens, skip_special_tokens=True
)
Expand Down Expand Up @@ -587,7 +589,7 @@ def process_engine_outputs(
)
outputs.update(debug_params)

yield TextGenerationOutput(**outputs)
return TextGenerationOutput(**outputs)

def engine_forward(
self, engine_inputs: List[numpy.ndarray], context: Dict
Expand Down Expand Up @@ -699,7 +701,7 @@ def engine_forward(
[finished_reason[-1]],
)

if not self.streaming:
if not streaming:
returns = (
numpy.array([generated_tokens]),
numpy.concatenate(generated_logits, axis=1),
Expand Down Expand Up @@ -953,12 +955,20 @@ def join_engine_outputs(

if debug:
sessions = debug[0]
kv_cache_state = numpy.stack(session.cached_inputs for session in sessions)
kv_cache_state = numpy.stack(
session.cached_inputs for session in sessions
)
num_processed_tokens = numpy.stack(
session.total_num_processed_tokens for session in sessions
)

yield [tokens, logits, finish_reason, kv_cache_state, num_processed_tokens]
yield [
tokens,
logits,
finish_reason,
kv_cache_state,
num_processed_tokens,
]

yield [tokens, logits, finish_reason]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,6 @@ def _test_output(
run_cache_validation: bool = True,
):
# extract numpy arrays from cached_inputs
kv_cache_array = list(cache_session.cached_inputs.values())

(
generated_logits,
prompt_logits,
Expand Down

0 comments on commit 3a18e5f

Please sign in to comment.