Skip to content

Commit 6d2645a

Browse files
committed
Add --prompt_file flag to the eagle3 runner
Reads the prompt text from a file instead of --prompt, mirroring the gemma4-31B runner. The prompt still goes through the normal encode + chat-template + BOS path, so this is independent of tokenization. Authored with assistance from Claude Code. ghstack-source-id: 4c633c4 ghstack-comment-id: 4734207725 Pull-Request: #20348
1 parent 1651349 commit 6d2645a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

examples/models/eagle3/main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#include <cstdint>
7676
#include <cstdio>
7777
#include <cstring>
78+
#include <fstream>
7879
#include <string>
7980
#include <vector>
8081

@@ -102,6 +103,10 @@ DEFINE_string(model_path, "", "Speculator model.pte path.");
102103
DEFINE_string(data_path, "", "Tensor data (.ptd) path for the CUDA backend.");
103104
DEFINE_string(tokenizer_path, "", "HuggingFace tokenizer.json path.");
104105
DEFINE_string(prompt, "Explain why the sky is blue.", "Prompt text.");
106+
DEFINE_string(
107+
prompt_file,
108+
"",
109+
"Read the prompt text from this file instead of --prompt.");
105110
DEFINE_bool(raw_prompt, false, "Skip the Gemma 4 IT chat template.");
106111
DEFINE_int32(max_new_tokens, 128, "Maximum tokens to generate.");
107112
DEFINE_int32(bos_id, 2, "BOS token id (-1 to skip; Gemma convention: 2).");
@@ -314,6 +319,16 @@ int main(int argc, char** argv) {
314319
}
315320

316321
std::string prompt_text = FLAGS_prompt;
322+
if (!FLAGS_prompt_file.empty()) {
323+
std::ifstream f(FLAGS_prompt_file);
324+
if (!f) {
325+
ET_LOG(
326+
Error, "Failed to open prompt file: %s", FLAGS_prompt_file.c_str());
327+
return 1;
328+
}
329+
prompt_text = std::string(
330+
std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>());
331+
}
317332
if (!FLAGS_raw_prompt) {
318333
prompt_text = FLAGS_chat_prefix + prompt_text + FLAGS_chat_suffix;
319334
}

0 commit comments

Comments
 (0)