-
Notifications
You must be signed in to change notification settings - Fork 821
[multimodal] Add token support to MultimodalInput #14451
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/14451
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 7 PendingAs of commit 71dea2a with merge base 07d1092 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
This pull request adds support for tokenizer-encoded input (as vectors of token IDs) to the `MultimodalInput` class, enabling more flexible and efficient handling of multimodal data. The update includes new constructors, type checks, getters, and factory functions for token inputs, as well as unit tests to ensure correct behavior and compatibility with existing code paths. **MultimodalInput class changes:** * Added a new `TOKENS` type to the `MultimodalInput::Type` enum and updated the internal `std::variant` to support storing `std::vector<uint64_t>` as token data. [[1]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R34-R73) [[2]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1L290-R367) * Implemented new constructors, type checks (`is_tokens()`), getters (`get_tokens()`), and safe accessors (`try_get_tokens()`) for token inputs, along with static and instance methods for type name conversion. [[1]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R34-R73) [[2]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R101-R107) [[3]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R151-R159) [[4]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R187-R201) [[5]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R319-R328) * Added factory functions `make_token_input` for easily creating token-based inputs. **Integration and logging:** * Updated `MultimodalPrefiller::prefill` to handle both text and token inputs, bypassing tokenization when tokens are provided directly. * Added logging in `MultimodalRunner::generate` to include the type name of each input for easier debugging. **Tests:** * Introduced a comprehensive suite of unit tests covering construction, type checking, getters, copy/move semantics, and edge cases for the new token input functionality in `MultimodalInput`.
This pull request adds support for tokenizer-encoded input (as vectors of token IDs) to the `MultimodalInput` class, enabling more flexible and efficient handling of multimodal data. The update includes new constructors, type checks, getters, and factory functions for token inputs, as well as unit tests to ensure correct behavior and compatibility with existing code paths. **MultimodalInput class changes:** * Added a new `TOKENS` type to the `MultimodalInput::Type` enum and updated the internal `std::variant` to support storing `std::vector<uint64_t>` as token data. [[1]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R34-R73) [[2]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1L290-R367) * Implemented new constructors, type checks (`is_tokens()`), getters (`get_tokens()`), and safe accessors (`try_get_tokens()`) for token inputs, along with static and instance methods for type name conversion. [[1]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R34-R73) [[2]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R101-R107) [[3]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R151-R159) [[4]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R187-R201) [[5]](diffhunk://#diff-db31b7448019ab4684675434f5b6e8054ff5d995ffa18e7adee15b5a694a7fb1R319-R328) * Added factory functions `make_token_input` for easily creating token-based inputs. **Integration and logging:** * Updated `MultimodalPrefiller::prefill` to handle both text and token inputs, bypassing tokenization when tokens are provided directly. * Added logging in `MultimodalRunner::generate` to include the type name of each input for easier debugging. **Tests:** * Introduced a comprehensive suite of unit tests covering construction, type checking, getters, copy/move semantics, and edge cases for the new token input functionality in `MultimodalInput`.
This pull request adds support for tokenizer-encoded input (as vectors of token IDs) to the
MultimodalInputclass, enabling more flexible and efficient handling of multimodal data. The update includes new constructors, type checks, getters, and factory functions for token inputs, as well as unit tests to ensure correct behavior and compatibility with existing code paths.MultimodalInput class changes:
TOKENStype to theMultimodalInput::Typeenum and updated the internalstd::variantto support storingstd::vector<uint64_t>as token data. [1] [2]is_tokens()), getters (get_tokens()), and safe accessors (try_get_tokens()) for token inputs, along with static and instance methods for type name conversion. [1] [2] [3] [4] [5]make_token_inputfor easily creating token-based inputs.Integration and logging:
MultimodalPrefiller::prefillto handle both text and token inputs, bypassing tokenization when tokens are provided directly.MultimodalRunner::generateto include the type name of each input for easier debugging.Tests:
MultimodalInput.