Skip to content

Conversation

larryliu0820
Copy link
Contributor

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] [2]
  • 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] [2] [3] [4] [5]
  • 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.

Copy link

pytorch-bot bot commented Sep 19, 2025

🔗 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 Pending

As of commit 71dea2a with merge base 07d1092 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 19, 2025
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@larryliu0820 larryliu0820 merged commit 9e7a264 into main Sep 20, 2025
125 of 129 checks passed
@larryliu0820 larryliu0820 deleted the token_input branch September 20, 2025 00:51
StrycekSimon pushed a commit to nxp-upstream/executorch that referenced this pull request Sep 23, 2025
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants