Repository navigation
Studio: keep same-second fine-tuning jobs in submission order across restarts - #16835
Conversation
…ead of a waiting job
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…t navigate (#16858) ## Summary `Chat UI Tests` on Windows fails now and then in `tests/studio/playwright_browser_bookmarks.py`, on the step that follows a link inside the browser panel's page. In the last day it hit main itself (run 42143788184, after #16856) and #16835 and #16758, none of which touch the browser panel: ``` FAIL Save, followed=True: Locator expected to have Value 'https://bookmark.test/followed' Actual value: https://bookmark.test/first ``` The failure screenshot from the main run shows the typed page still loaded with "Follow link" on it. The click never produced a navigation, so the address bar stayed on the first page for the whole 5 s wait. The same Save and Enter cases pass in the same run and on the next run. All three failures were on the Windows lane. It looks like a click lost on a loaded Windows runner, not a regression: the page's link handler is installed before the page's own content, and the panel accepts the first same-tab navigation a page reports. ## Change `tests/studio/playwright_browser_bookmarks.py` only. A small `follow_link` helper clicks "Follow link" and waits 5 s for the address to change, as before. If it has not, and the address is still the typed page and the tab still says "Typed page", it clicks again, up to three clicks in total, and prints a line when it retries. It does not retry if the address moved anywhere else, so a wrong navigation still fails at once. A second click cannot double a slow navigation either: once a page has reported a same-tab navigation the panel ignores any further one from it (`left` in `page-frame.tsx`). Every later assertion (bookmark contents, Back to the first page, Forward to the followed one) is unchanged, so a link that really stops navigating still fails after the third click. ## Testing - A fake page and address bar drive `follow_link` through five cases: navigates on the first, second or third click (passes, 1/2/3 clicks), never navigates (fails after 3 clicks), lands on another page (fails after 1 click). - `tests/studio/test_playwright_suites_run_in_ci.py`: 9 passed.
|
Pushed 003b7cc on top of this branch: jobs created in the same second could still be skipped in an |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 003b7ccdb7
ℹ️ 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".
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…azily Order queue, live and persisted jobs in one heap keyed by creation time, then queue order and public id, so jobs created in the same second keep their place when a batch moves from live to history. Queue entries share the heap, so a short page reads only the history rows it needs. Regression tests ported from unslothai#16835. [skip ci]
|
Summary for head 003b7cc:
|
…hem (unslothai#16832) Listing fine-tuning jobs page by page through the OpenAI-compatible API could skip a job. When two compatible jobs started together as a Multi-LoRA batch while an older job kept waiting, the waiting job later started with a newer start time and jumped ahead of the batch in the history. A client that had already paged past the batch never saw it. Finished runs are now listed by the time the job was queued, falling back to the start time for runs that never went through the queue or predate it. The history keeps the order the jobs were submitted in, however the batches came out. Fixes unslothai#16720 Follow-up on this branch: queue, live and persisted jobs are ordered in one pass by creation time, with jobs created in the same second ordered by when they were queued, then by job ID. Before, those jobs could swap places when a batch moved from running to history, and a client could skip one. History is still read lazily: a short page reads only the rows it needs, even after a long backlog. Regression tests for these cases come from unslothai#16835. --------- Co-authored-by: Daniel Han <[email protected]>
|
Thank you for the PR! The goal of this PR is to stop This has since landed on main: #16832 (which closed #16720) carries the same creation-time heap ordering and the regression tests from this branch, and #16823 kept same-second ties on the public job id so the order is the same across restarts. The branch now conflicts with main, and resolving toward main leaves an empty diff apart from the in-process That counter reintroduces a skip across a backend restart, because it is held only in memory. Three finished jobs created in the same second (
|
…across restarts Replaces the in-process creation counter, which was lost on restart and let an after= walk skip a job. Jobs created in the same second are ordered by a nanosecond stamp saved in the alias table (new nullable created_ns column; older tables gain it on first use), then by public id.
|
Reopened and rescoped, sorry for the noise. The ordering fix itself is on main via #16832 and #16823, but main breaks same-second ties by the random job id, so |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7ed6761c2
ℹ️ 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".
| ) | ||
| _QUEUE.append(entry) | ||
| _ALIASES[entry.alias] = entry | ||
| _ALIAS_CREATED_NS[entry.alias] = time.time_ns() |
There was a problem hiding this comment.
Evict creation stamps with discarded terminal jobs
For queued jobs cancelled or failed before starting, _finish() limits retained terminal aliases to _TERMINAL_KEEP (256), but never removes their entries from this new timestamp dictionary. In a reproduction with 10,000 enqueue/cancel cycles, _QUEUE was empty and _ALIASES contained 256 entries, while _ALIAS_CREATED_NS still contained all 10,000. These discarded jobs have no persisted runs requiring their stamps, so repeated cancellation/retry workflows now cause unbounded memory growth in a long-running Studio process. Remove the corresponding stamps when unstarted terminal aliases are evicted.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 042a5eca8d
ℹ️ 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".
| # start is final. | ||
| def item(created_at: int, public_id: str, seq: int, row: dict[str, Any], is_run: bool): | ||
| return (-created_at, public_id, seq), row, is_run | ||
| return (-created_at, -_ALIAS_CREATED_NS.get(public_id, 0), public_id, seq), row, is_run |
There was a problem hiding this comment.
Stamp direct-start jobs before applying the new tie-breaker
When a queued job is cancelled and a replacement can start immediately within the same second, create_fine_tuning_job() bypasses _enqueue() for the replacement, so it has no _ALIAS_CREATED_NS entry. This new key puts the older cancelled job ahead of the unstamped replacement, making jobs.list(limit=1) return the older job; the previous public-ID tie-breaker returned the replacement in this scenario. Give direct-start API jobs a persisted creation stamp too so mixed queued/direct jobs retain submission order.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 00a6672: a directly started job now gets a stamp too, saved in the alias table under its usual public id (created_at still comes from the run), with a test covering the cancel-then-direct-start case before and after a restart.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Follow-up to #16720, #16832 and #16823.
When several fine-tuning jobs are created within the same second (a script submitting jobs in a loop),
GET /v1/fine_tuning/jobsbroke thecreated_attie by the random public job id. Sojobs.list(limit=1)could return an older job instead of the one just submitted, and the order among those jobs had nothing to do with submission order. An earlier revision of this branch fixed that with an in-process counter. That counter was lost when Studio restarted, so a client paging withafter=across a restart could skip a job (three same-second jobs, page 1 before a restart, page 2 after:ftjob_qanever returned).Jobs now get a nanosecond creation stamp when they are queued (kept strictly increasing, since Windows clocks can tick only every ~16 ms). It is saved with the job id mapping in the alias table, in a new nullable
created_nscolumn, and loaded back on start. Same-second jobs are ordered by that stamp, then by public id, so a job keeps its place from queued to running to history, and across restarts. Older alias tables gain the column the first time they are opened. Jobs the API starts directly, without queueing, get a stamp too: it is saved under their usual public id, and theircreated_atstill comes from the run. Rows without a stamp (runs started from the Studio UI, jobs from older builds) keep the public id order. Older builds name their columns explicitly when they read and write this table, so a downgrade still works.Verification:
test_a_job_batched_past_keeps_its_place_when_it_starts_between_pagesnow also runs across a simulated restart and asserts submission order when jobs share a second. On main, the 3 same-second cells fail and the 3 others pass. Here, all 6 pass.test_an_alias_table_from_an_older_build_loads_and_gains_the_ns_column: an alias table from an older build loads, gains the column, and saves new stamps.test_jobs_created_within_one_clock_tick_list_newest_submitted_first: with a frozen clock, jobs still list newest submitted first (fails without the strictly increasing stamp).test_a_job_started_directly_lists_ahead_of_an_older_same_second_job: a queued job is cancelled and a replacement starts directly in the same second. The replacement lists first, before and after a restart.test_openai_fine_tuning.py: 125 passed.test_training_api_snippet_contract.py+tests/multi_account(fine-tuning/training selection): 129 passed.