-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix pi0 prepare_language will raise an error if the task is a string #1625
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -392,6 +392,11 @@ def prepare_language(self, batch) -> tuple[Tensor, Tensor]: | |||||||||||||||||||
| """Tokenize the text input""" | ||||||||||||||||||||
| device = batch[OBS_STATE].device | ||||||||||||||||||||
| tasks = batch["task"] | ||||||||||||||||||||
| if isinstance(tasks, str): | ||||||||||||||||||||
| tasks = [tasks] | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if len(tasks) == 1: | ||||||||||||||||||||
|
Comment on lines
+395
to
+398
|
||||||||||||||||||||
| if isinstance(tasks, str): | |
| tasks = [tasks] | |
| if len(tasks) == 1: | |
| was_string = isinstance(tasks, str) # Track if the input was originally a string | |
| if was_string: | |
| tasks = [tasks] | |
| if was_string or len(tasks) == 1 and len(tasks) != batch[OBS_STATE].shape[0]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
len(tasks) == 1will always be true after the previous block that converts a string to a single-element list. This means single tasks will always be replicated to match batch size, even when the original input was already a list with one element that shouldn't be replicated.