Skip to content

Commit 168f126

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Fix text_llm_runner unit test
Summary: This is a follow-up of #11570 (D76457271) We should not abort when num_prompt_tokens >= max_context_len, instead we should return error. Differential Revision: D76791781
1 parent be8ffd1 commit 168f126

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extension/llm/runner/text_llm_runner.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,13 @@ Error TextLLMRunner::generate_from_pos(
128128

129129
// Reduce max_context_len by start_pos
130130
int64_t max_context_len = metadata_.at(kMaxContextLen) - start_pos;
131-
ET_CHECK_MSG(num_prompt_tokens >= 1, "Expected at least 1 prompt token");
132-
ET_CHECK_MSG(
131+
ET_CHECK_OR_RETURN_ERROR(
132+
num_prompt_tokens >= 1,
133+
InvalidArgument,
134+
"Expected at least 1 prompt token");
135+
ET_CHECK_OR_RETURN_ERROR(
133136
num_prompt_tokens < max_context_len,
137+
InvalidArgument,
134138
"num_prompt_tokens %d >= max_context_len %" PRId64
135139
", Max seq length exceeded - please increase max seq len value in your export script",
136140
num_prompt_tokens,

0 commit comments

Comments
 (0)