Skip to content

Studio: renew the chat-run lease while long prefill is still advancing - #12619

Merged
danielhanchen merged 16 commits into
mainfrom
reland/pr-12523
Oct 3, 2026
Merged

danielhanchen merged 16 commits into
mainfrom
reland/pr-12523

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Re-opens #12523 for review. It was merged before its review converged and was reverted in #12569.

The change is the original squash commit, cherry-picked unchanged (git cherry-pick -x d8740d387), with authorship kept for @indrajeetapache. The full description and discussion are on #12523.
#12569 has merged, so this PR targets main and its diff shows only this change.

Etherll and others added 12 commits October 2, 2026 14:53
…and lighten both drag copies" (#12499)

This reverts commit 9838541. It was merged before Codex review converged; it will be re-opened for review.
…11187)" (#11361)

This reverts commit cd4d5c1. It was merged before Codex review converged; it will be re-opened for review.
… saved" (#12505)

This reverts commit a91ee37. It was merged before Codex review converged; it will be re-opened for review.
…advancing" (#12523)

This reverts commit d8740d3. It was merged before Codex review converged; it will be re-opened for review.
…row" (#12529)

This reverts commit 5b78baf. It was merged before Codex review converged; it will be re-opened for review.
…ersized request streams pinned groups" (#12526)

This reverts commit d883d2d. It was merged before Codex review converged; it will be re-opened for review.
…, Z-Image, Ideogram 4, Wan2.2 and HunyuanVideo-1.5" (#12516)

This reverts commit fd2522b. It was merged before Codex review converged; it will be re-opened for review.
…ndow" (#12514)

This reverts commit dae96ea. It was merged before Codex review converged; it will be re-opened for review.
…#12486)

This reverts commit ed6d0e8. It was merged before Codex review converged; it will be re-opened for review.
…names" (#12475)

This reverts commit 079dc91. It was merged before Codex review converged; it will be re-opened for review.
#12562 (make carried rows a faintly frosted, darker copy) landed after this
branch was cut and restyles the shared ghost rule that #12499 introduced: it
relies on --row-ghost-surface and .model-picker-row-ghost, and edits
model-picker-pinned-drag-preview.test.ts, all of which the #12499 revert
removes. Keeping it without #12499 leaves .sidebar-row-ghost reading an unset
variable, so the conflict is resolved by dropping #12562's two hunks as well.
It should be re-opened together with #12499. #12563, #12564 and #12597 are kept.
#12523)

* Studio: renew the chat-run lease while long prefill is still advancing

Dropped prompt_progress was replaced with : keep-alive, which the durable
lease deliberately ignores, so a healthy multi-minute prefill was reaped as
"Generation stopped making progress" (unslothai#12518). Stand in with
: prefill-progress and renew on it, same pattern as : tool-heartbeat.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: renew the lease from native GGUF prefill too

The Studio UI never sends client tools, so its GGUF chat and tool loop run
the native generators rather than the passthrough. Those consume
prompt_progress themselves and stay silent until the first token, so the
stall loop only ever sent ": keep-alive" and a long prefill was still
reaped after the lease ran out.

Wrap the GGUF perf callback in a small signal that counts moving
prompt_progress, and have both native stall loops send ": prefill-progress"
when it moved since the last tick. A generator that reports nothing still
gets ": keep-alive" and is still reaped. The wrapper opts out of per-token
timings unless a monitor is attached, and non-streaming requests keep the
plain monitor callback.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Etherl <[email protected]>
(cherry picked from commit d8740d3)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T15:56:14.833321Z 83086ef Manual request
🔒 Security Review ⚠️ Failed 2026-10-03T10:48:34.637141Z edee89b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from revert/unconverged-2026-10-02 to main October 3, 2026 10:51
danielhanchen and others added 3 commits October 3, 2026 03:51
#12523)

* Studio: renew the chat-run lease while long prefill is still advancing

Dropped prompt_progress was replaced with : keep-alive, which the durable
lease deliberately ignores, so a healthy multi-minute prefill was reaped as
"Generation stopped making progress" (unslothai#12518). Stand in with
: prefill-progress and renew on it, same pattern as : tool-heartbeat.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: renew the lease from native GGUF prefill too

The Studio UI never sends client tools, so its GGUF chat and tool loop run
the native generators rather than the passthrough. Those consume
prompt_progress themselves and stay silent until the first token, so the
stall loop only ever sent ": keep-alive" and a long prefill was still
reaped after the lease ran out.

Wrap the GGUF perf callback in a small signal that counts moving
prompt_progress, and have both native stall loops send ": prefill-progress"
when it moved since the last tick. A generator that reports nothing still
gets ": keep-alive" and is still reaped. The wrapper opts out of per-token
timings unless a monitor is attached, and non-streaming requests keep the
plain monitor callback.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Etherl <[email protected]>
(cherry picked from commit d8740d3)
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05ebc646d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +29521 to +29524
yield (
_OPENAI_PREFILL_PROGRESS_SSE
if _gguf_prefill_signal.advanced()
else _OPENAI_PASSTHROUGH_SSE_KEEPALIVE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Poll prefill before the shortest lease expires

When UNSLOTH_STUDIO_CHAT_RUN_LEASE_TIMEOUT_S is configured at or below 15 seconds, the lease is clamped to exactly 15 seconds, but this native GGUF loop can emit its first : prefill-progress marker only after the fixed 15-second stall timeout. Because reconciliation expires timestamps using <=, a sweep—especially with a short sweep interval or one aligned with this timer—can settle a healthy prefill before this marker is handled. Poll the progress signal on a cadence strictly shorter than the applied lease, or include this 15-second producer cadence plus margin in the lease clamp.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lease only drops to 15 s if UNSLOTH_STUDIO_CHAT_RUN_LEASE_TIMEOUT_S is set that low; the default is 1200 s with a 60 s sweep, so the 15 s prefill-progress poll renews well inside it and a live prefill is not reaped.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05ebc646d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 41858 to +41861
if not client_wants_progress and _is_prefill_progress_only(chunk_data):
_monitor_openai_sse_line(monitor_id, raw_line, llama_backend.context_length)
if progress_keepalive.due():
yield _OPENAI_PASSTHROUGH_SSE_KEEPALIVE
yield _OPENAI_PREFILL_PROGRESS_SSE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify passthrough progress advances before renewing the lease

When llama-server repeatedly emits the same prompt_progress.processed value, _aiter_llama_stream_items correctly treats it as non-advancing for the first-token deadline, but this branch still emits : prefill-progress whenever the wall-clock interval is due. The durable supervisor consequently renews the run lease for static progress, so a stalled passthrough generation can evade a shorter configured lease until the separate first-token timeout expires. Track the processed value here (and in the equivalent completions relay) and emit this marker only when it increases.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first-token deadline only extends when processed increases, so repeated progress values cannot keep a stalled run alive past the 1200 s first-token timeout, and a hung llama-server emits no progress events at all.

Comment on lines 41858 to +41861
if not client_wants_progress and _is_prefill_progress_only(chunk_data):
_monitor_openai_sse_line(monitor_id, raw_line, llama_backend.context_length)
if progress_keepalive.due():
yield _OPENAI_PASSTHROUGH_SSE_KEEPALIVE
yield _OPENAI_PREFILL_PROGRESS_SSE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep durable progress renewal when relay keepalives are disabled

When UNSLOTH_OPENAI_COMPAT_STREAM_KEEPALIVE_INTERVAL=0, _keepalive_s is None, so _ProgressKeepalive.due() is always false and every dropped prompt_progress event takes this continue without emitting : prefill-progress. _aiter_llama_stream_items still extends the first-token deadline for advancing progress, but the durable supervisor receives no renewal and can reap an otherwise healthy long prefill after its lease timeout. Durable lease signaling needs a cadence independent of the optional client/proxy keepalive setting.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs UNSLOTH_OPENAI_COMPAT_STREAM_KEEPALIVE_INTERVAL=0, an undocumented non-default setting that deliberately relays in silence; there behaviour matches main, and with the default interval the prefill-progress renewal is active.

@danielhanchen danielhanchen self-assigned this Oct 3, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 83086efda1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

The red Chat UI Tests here is not caused by this PR. The permission step fails on heading "Enable Full access?". #12630 reworded that dialog, which broke the step on main. The run was built on a main from before the fix: #12640 (merged as 93769f5) changes that lookup. A rebase onto main or a re-run of the Chat UI jobs should clear it.

@danielhanchen
danielhanchen merged commit 0b67c51 into main Oct 3, 2026
@danielhanchen
danielhanchen deleted the reland/pr-12523 branch October 3, 2026 17:37
JoshuaL3000 pushed a commit to JoshuaL3000/unsloth that referenced this pull request Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants