Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/core/scheduler/continuous_scheduler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,36 @@ TEST(ContinuousSchedulerTest, BatchRejectedStreamsCancelAtSchedulingBoundary) {
EXPECT_TRUE(requests[1]->cancelled());
EXPECT_TRUE(scheduler->get_running_requests().empty());
}

TEST(ContinuousSchedulerTest,
BatchStreamMarksPrefillFinishedWhenFirstTokenDecodesEmpty) {
ContinuousScheduler::Options opt =
create_scheduler_options(1024, 16, 0, 1024, 1);
auto engine = std::make_unique<FakeEngine>(32, 4);
auto scheduler = std::make_unique<TestContinuousScheduler>(engine.get(), opt);

auto request = generate_request_with_prompt_tokens({1, 2, 3, 4}, 4, 30000);
request->state().stream = true;
make_request_decode_ready(request);

bool callback_called = false;
bool outputs_empty = false;
bool finished_on_prefill_instance = false;
request->state().outputs_func =
[&](const std::vector<RequestOutput>& outputs) {
callback_called = true;
outputs_empty = outputs.size() == 1 && outputs[0].outputs.empty();
finished_on_prefill_instance =
outputs.size() == 1 && outputs[0].finished_on_prefill_instance;
return std::vector<bool>{true};
};

scheduler->reject_streams({request});

EXPECT_TRUE(callback_called);
EXPECT_TRUE(outputs_empty);
EXPECT_TRUE(finished_on_prefill_instance);
}
// ============== Async RL training: Pause/Resume tests ==============

// TEST: pause()/resume() state transitions are correct and idempotent.
Expand Down
12 changes: 6 additions & 6 deletions xllm/core/scheduler/async_response_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ void AsyncResponseProcessor::batch_process_stream_requests(
auto seq_output = seq->generate_streaming_output(size, *tokenizer_);
if (seq_output.has_value()) {
req_output->outputs.push_back(std::move(seq_output.value()));
if (seq->num_generated_tokens() == 1) {
// currently only support one sequence when enable_service_routing
// IMPROVE LATER: support enable_schedule_overlap in Default mode
// for stream request
req_output->finished_on_prefill_instance = true;
}
}
if (seq->num_generated_tokens() == 1) {
// currently only support one sequence when enable_service_routing
// IMPROVE LATER: support enable_schedule_overlap in Default mode
// for stream request
req_output->finished_on_prefill_instance = true;
}
}
counter->decrement_count();
Expand Down
Loading