backend: isolate core backend generation/input updates#65
Open
Parry-Parry wants to merge 24 commits into
Open
Conversation
…nd-infra-followup
refactor: tokenizer does not need a setter refactor: batch_size is only set for subclasses of Backend that need it
refactor: tokenizer does not need a setter refactor: batch_size is only set for subclasses of Backend that need it
This reverts commit 408748b.
Collaborator
There was a problem hiding this comment.
I thought we decided not to add batch_size to the base Backend?
(Also, it looks like these changes were pushed to main as well as this branch?)
cmacdonald
reviewed
Mar 6, 2026
cmacdonald
reviewed
Mar 6, 2026
| self.tokenizer.pad_token = self.tokenizer.eos_token | ||
| self._model.generation_config.pad_token_id = self.tokenizer.pad_token_id | ||
| self._tokenizer = AutoTokenizer.from_pretrained(model_id) | ||
| self._model = ( |
Collaborator
There was a problem hiding this comment.
whats the logic going on here - just one line comment please
cmacdonald
reviewed
Mar 6, 2026
| if not isinstance(inps, list): | ||
| raise TypeError("Expected list as input to generate(), found " + str(type(inps))) | ||
| if not isinstance(inps[0], str): | ||
| raise ValueError(f'{self!r} only supports str inputs to generate') |
Collaborator
There was a problem hiding this comment.
so if it allows lists of non strings, can we check that whether it supports is valid?
cmacdonald
reviewed
Mar 6, 2026
| sliced_sequences.append(sequences[i, prompt_length:]) | ||
| prompt_len_with_padding = inputs["input_ids"].shape[1] | ||
| for seq in sequences: | ||
| sliced_sequences.append(seq[prompt_len_with_padding:]) |
Collaborator
There was a problem hiding this comment.
did you test this change works as expected?
cmacdonald
requested changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR isolates backend runtime changes from prompt refactoring work. In particular, it allows batch_size to be passed through HF backends and adds message support
What changed
Updated backend core generation plumbing:
Added HuggingFace backend handling for modern input paths
Added vLLM backend handling for chat/message-style inputs: