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 5 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
35 changes: 23 additions & 12 deletions src/deepsparse/transformers/engines/nl_decoder_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,29 @@ def run(

:return: The output of the engine
"""
if bool(kv_cache.engine_internal_cache):
# conventionally, before dispatching
# inputs to the engine, we validate them
# if val_inp=True. However, in this case
# we want to pass the empty kv cache inputs
# (batch_size=0) to the engine. Therefore,
# we skip the validation
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)
if kv_cache is not None:
# run the engine assuming kv cache support
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
# we want to pass the empty kv cache inputs
# (batch_size=0) to the engine. Therefore,
# we skip the validation
return self.engine._eng_net.execute_list_out(
inputs, kv_cache.engine_internal_cache
)
else:
# run the engine assuming external kv cache
# management.
return self.engine.run(inputs, val_inp, kv_cache)
else:
# run the engine without the kv cache support
return self.engine.run(inputs, val_inp)
dbogunowicz marked this conversation as resolved.
Show resolved Hide resolved

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