layer-major prefill on a split: a stale hand_in_ left by a chunk-major prompt no longer turns layer-major off (#3976)

run_impl never clears a later stage's hand_in_, so after one short prompt (read
chunk-major) every later prompt was declined with "a layer split's chunk hand-off
is in use". lm_prepare_chain now declines only when a hand-off is really in flight
(a stage's next_run_ is valid) and otherwise clears the stale hand-in pointers.
This commit is contained in:
Norihiro Nishimura authored and Niko1221 committed 2026-10-26 20:03:03 +01:00
1 parent 18c5357666
commit e7318fa23d
1 file changed
+10
+10
View File
@@ -5779,6 +5779,16 @@ int64_t Prefill::lm_prepare(int64_t n, std::string& why, int64_t cap) {
// A layer split: every stage gets the same super-chunk (the smallest any of them fits), re-sized until they agree.
int64_t Prefill::lm_prepare_chain(int64_t n, std::string& why) {
// a later stage's hand_in_ still points at the last chunk a chunk-major prompt handed it (run_impl never clears it):
// with no hand-off in flight that is stale, not in use (a short prompt first would otherwise turn layer-major off
// for every later prompt)
for (Prefill* p = this; p->next_ != nullptr; p = p->next_)
if (p->next_run_.valid()) { why = "a layer split's chunk hand-off is in flight"; return 0; }
for (Prefill* p = next_; p != nullptr; p = p->next_) {
p->hand_in_ = nullptr;
p->hand_ev_ = nullptr;
p->hand_pieces_ = 0;
}
int64_t cap = 0;
for (int round = 0; round < 4; ++round) {
bool same = true;