You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[multimodal] Add token support to MultimodalInput (#14451)
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`.
0 commit comments