Skip to content

CI: run the three Windows inference smokes as phases of one job - #8013

Merged
danielhanchen merged 4 commits into
mainfrom
ci/merge-windows-inference-phases
Aug 6, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
ci/merge-windows-inference-phases

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

openai-anthropic, tool-calling and json-images differed only in model, port and test body. The checkout, setup-node, setup-python, npm/Defender tweaks, install.ps1 --local --no-torch and prebuilt assertion were identical in all three, so every triggering PR ran the same Windows install three times concurrently.

Why Windows and not Linux

This is measured, not assumed. Consolidating trades wall time for concurrency slots, and that only pays when per-job setup S dominates test time T (the saving is 2S - C). From recent successful runs:

setup S tests T verdict
Windows 7.0 min (install.ps1 alone is 6.4) 3.8 min setup dominates, consolidate
Ubuntu 1.9 min 3.0 min tests dominate, leave parallel
macOS 2.1 min 2.1 min already done in #7978, forced by the hard 5-slot cap

So this saves ~14 runner-minutes and 2 of the 60 concurrent-job slots, at roughly +4 min of wall time on this workflow. I deliberately did not make the same change to studio-inference-smoke.yml (ubuntu): there it would add more feedback latency than the slots are worth, and minutes are free on public repos.

Windows jobs on this workflow: 10 to 8.

Collisions the merge had to resolve

All three jobs were written assuming they owned the runner, so merging them surfaced real conflicts rather than just concatenating:

collision resolution
cache-hf / prime-hf step ids in both phase 1 and phase 3 phase-scoped: cache-hf-vision, prime-hf-vision
both used the hf-cache directory and the same HF_HOME split into hf-cache, gguf-cache-tools, hf-cache-vision
all three wrote logs/studio.log studio.log / studio_tools.log / studio_vision.log

Model, GGUF file, port and HF_HOME move from job-level env: to per-phase $GITHUB_ENV writes, and the cache keys inline their values as literals. That follows #7978: if a phase-specific key were also declared at job level, whether the later $GITHUB_ENV write wins is not something the Actions docs pin down, and a phase quietly talking to the previous phase's port would be a nasty way to find out.

Phase independence is preserved, not assumed

Each phase is gated on the shared preamble (!cancelled() && steps.assert-prebuilt.outcome == 'success'), not on the phase before it. One failing phase therefore does not swallow the next, and a failure still points at a single phase.

The nine Stop Unsloth / Collect llama-server logs / Upload logs steps keep their always() verbatim so logs survive a failure. Worth flagging that I got this wrong first time: a blanket "gate every step" pass added a second if: key to 10 steps that already had one, including those always() steps. YAML keeps the last, so it would have silently changed when logs get collected. Existing conditions are now ANDed with the gate rather than replaced.

Every step that can block carries its own timeout-minutes. The 90 min job cap is the outer guard only, because hf-download-with-retry.sh retries forever by design and named the job timeout as its bound (the gap #7978 had to close).

Verification

  • Workflow parses; no duplicate step ids, no duplicate if: keys, ports/log files/cache dirs/artifact names all distinct per phase.
  • No dangling needs: or cross-references to the three removed job ids.
  • Assertion-preservation diff: the set of test commands extracted from every workflow is identical before and after, 121 commands. All three phase bodies are intact (Multi-turn determinism, Tool calling, JSON schema decoding + image input).
  • Staging CI to follow on this PR.

openai-anthropic, tool-calling and json-images differed only in model,
port and test body. The checkout, setup-node, setup-python, npm/Defender
tweaks, install.ps1 --local --no-torch and prebuilt assertion were
identical in all three, so every triggering PR ran the same Windows
install three times concurrently.

Windows is where that actually costs something. Measured over recent
successful runs, setup is ~7.0 min per job (install.ps1 alone is ~6.4)
against ~3.8 min of tests. Setup dominates, so sharing it once saves
~14 runner-minutes and 2 of the 60 concurrent-job slots, at roughly
+4 min of wall time on this workflow.

The same trade is deliberately NOT made on ubuntu. In
studio-inference-smoke.yml setup is ~1.9 min against ~3.0 min of tests,
so consolidating there would add more feedback latency than the slots
are worth, and minutes are free on public repos.

Phase independence is preserved rather than assumed. Each phase keeps
its own model cache directory (hf-cache, gguf-cache-tools,
hf-cache-vision), its own HF_HOME, port, server log and artifact, and
each phase is gated on the SHARED preamble rather than on the phase
before it, so one failing phase does not swallow the next and earlier
logs survive.

Collisions the merge had to resolve, since all three were written
assuming they owned the runner: the cache-hf and prime-hf step ids
appeared in both phase 1 and phase 3, both used the hf-cache directory
and the same HF_HOME, and all three wrote logs/studio.log. Ids are now
phase-scoped, cache directories are split, and the logs are
studio.log / studio_tools.log / studio_vision.log.

Model, GGUF file, port and HF_HOME move from job-level env to per-phase
$GITHUB_ENV writes, and the cache keys inline their values as literals,
so no phase can inherit another's. Every step that can block carries its
own timeout-minutes; the 90 min job cap is the outer guard only, because
hf-download-with-retry.sh retries forever by design.

Windows jobs on this workflow: 10 to 8. Validated with actionlint (clean
apart from the four pre-existing windows-2025-vs2026 custom-label
warnings that main already emits) and an assertion-preservation diff:
the set of test commands across all workflows is unchanged at 121.
@danielhanchen
danielhanchen force-pushed the ci/merge-windows-inference-phases branch from d37b475 to 578767f Compare August 6, 2026 10:39

@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: d37b4752c5

ℹ️ 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".

node-version: '22'

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
- name: Phase 1 environment (API + auth)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Attach python-version to the setup-python step

Inserting this new list item here separates actions/setup-python from its with: block: python-version: '3.12' is now attached to this shell step instead of the action. A run step cannot consume action inputs, so GitHub may reject the workflow during validation; even if accepted, setup-python no longer selects Python 3.12. Move the environment step below the action's with: block.

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.

Correct, and already fixed at head in 578767f -- this review landed against the pre-force-push commit d37b475.

The diagnosis is exactly right. I assembled the merged job from line ranges of the original file and my shared-preamble range ended one step early, slicing actions/setup-python between its uses: and its with:, so the new phase-env step landed in the gap. GitHub rejected the whole workflow, which is the stronger of the two outcomes you predicted:

151:9: this step is for running shell command since it contains at least one of
"run", "shell" keys, but also contains "with" key which is used for running action

Worth noting why my own checks missed it and yours would not have: yaml.safe_load parses that happily, and so does a strict duplicate-key loader, because it is valid YAML and only invalid as an Actions workflow. I have added actionlint to the loop for this file, which is what named it.

At head, setup-python has its with: python-version: '3.12' back and Phase 1 environment follows the complete step.

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
- name: Phase 2 environment (tool calling)

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 Run phase environment setup after earlier phase failures

When any Phase 1 test fails after the shared preamble succeeds, this step is skipped by the implicit success() condition, but the following Phase 2 steps explicitly use !cancelled() && steps.assert-prebuilt.outcome == 'success' and therefore still run. They then inherit Phase 1's repository, file, port, and cache values, so the tool phase can download or contact the wrong model/server; Phase 3 has the same problem after a Phase 2 failure. Give each phase-environment step the same explicit status condition as its phase.

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.

Genuine bug, fixed in 852da21. This is the sharpest item of the three.

Confirmed the asymmetry directly rather than reasoning about it:

Phase 1 environment (API + auth)      if=(implicit success())
Phase 2 environment (tool calling)    if=(implicit success())   <- rode success()
Restore GGUF model cache              if=!cancelled() && steps.assert-prebuilt.outcome == 'success'
Reset auth + boot Unsloth             if=!cancelled() && steps.assert-prebuilt.outcome == 'success'

So a phase 1 TEST failure skipped Phase 2 environment while every gated step below it still ran, and phase 2 would then have executed with phase 1's GGUF_REPO, GGUF_FILE, STUDIO_PORT=18888 and HF_HOME. Not just the wrong model: the cache save would have written phase 1 content under phase 2's key, poisoning it for later runs.

That is precisely the failure mode the job header warns about ("a phase quietly talking to the previous phase's port would be a nasty way to find out"), which makes it a fair hit -- I wrote the warning and then left the gap open in the steps that set those very values.

Both later phase-environment steps now carry their phase's gate. Phase 1's stays ungated on purpose: it runs before the install and the assert, so there is no assert-prebuilt outcome to gate on yet.

Comment on lines 541 to +542
UNSLOTH_API_ONLY=1 unsloth studio -H 127.0.0.1 -p "$STUDIO_PORT" \
> logs/studio.log 2>&1 &
> logs/studio_tools.log 2>&1 &

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 Terminate each server before booting the next phase

On every successful multi-phase run, this starts a second Unsloth instance while Phase 1 is still alive: the preceding Stop Unsloth step is explicitly a no-op that relied on the runner reclaiming processes at job end, which was safe only when each smoke was a separate job. Phase 2 and Phase 3 therefore retain the preceding studio and llama-server processes and their loaded models, increasing memory pressure and sharing auth/log state; terminate each phase's process before starting the next one.

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.

Genuine, and a regression this PR introduced. Fixed in 852da21.

Confirmed the step is literally a no-op:

shell: cmd
run: echo Stop Unsloth (no-op; runner reclaims STUDIO_PID=%STUDIO_PID% at job end)

You are right that the reliance on job-end reclamation was only sound while each smoke was its own job. The memory pressure is the visible cost; the one that worried me more is auth state, since each phase does rm -rf ~/.unsloth/studio/auth and boots expecting to re-seed a fresh .bootstrap_password while a previous server still owns that directory.

The obvious fix is the one that was already tried and reverted, so I checked the history before writing it. kill "${STUDIO_PID}" under Git Bash on windows-latest exits 143 (SIGTERM) and fails the step, which is why #5460 and then #5462 ended at the cmd marker:

bash on windows-latest exits with that signal before any inline guard runs, regardless of redirection

So the fix avoids both traps:

  • pwsh, not Git Bash, so the 143 behaviour is out of scope entirely.
  • Kill by listening port, not by PID. STUDIO_PID is bash's $!, an MSYS pid that Stop-Process/taskkill cannot resolve to the real Windows process, so a PID-based fix would have silently no-op'd and looked like it worked.
  • $ErrorActionPreference = 'SilentlyContinue' and a closing exit 0, so teardown still cannot fail the job -- the property ci: switch Windows Stop Studio to a cmd no-op marker #5462 was protecting.

It also logs which pid it stopped and whether the port ended up free, so a future regression here is visible in the log rather than silent.

Re-validating on staging now.

@danielhanchen

Copy link
Copy Markdown
Member Author

Force-pushed a fix: the first push had a workflow syntax error and GitHub rejected the file outright.

Staging caught it immediately, and the symptom is worth recording because it is easy to misread: the run appears named after the raw path (.github/workflows/studio-windows-inference-smoke.yml) rather than the workflow's name:, with no jobs and no annotations exposed through the API.

Cause. I assembled the merged job from line ranges of the original file, and my shared-preamble range ended one step too early, cutting actions/setup-python between its uses: and its with:. The new Phase 1 environment step landed in the gap, producing a step with both run and with:

      - uses: actions/setup-python@a309ff8b...
      - name: Phase 1 environment (API + auth)
        run: |
          ...
        with:              # <- orphaned from setup-python
          python-version: '3.12'

Why my checks missed it. yaml.safe_load parses that happily, and so does a strict duplicate-key loader, because it is valid YAML and only invalid as an Actions workflow. I have added actionlint to the loop, which names it exactly:

151:9: this step is for running shell command since it contains at least one of
"run", "shell" keys, but also contains "with" key which is used for running action

actionlint is now clean on this file apart from four windows-2025-vs2026 custom-runner-label warnings, which I verified main emits identically (same count, same lines).

A second bug this round, also caught before merge. My first gating pass appended if: to every step in phases 2 and 3, which added a second if: key to 10 steps that already had one, including the nine Stop Unsloth / Collect llama-server logs / Upload logs steps carrying always(). YAML keeps the last key, so that would have silently changed when logs get collected on a failure. Existing conditions are now ANDed with the gate, and always() steps are left untouched.

Re-verified after the fix: unique step ids, three distinct cache directories, three distinct ports and log files, unique artifact names, nine always() steps intact, no unbounded blocking step, no duplicate if: keys, and the assertion-preservation diff still identical at 121 test commands.

@danielhanchen

Copy link
Copy Markdown
Member Author

Staging CI green: danielhanchen/unsloth-staging-2 run 31094104433.

The merged job passed in 667s (11.1 min) with all three phases executing:

step result
Phase 1 environment (API + auth) success
Install Unsloth (--local, --no-torch) success
Assert install.ps1 used the Windows llama.cpp prebuilt success
Phase 2 environment (tool calling) success
Tool calling, server-side tools, thinking on/off success
Phase 3 environment (JSON + vision) success
JSON schema decoding + image input success

All seven other Windows jobs in the workflow are green too (no-vs-cpu, no-vs-gpu-resolve, pester, both vs-integration legs, both vcredist-clean-box legs).

One honest note on the numbers: 11.1 min is close to the ~10.8 min the slowest single job took before, i.e. much better than the ~+4 min I predicted in the description. That run had warm model caches, so I would treat +4 min as the cold-cache upper bound rather than revise the estimate on a single sample. The slot saving does not depend on which case you get.

Two real defects the consolidation introduced, both found in review.

Phase environment steps rode the implicit success() while every other
step in their phase carried the explicit
`!cancelled() && steps.assert-prebuilt.outcome == 'success'` gate. A
phase 1 TEST failure therefore skipped 'Phase 2 environment' but still
ran the rest of phase 2, which then inherited phase 1's GGUF_REPO,
GGUF_FILE, STUDIO_PORT and HF_HOME: the tool phase would have talked to
the previous phase's port and cached under the wrong key. Exactly the
failure the job header warns about. Both later phase environment steps
now carry their phase's gate.

Stop Unsloth was an explicit no-op that relied on the runner reclaiming
the process at job end. That was correct while each phase was its own
job; in one job the phase 1 server stayed alive through phases 2 and 3,
holding its model resident and still owning ~/.unsloth/studio/auth while
the next phase wipes and re-seeds that directory for a fresh bootstrap
password.

The obvious fix is the one that was already tried and reverted: a plain
`kill` under Git Bash exits 143 and fails the step (#5460, #5462). This
runs under pwsh instead, so it never goes through Git Bash, and kills by
listening port rather than PID, because STUDIO_PID is bash's $! -- an
MSYS pid that Stop-Process cannot resolve to the real Windows process.
Every failure is swallowed and the step ends in exit 0, so teardown still
cannot fail the job.

The third review item, setup-python being separated from its with block,
was real but already fixed in 578767f: it was the syntax error actionlint
caught before the review landed.

@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: 852da21cb3

ℹ️ 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".

# block also carries its own `timeout-minutes`: the job cap alone is not a
# substitute, because hf-download-with-retry.sh retries forever by design and
# named the job timeout as its bound.
timeout-minutes: 90

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 Restore a timeout for each consolidated phase

When Phase 1 stalls, this shared 90-minute cap is now the only outer bound, so it can consume the entire job and prevent the tool and vision phases from running. The Phase 1 load step still permits three 600-second attempts and its SDK test has no step timeout; previously the 30-minute Phase 1 job could time out without affecting the other two parallel jobs. Add step or phase-equivalent timeouts matching the old per-job limits so a hung phase cannot suppress the remaining coverage.

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.

Genuine, and I had not accounted for it. Fixed in 8df4e8e.

The old jobs bounded themselves: openai-anthropic 30, tool-calling 30, json-images 35. Three parallel jobs meant a hang cost one job and the other two still reported. One job at 90 turns that into a total loss of the two phases behind it, and you correctly identified which steps were unbounded -- I had put step timeouts on the caches, install and health waits, but not on the boot, rotation, load or test steps:

14 Reset auth + boot Unsloth (API-only)         to=None   ->  2
16 Password rotation                            to=None   ->  3
17 Load the GGUF                                to=None   -> 20
18 Multi-turn determinism via SDKs              to=None   -> 12
26 Reset auth + boot (tool policy)              to=None   ->  2
28 Tool calling, server-side tools, thinking    to=None   -> 15
36 Reset auth + boot (vision)                   to=None   ->  2
38 JSON schema decoding + image input           to=None   -> 15

Step timeout-minutes is the right instrument here rather than a phase-level cap, because it produces a failure, not a cancellation. The later phases gate on !cancelled() && steps.assert-prebuilt.outcome == 'success', so a phase that blows its own step budget fails and the remaining phases still run -- which is the isolation property the three jobs had. A cancellation would have taken the whole job down with it and left you no better off.

This also matches the already-merged Mac consolidation, which carries step timeouts throughout for the same reason.


- name: Install Unsloth (--local, --no-torch)
id: install
if: ${{ !cancelled() }}

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 Preserve the shared setup failure gate

If an installer unit test, setup action, or pre-install tweak fails, the intervening default-conditioned steps are skipped, but this explicit !cancelled() still runs the installer; if that succeeds, the later phases gated only on assert-prebuilt also run without the pinned Python/Node setup or other skipped prerequisites. This defeats the existing fast gate and can produce misleading downstream failures on an incompletely prepared runner; distinguish Phase 1 cache failures from shared-preamble failures rather than bypassing every prior failure here.

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.

Correct, and it is a regression this PR introduced rather than a pre-existing gap. Fixed in 8df4e8e.

Checked all three original jobs at the merge base:

--- openai-anthropic
   Install Unsloth (--local, --no-torch)   if=None
--- tool-calling
   Install Unsloth (--local, --no-torch)   if=None
--- json-images
   Install Unsloth (--local, --no-torch)   if=None

No if: on any of them, so all three rode the implicit success() and a failed preamble stopped the job before installing. The !cancelled() came from the blanket gating pass and is wrong for this step specifically, for exactly the reason you give: the installer does not depend on setup-python or setup-node succeeding, so it can pass on a runner where they did not, assert-prebuilt then passes, and all three phases run on an incompletely prepared box and fail somewhere unrelated.

Rather than trying to distinguish cache failures from preamble failures with a compound condition, I removed the if: entirely so the step is back to main's semantics exactly. assert-prebuilt gates on steps.install.outcome == 'success', and a skipped step reports skipped, so the phases below skip too -- the fast gate you are describing works again with no extra machinery. Comment added above the step so the next blanket pass leaves it alone.

key: ${{ runner.os }}-gguf-unsloth/Qwen3.5-2B-GGUF-Qwen3.5-2B-UD-Q4_K_XL.gguf-v1

- name: Reset auth + boot Unsloth (API-only, default tool policy)
if: ${{ !cancelled() && steps.assert-prebuilt.outcome == 'success' }}

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 Stop each phase after its own prerequisite fails

When Phase 2's download or server boot fails, this condition remains true because it checks only the shared install assertion, so the load step and tool test still run without their model, server, or API_KEY; Phase 3 repeats the same pattern. Although the job is already red, these long cascading failures waste runner time and obscure the original error. Gate each step on its preceding phase-local prerequisite while keeping only the first step of each phase independent of failures in earlier phases.

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.

Real, and your framing of the fix is the right one -- phase-local prerequisite, first step of each phase still independent. Fixed in 8df4e8e.

Worth recording why phases differ, because it is not symmetric: phase 1 carries no if: at all and therefore rides the implicit success(), so it already chained correctly. Only phases 2 and 3 had the flat gate, which is where the blanket pass reached.

Phase 2 now reads:

26 Reset auth + boot   id=boot-tools    ... && steps.download-gguf-tools.outcome != 'failure'
27 Wait/login/load     id=ready-tools   ... && steps.boot-tools.outcome  == 'success'
28 Tool calling                          ... && steps.ready-tools.outcome == 'success'

and phase 3 the same via prime-hf-vision -> boot-vision -> ready-vision. Every clause keeps !cancelled() && steps.assert-prebuilt.outcome == 'success' as its first term, so cross-phase independence is untouched.

The download clause is != 'failure' rather than == 'success' deliberately: on a cache hit the download step is skipped, and == 'success' would have made a warm cache skip the entire phase.

One note for the record: the merged Mac consolidation uses the flat dialect throughout and has the same weakness. I am not changing it in this PR, since it is a different file and deserves its own diff, but it should get the same treatment.

Comment on lines +548 to +549
path: gguf-cache-tools
key: ${{ runner.os }}-gguf-unsloth/Qwen3.5-2B-GGUF-Qwen3.5-2B-UD-Q4_K_XL.gguf-v1

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 Bump keys for both renamed cache directories

The tool cache moved from gguf-cache to gguf-cache-tools while retaining its -v1 key, and the vision cache similarly moved from hf-cache to hf-cache-vision while retaining -v2. Because actions/cache includes the path in its cache-version hash, existing entries under these keys no longer restore into the renamed paths, and saves can be refused because the old key is already reserved; the matching consolidated Mac workflow documents this observed perpetual-miss behavior. Bump both renamed caches' key suffixes.

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.

Correct on both counts, and I should have caught this -- I am the one who measured it. Fixed in 8df4e8e.

You are right that the Mac workflow documents it, and it documents it because it happened there first:

Measured on staging before the bump: two consecutive runs both logged "Cache not found for input keys" and both failed to save.

The mechanism is exactly as you describe: an entry is identified by key AND a version hash derived from path, but key uniqueness is global per ref, so the surviving gguf-cache entry keeps the -v1 key while a restore into gguf-cache-tools misses on version, and the save comes back "Unable to reserve cache with key ... another job may be creating this cache". The phase re-downloads on every run, forever, and nothing in the log says why.

Both renamed paths bumped:

gguf-cache-tools   ...-Qwen3.5-2B-UD-Q4_K_XL.gguf-v1   ->  -v2
hf-cache-vision    ...-UD-IQ2_XXS-mmproj-F16.gguf-v2   ->  -v3

Phase 1's hf-cache path is unchanged, so its -v2 key stays as-is and its warm cache survives. Carried the explanation into this file rather than leaving a cross-reference, since the next person renaming a cache dir here will be reading this file.

Four things the three separate jobs gave for free, which merging them lost:

Per-step timeouts. The old jobs capped themselves at 30/30/35 minutes, so a
hung phase died on its own and the other two ran anyway. One job with a single
90-minute cap means a hang in phase 1 eats the whole budget and phases 2 and 3
never start. The unbounded steps (boot, password rotation, model load, and the
three test steps) now carry step timeouts. A step timeout is a failure, not a
cancellation, so the later phases still run behind their !cancelled() gates.

The install gate. It had picked up 'if: ${{ !cancelled() }}' during the blanket
gating pass, which is wrong for that step specifically: on main it had no 'if:'
and rode the implicit success(), so a failed preamble stopped the job. With
!cancelled() a broken setup-python or setup-node would still install,
assert-prebuilt would pass, and all three phases would run on an
incompletely prepared runner. Removed, with a comment saying why it stays off.

Phase-local prerequisites. Phase 1 rides success() and so chains correctly, but
phases 2 and 3 gated every step on the shared assert-prebuilt alone, so a failed
download or a server that never came up still ran the test against it. Each
phase now also gates on its own download and boot, which keeps the
phase-independence the shared gate buys while restoring within-phase chaining.

Cache keys. gguf-cache -> gguf-cache-tools and hf-cache -> hf-cache-vision kept
their -v1/-v2 suffixes. actions/cache identifies an entry by key AND a version
hash over 'path', but key uniqueness is global, so the renamed paths would miss
forever and never save. This is the same failure measured on staging during the
Mac consolidation; bumped to -v2 and -v3.

@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: 8df4e8e5a5

ℹ️ 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".

# implicit success(), so a phase 1 TEST failure would skip it while the
# gated steps below still ran -- and they would then inherit the previous
# phase's model, port and HF_HOME.
if: ${{ !cancelled() && steps.assert-prebuilt.outcome == 'success' }}

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 Gate later phases on the shared shim setup

When Add Unsloth shim to GITHUB_PATH fails after assert-prebuilt succeeds, this condition remains true, so both later phases proceed until their boot commands fail because unsloth is unavailable. Fresh evidence after the earlier preamble fix is that this shared prerequisite now occurs after assert-prebuilt, and the final-tree gates still check only the assertion; record the shim step's outcome and include it in the later-phase gate.

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.

Real. Fixed in c0e0543.

The gate was keyed on assert-prebuilt because that was the last shared step when I wrote it; the shim and the SDK install were added to the shared preamble after it, and the gates never moved. A failed shim left the gates true and both later phases booted a Studio that is not on PATH.

Repointed all fourteen phase gates onto the shim step itself:

 8 Add Unsloth shim to GITHUB_PATH   id=shim   if=!cancelled() && steps.assert-prebuilt.outcome == 'success'
22 Phase 2 environment                         if=!cancelled() && steps.shim.outcome == 'success'
32 Phase 3 environment                         if=!cancelled() && steps.shim.outcome == 'success' && steps.sdks.outcome == 'success'

Keying on the shim rather than ANDing it in is deliberate and not just brevity: the shim step itself only runs when assert-prebuilt succeeded, so steps.shim.outcome == 'success' already implies the assertion passed. One term, strictly stronger than the old one, and there is one place to extend if another shared prerequisite is ever added. Comment on the shim step records that contract so the next person does not re-point the gates back.

(The first draft of this had the shim gating on its own outcome. Caught it in the step dump before pushing.)

Comment on lines 300 to 303
- name: Install OpenAI + Anthropic Python SDKs
if: ${{ !cancelled() && steps.assert-prebuilt.outcome == 'success' }}
timeout-minutes: 10
run: python -m pip install 'openai>=1.50' 'anthropic>=0.40'

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 Gate the vision phase on SDK installation

When this pip installation fails transiently after the shared assertion passes, the explicit Phase 3 gates still run its cache download, server boot, and model load, only for the test to fail on its openai/anthropic imports. Before consolidation the vision job installed these SDKs itself; either retain a phase-local installation or include this step's outcome in the Phase 3 prerequisites so it does not spend most of the phase cascading from a known missing dependency.

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.

Correct, including the detail that the vision job used to install them itself. Fixed in c0e0543.

Confirmed against the merge base rather than taking it on trust -- json-images had its own SDK install and tool-calling did not:

--- json-images                          --- tool-calling
    9 Add Unsloth shim to GITHUB_PATH        9 Add Unsloth shim to GITHUB_PATH
   10 Install OpenAI + Anthropic SDKs       10 Reset auth + boot Unsloth
   11 Reset auth + boot Unsloth             11 Wait for health, log in, load model

So I kept the shared install and gated phase 3 on it, rather than restoring a phase-local copy -- deduplicating that install is part of what the consolidation buys. All six phase-3 gates now carry && steps.sdks.outcome == 'success'.

Phase 2 deliberately does not, for the reason your own diff shows: it drives the API with curl and never imports openai or anthropic, so a pip failure there should not cost the tool-calling coverage. Noted that asymmetry in a comment on the SDK step so it does not look like an oversight.

Phase 1 needs them too and gets it for free -- it rides the implicit success(), so the failed pip already skips it.

@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: 8df4e8e5a5

ℹ️ 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 +487 to +488
$owners = (Get-NetTCPConnection -LocalPort $port -State Listen).OwningProcess |
Sort-Object -Unique

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 Kill Studio even when it never binds its port

When Studio hangs during startup before binding STUDIO_PORT—the following health wait explicitly accommodates this failure mode—Get-NetTCPConnection -State Listen returns no owner, so this teardown kills nothing and the later !cancelled() phases start additional Studio processes on the same runner. This can retain shared auth state or other resources and reintroduce the cross-phase interference the consolidation is intended to prevent. Fresh evidence beyond the earlier no-op teardown finding is that the final cleanup now targets only a listening socket, with no fallback for the still-live pre-bind process.

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.

Real, and a hole in my own fix from the previous round. Fixed in c0e0543.

You picked the right piece of evidence: the health wait polls for 180 seconds precisely because Studio can take a long time to bind, so 'hung before binding' is a state this workflow already knows about, and a port-based teardown is blind to exactly that state.

Added a command-line sweep after the port kill:

$stragglers = Get-CimInstance Win32_Process |
              Where-Object { $_.CommandLine -match 'unsloth' -and
                             $_.CommandLine -match 'studio' -and
                             $_.ProcessId -notin $owners }

Both terms are required on purpose. The workspace path on a runner is D:\a\unsloth\unsloth, so matching unsloth alone would match anything running out of the checkout, including the step's own shell; requiring studio as well scopes it to the server. -notin $owners keeps it from re-stopping what the port pass already handled, and $owners being $null on the no-listener path is fine -- -notin $null is true.

Still under $ErrorActionPreference = 'SilentlyContinue' with the closing exit 0, so this cannot fail the job, which was the property #5462 was protecting when it made the step a no-op in the first place.

Comment on lines +240 to 246
# Deliberately NO `if:`, so this rides the implicit success() and a failed
# preamble (installer unit tests, setup-node, setup-python, the Defender
# tweak) still stops the job here, exactly as it did when this was three
# jobs. Gating it on `!cancelled()` would install onto a runner whose
# pinned Python or Node never materialised, and every phase below gates on
# assert-prebuilt, which would then pass and hide the real failure.
- name: Install Unsloth (--local, --no-torch)

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 Run the shared install after phase 1 cache failures

When Phase 1 model priming fails or reaches its new 15-minute timeout, this implicit success() condition skips the shared install; assert-prebuilt is consequently skipped and every explicit Phase 2 and Phase 3 gate evaluates false. A transient cache or model-download failure therefore suppresses all later smoke coverage, unlike the three independent jobs this replaces. Fresh evidence after the earlier shared-preamble gate change is that Phase 1 cache priming still precedes this default-conditioned shared install, so the gate must distinguish shared setup failures from Phase 1 resource failures.

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.

Genuine, and it is the mirror image of the previous round's finding. Fixed in c0e0543.

You are right that removing the !cancelled() was only half the job. The two failure classes were still interleaved because phase 1's environment and HF cache sat BEFORE the installer:

before          5 Phase 1 environment    6 cache-hf    7 prime-hf    8 save
                9 tweaks   10 install   11 assert-prebuilt

That ordering is inherited from when phase 1 was its own job, where it was harmless because a priming failure killed only that job. Shared, it skips the installer, skips assert-prebuilt with it, and evaluates every phase-2 and phase-3 gate false -- a transient HF download takes the whole workflow down, which is worse than what the three jobs did.

Rather than build a compound condition to tell the two apart, I moved the block so the ordering itself does:

after           5 tweaks    6 install    7 assert-prebuilt    8 shim    9 sdks
               10 Phase 1 environment   11 cache-hf   12 prime-hf   13 save

Everything before phase 1's block is genuinely shared, everything after it is phase 1's own. Phase 1 keeps its implicit success(), so a prime failure still skips the rest of phase 1; phases 2 and 3 gate explicitly on the shared steps, so they are untouched by it. No new condition anywhere.

Checked that nothing in the preamble needed the moved env: the installer takes GH_TOKEN and HF_TOKEN but not HF_HOME, and on main the tool-calling job already ran it with no HF_HOME set at all.

Four gate corrections that all come from the same root cause: after
consolidation, 'shared' and 'phase 1' were still interleaved.

Phase 1's environment and HF cache ran BEFORE the installer, which is where
they sat when phase 1 was its own job. Harmless then, since a priming failure
killed only that job. Shared now, so the same failure skipped the installer
under the implicit success(), skipped assert-prebuilt with it, and evaluated
every phase 2 and phase 3 gate false. A transient HF download took the whole
workflow down. Moved the block after the shared preamble, so a phase-1 resource
failure is phase-local again while a genuine preamble failure still stops
everything.

The phase gates keyed on assert-prebuilt, which is not the last thing every
phase needs. A failed 'Add Unsloth shim to GITHUB_PATH' left the gates true and
both later phases booted a Studio that was not on PATH. The gates now key on the
shim step, which only runs when the assertion passed, so it implies the old
condition and catches the shim too.

Phase 3 imports openai and anthropic, and installed them itself before
consolidation. It now shares the preamble's install, so it also gates on it.
Phase 2 drives the API with curl and deliberately does not.

Teardown killed by listening port, which finds nothing when Studio hangs during
startup and never binds. That is the exact case the health wait exists for, and
it left the process alive to collide with the next phase. Added a command-line
sweep scoped to a process naming both unsloth and studio, which cannot reach the
runner's own python from actions/setup-python.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: c0e0543e82

ℹ️ 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
danielhanchen merged commit ccb8dff into main Aug 6, 2026
14 checks passed
@danielhanchen
danielhanchen deleted the ci/merge-windows-inference-phases branch August 6, 2026 12:03
danielhanchen added a commit that referenced this pull request Aug 6, 2026
Follow-up to the Mac consolidation, applying the resolution that came out of
reviewing the equivalent Windows change in #8013.

The installer carried an explicit 'if: ${{ !cancelled() }}' with a comment
explaining why: phase 1's environment and model cache ran before it, so under
the implicit success() a phase-1 GGUF download failure would skip the install,
skip assert-llama with it, and take phases 2 and 3 down. The gate bought that
independence, but at a price the comment did not mention: a failed setup-node
or setup-python no longer stops anything, the installer runs on a runner that
never got its pinned toolchain, assert-llama passes, and all three phases run
and fail somewhere unrelated.

Moving phase 1's block below the shared preamble is better than either gate,
because it makes the two failure classes structural rather than conditional.
Everything above the block is genuinely shared, everything below it belongs to
phase 1, and the installer can go back to the implicit success().

Phases 2 and 3 also gated every step on assert-llama alone, so a failed
download or a server that never came up still ran the test against it. Each
phase now chains on its own prerequisites, keeping assert-llama as the first
term so cross-phase independence is unchanged. Phase 3 additionally gates on
its SDK install, which only it needs.

Verified no coverage moved: every 'run:' body in the file is byte-identical
across the change, 24 before and 24 after, none lost and none added.
danielhanchen added a commit that referenced this pull request Aug 6, 2026
…8024)

Follow-up to the Mac consolidation, applying the resolution that came out of
reviewing the equivalent Windows change in #8013.

The installer carried an explicit 'if: ${{ !cancelled() }}' with a comment
explaining why: phase 1's environment and model cache ran before it, so under
the implicit success() a phase-1 GGUF download failure would skip the install,
skip assert-llama with it, and take phases 2 and 3 down. The gate bought that
independence, but at a price the comment did not mention: a failed setup-node
or setup-python no longer stops anything, the installer runs on a runner that
never got its pinned toolchain, assert-llama passes, and all three phases run
and fail somewhere unrelated.

Moving phase 1's block below the shared preamble is better than either gate,
because it makes the two failure classes structural rather than conditional.
Everything above the block is genuinely shared, everything below it belongs to
phase 1, and the installer can go back to the implicit success().

Phases 2 and 3 also gated every step on assert-llama alone, so a failed
download or a server that never came up still ran the test against it. Each
phase now chains on its own prerequisites, keeping assert-llama as the first
term so cross-phase independence is unchanged. Phase 3 additionally gates on
its SDK install, which only it needs.

Verified no coverage moved: every 'run:' body in the file is byte-identical
across the change, 24 before and 24 after, none lost and none added.
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.

1 participant