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

[Add] sequence length to text gen pipelines #1518

Merged
merged 2 commits into from
Jan 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,7 @@ def __init__(
self.tokenizer = tokenizer if tokenizer else self.model.tokenizer

self._batch_size = batch_size
try:
self._max_length = pipeline.sequence_length
except Exception:
# workaround until the DeepSparse pipeline exposes the sequence_length
self._max_length = pipeline.ops["single_engine"].sequence_length

self._max_length = pipeline.sequence_length
self._max_gen_toks = max_gen_toks or 256

self.vocab_size = self.tokenizer.vocab_size
Expand Down
10 changes: 10 additions & 0 deletions src/deepsparse/transformers/pipelines/text_generation/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ def expand_inputs(self, items, batch_size):
def condense_inputs(self, *args, **kwargs):
return args[0], kwargs

@property
def sequence_length(self) -> int:
"""
Property to return the sequence length for the pipeline.
(relies on the single engine operator)

:return: the sequence length for the pipeline
"""
return self.ops["single_engine"].sequence_length

def _get_continuous_batching_scheduler(
self, batch_sizes: List[int], engines: List[EngineOperator]
) -> ContinuousBatchingScheduler:
Expand Down
Loading