Skip to content

Clarify ownership of runner components #10338

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

larryliu0820
Copy link
Contributor

@larryliu0820 larryliu0820 commented Apr 21, 2025

Summary:
The ownership of these components need some clarification.

  • Module should be shared by TextDecoderRunner and potentially TextPrefiller (or ImagePrefiller in multimodal runner).
  • TextDecoderRunner should be shared by the TextPrefiller and TextTokenGenerator.
  • Tokenizer should be owned by the Runner as well as TextTokenGenerator.

Differential Revision: D73399600

Copy link

pytorch-bot bot commented Apr 21, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/10338

Note: Links to docs will display an error until the docs builds have been completed.

⏳ 3 Pending, 1 Unrelated Failure

As of commit 8305e49 with merge base cfd1be3 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@facebook-github-bot facebook-github-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 Apr 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

@larryliu0820 larryliu0820 added the release notes: api Changes to public facing apis (any interfaces, pybinded runtime methods, etc.) label Apr 21, 2025
facebook-github-bot pushed a commit that referenced this pull request Apr 21, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be solely owned by `TextDecoderRunner`
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

facebook-github-bot pushed a commit that referenced this pull request Apr 21, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be solely owned by `TextDecoderRunner`
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

facebook-github-bot pushed a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
facebook-github-bot pushed a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:
Pull Request resolved: #10338

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
facebook-github-bot pushed a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
facebook-github-bot pushed a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:
Pull Request resolved: #10338

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:
Pull Request resolved: #10338

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
facebook-github-bot pushed a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

::executorch::extension::llm::Stats stats_;
std::unique_ptr<::executorch::extension::llm::Stats> stats_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we moving this to the heap?

Copy link
Contributor Author

@larryliu0820 larryliu0820 Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's because in my next PR TextTokenGenerator needs to share the same stats with Runner, TextTokenGenerator(stats) but also Runner constructor is going to take in a TextTokenGenerator. Runner(text_token_generator)

Therefore the only way I can think of is to:

auto stats = std::make_unique<Stats>();
auto text_token_generator = std::make_unique<TextTokenGenerator>(stats.get());
auto runner = std::make_unique<Runner>(std::move(stats), std::move(text_token_generator));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course I can put this change into next PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to avoid the heap allocation, you can have the Runner hand a pointer to its Stats object to the TextTokenGenerator, or you can have the runner create the TextTokenGenerator and leave the constructor as-is.

facebook-github-bot pushed a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

@larryliu0820 larryliu0820 changed the title Use unique_ptr and shared_ptr properly for runner components Clarify ownership of runner components Apr 22, 2025
facebook-github-bot pushed a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

Summary:
Pull Request resolved: #10338

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: kirklandsign

Differential Revision: D73399600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73399600

Copy link
Contributor

@swolchok swolchok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Reviewed By: swolchok, kirklandsign

Differential Revision: D73399600
larryliu0820 added a commit that referenced this pull request Apr 22, 2025
Summary:
Pull Request resolved: #10338

The ownership of these components need some clarification.

* `Module` should be shared by `TextDecoderRunner` and potentially `TextPrefiller` (or `ImagePrefiller` in multimodal runner).
* `TextDecoderRunner` should be shared by the `TextPrefiller` and `TextTokenGenerator`.
* `Tokenizer` should be owned by the `Runner` as well as `TextTokenGenerator`.

Differential Revision: D73399600

Reviewed By: kirklandsign
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. fb-exported release notes: api Changes to public facing apis (any interfaces, pybinded runtime methods, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants