Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix][Text Generation] Fix the. outdated non-kv cache inference pathway #1328

Merged
merged 8 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions src/deepsparse/transformers/engines/nl_decoder_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ def run(

:return: The output of the engine
"""
if kv_cache is None:
# run the engine without the kv cache support
return self.engine.run(inputs, val_inp)

if bool(kv_cache.engine_internal_cache):
# run the engine assuming internal kv cache
# management. In this case the LIB.kv_cache
# class object will be passed to the engine
# call as well
# conventionally, before dispatching
# inputs to the engine, we validate them
# if val_inp=True. However, in this case
Expand All @@ -164,8 +172,10 @@ def run(
return self.engine._eng_net.execute_list_out(
inputs, kv_cache.engine_internal_cache
)
# run the engine without the LIB.kv_cache object
return self.engine.run(inputs, val_inp)
else:
# run the engine assuming external kv cache
# management.
return self.engine.run(inputs, val_inp, kv_cache)

def __call__(
self,
Expand Down
5 changes: 4 additions & 1 deletion src/deepsparse/transformers/pipelines/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,10 @@ def engine_forward(
)
for prompt_logit in prompt_logits:
token_generator.generate(prompt_logit)
return numpy.array([self.tokens]), prompt_logits
yield numpy.array([token_generator.tokens]), prompt_logits, [
dbogunowicz marked this conversation as resolved.
Show resolved Hide resolved
FinishReason.LENGTH
]
return

else:
# run the prompt through
Expand Down