Skip to content

Commit e289f6c

Browse files
Make token and stat callback optional in multimodal runner (#13950)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #13872 by @jackzhxng ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/jackzhxng/36/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/jackzhxng/36/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/jackzhxng/35/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/jackzhxng/36/orig @diff-train-skip-merge --------- Co-authored-by: Jack Zhang <[email protected]>
1 parent c1d973e commit e289f6c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

extension/llm/runner/multimodal_runner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ Error MultimodalRunner::load() {
6565
Error MultimodalRunner::generate(
6666
const std::vector<MultimodalInput>& inputs,
6767
const GenerationConfig& config,
68-
std::function<void(const std::string&)>& token_callback,
69-
std::function<void(const Stats&)>& stats_callback) {
68+
std::function<void(const std::string&)> token_callback,
69+
std::function<void(const Stats&)> stats_callback) {
7070
if (inputs.empty()) {
7171
ET_LOG(Error, "MultimodalInput vector cannot be empty");
7272
return Error::InvalidArgument;

extension/llm/runner/multimodal_runner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ class ET_EXPERIMENTAL MultimodalRunner {
116116
virtual ::executorch::runtime::Error generate(
117117
const std::vector<MultimodalInput>& inputs,
118118
const GenerationConfig& config,
119-
std::function<void(const std::string&)>& token_callback,
120-
std::function<void(const Stats&)>& stats_callback);
119+
std::function<void(const std::string&)> token_callback = {},
120+
std::function<void(const Stats&)> stats_callback = {});
121121

122122
inline void stop() {
123123
text_token_generator_->stop();

extension/llm/runner/text_token_generator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class ET_EXPERIMENTAL TextTokenGenerator {
3636

3737
/**
3838
* Token generation loop.
39-
* @param tokens prompt tokens as well as the first token generated by
40-
* prefill.
41-
* @param start_pos the start position of the new tokens, based on how many
39+
* @param tokens The first token generated by prefill, if using kv cache. Else
40+
* the prompt tokens + the first token generated by prefill.
41+
* @param start_pos The start position of the new tokens, based on how many
4242
* prompt tokens is prefilled.
4343
* @param max_new_tokens Maximum number of new tokens to generate.
4444
* @param temperature controls the randomness of predictions by scaling the

0 commit comments

Comments
 (0)