Skip to content

CI: run the three mac inference smokes as phases of one job - #7978

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

danielhanchen merged 6 commits into
mainfrom
ci/merge-mac-inference-phases

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Completes the macOS work from #7974 and #7975. This is the merge I deferred out of #7975 once inspection turned up collisions; they are all resolved here and verified.

The three jobs in studio-mac-inference-smoke.yml differed only in model, port and test body. Their preamble was byte-identical:

checkout -> setup-node -> setup-python
  -> install.sh --local --no-torch -> assert-llama-loads.sh

So every triggering PR ran the same install on three macos-14 runners at once. Concurrent macOS jobs are capped at 5 per account, shared with unslothai/unsloth-zoo, so this single workflow took 3 of the 5 slots to derive the same install three times.

They are now three sequential phases sharing one install.

Collisions the merge had to resolve

None of these were visible from the job list; each would have broken the job or corrupted results silently:

Collision Consequence if merged naively Fix
cache-gguf + download-gguf ids defined in two jobs Duplicate step ids in one job is a hard workflow error suffixed -tools / -vision
Both jobs cached to the same gguf-cache dir with different models vision phase could restore tool-phase bytes gguf-cache-tools / gguf-cache-vision
All three boots wrote logs/studio.log each phase truncates the previous phase's diagnostics one log per phase

On environment precedence

Phase values are set only through $GITHUB_ENV, never at job level, and everything inside ${{ }} is a literal.

Whether a later $GITHUB_ENV write beats a job-level env: key of the same name is not something the Actions docs pin down. I looked, and the reference page does not cover it. Rather than bet on it, the conflict is removed: job-level env: now holds only HF_HOME, which every phase shares.

This matters because the failure mode is quiet. A phase talking to the previous phase's port, or a cache key resolving to the wrong model, would still pass -- just against the wrong bytes. The inlined literals resolve to the same strings as before, so the cache keys are unchanged.

Correction, measured on staging: the model caches still miss once. actions/cache identifies an entry by key and a version hash derived from the path input, so renaming gguf-cache to gguf-cache-tools / gguf-cache-vision invalidates the existing entries even though the key string is identical. The staging run logged Cache not found for input keys: macOS-gguf-unsloth/Qwen3.5-2B-GGUF-...-v1 while the same key hit on the unmodified branch. This is a one-time re-download of the tool (~890 MB) and vision (~2.4 GB + 986 MB) models; the caches repopulate under the new version on the first run and hit from then on. I had claimed these would still hit, which was wrong.

Verification

  • One job, 37 steps
  • No duplicate step ids, no duplicate artifact names
  • No dangling steps.* references
  • Exactly 1 install and 1 llama-load assert (was 3 each)
  • Three distinct ports (18888 / 18898 / 18899) and three distinct server logs
  • No ${{ env.* }} references remain
  • Assertion-preservation diff: extracted test-command set identical to before, once the intended cache-directory rename is normalised
  • CI green on this PR

Measured on staging CI

Both arms dispatched within 5 s of each other on danielhanchen/unsloth-staging-2 (personal account, its own macOS quota), so they faced the same starting cache state and did not queue behind one another. Both succeeded, which also validates the merged three-phase job end to end on a real macOS runner.

before (3 jobs) after (1 job)
macOS jobs 3 1
installs 3 1
peak concurrent slots 3 1
slot-minutes 12.6 6.5 (-48%)
wall time 5.2 min 6.6 min (+1.4)

Slot-minutes is the number that matters against a pool capped on concurrent jobs; it is the throughput cost when the pool is saturated.

Two honest caveats:

  • The -48% is understated. Because of the cache-version invalidation above, the after arm downloaded ~3.3 GB of models that the before arm restored from cache. Steady state will be better than 6.5 slot-minutes.
  • The wall-time cost is far smaller than I projected. I wrote earlier that three ~25 min parallel jobs would become one ~75 min sequential job. Measured, the jobs are 2.7 / 4.7 / 5.2 min and the merged job is 6.5 min: +1.4 min, not +50. The 25 min figures were timeouts, not observed durations, and the install dominates each job, so removing two of them nearly cancels the cost of serialising. The timeout is still set to 90 as headroom, not as an expectation.

Trade-off worth stating

Wall time for this check goes up by 1.4 min (5.2 -> 6.6, measured), timeout raised 25 -> 90 as headroom. Total runner minutes drop 48% and the slot burst drops from 3 to 1. Given the measured cost, the earlier framing of this as a meaningful latency trade-off was overstated.

Stacks cleanly on #7975 (different files, no conflict). macOS jobs: 29 -> 27 with #7975 merged, or 31 -> 29 against main alone.

Correction on the cache-key claim

An earlier revision of this PR body, and the commit message on the key bump, said the save was
"refused because the key is already taken" and that the miss was therefore permanent. That
mechanism is not proven, and I am correcting it.

I bumped the keys to fresh values (-v2 / -v3) that had never existed, re-ran on staging, and the
save still failed with Unable to reserve cache with key ..., another job may be creating this cache. A never-before-used key cannot be occupied, so "key already taken" cannot be the explanation.

The actual confound: the staging repo is itself over the 10 GB cache limit (11.1 GB across 15
caches), so saves there fail or are evicted immediately, whatever the key. The save behaviour I
attributed to this change was a property of the test environment.

What is still established, and is why the key bump stays:

  • actions/cache identifies an entry by key and a version hash derived from path. On staging,
    the unmodified branch hit macOS-gguf-...-v1 while the renamed-directory branch missed the same
    key string. So renaming the cache directory does invalidate the existing entry.
  • In unslothai/unsloth, macOS-gguf-...-v1 exists on main. Without the bump, the renamed paths
    would miss on version and then contend for a key that is already held. Bumping gives the new paths
    a clean key.

What I can no longer claim is the "3.3 GB re-downloaded on every run, forever" figure. That was
measured on an over-budget repo and is not a sound prediction for a healthy one. The real fix for
both repos is #7990, which brings cache usage back under the limit.

The three jobs in this workflow differed only in model, port and test body.
Their checkout, setup-node, setup-python, install.sh --local --no-torch and
assert-llama-loads.sh preamble was byte-identical, so every triggering PR ran
the same install on three macos-14 runners at once. Concurrent macOS jobs are
capped at 5 per account and that pool is shared with unslothai/unsloth-zoo, so
this one workflow took 3 of the 5 slots to derive the same install three times.

They are now three sequential phases sharing a single install. Each phase keeps
its own model cache, port, server log and uploaded artifact, so a failure still
names one phase and the earlier phases' logs survive it.

Collisions the merge had to resolve, none of which were visible from the job
list alone:

  - cache-gguf and download-gguf were defined in both the tool-calling and
    json-images jobs. Duplicate step ids inside one job are a hard error, so
    they are suffixed -tools and -vision.
  - both jobs cached to the same gguf-cache directory with different models.
    Merged, the vision phase could have restored tool-phase bytes. Split into
    gguf-cache-tools and gguf-cache-vision.
  - all three boots wrote logs/studio.log, so merged, each phase would have
    truncated the previous phase's diagnostics. Split per phase.

Phase-specific values are set only through , never at job level.
Whether a later  write beats a job-level env: key of the same name
is not something the Actions docs pin down, and a phase quietly talking to the
previous phase's port is a bad way to discover the answer. Everything inside
${{ }} is a literal for the same reason: a cache key that silently resolved to
the wrong model would still pass, just against the wrong bytes. The literals
resolve to the same strings as before, so existing caches still hit.

Verified: one job, 37 steps, no duplicate ids or artifact names, no dangling
steps.* references, exactly one install, three distinct ports and logs, and the
extracted test-command set is identical to before once the cache-directory
rename is normalised.

macOS jobs in this repo: 29 -> 27 on top of #7975 (31 -> 29 on main alone).

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

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

with:
path: gguf-cache
key: ${{ runner.os }}-gguf-${{ env.GGUF_REPO }}-${{ env.GGUF_FILE }}-v1
path: gguf-cache-tools

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 cache paths stable when reusing existing keys

On the first run after this change, the previously warmed tool cache cannot be restored because actions/cache incorporates the configured path into its cache version: changing gguf-cache to gguf-cache-tools creates a different version even though the key string is unchanged. The analogous gguf-cache-vision rename has the same effect, so rollout forces fresh downloads of both large models—including the multi-gigabyte vision files that this workflow says are prone to stalling on anonymous PR downloads. Preserve the old cache path or provide an explicit migration/fallback if existing warm caches are intended to remain usable.

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 mechanism is right (actions/cache derives its version hash from the resolved path, so the same key against a different path never restores), but the conclusion does not follow here.

On main both the tool-calling job and the json-images job cached into the same directory name, gguf-cache -- they could, because they were separate jobs on separate runners. Merging them into one job means they now share a workspace, so at least one of the two directories has to be renamed; there is no variant of this PR that keeps both warm caches.

Given the rename is forced, the key bump is not an oversight, it is the deliberate follow-up commit 99c046d ("bump the renamed GGUF cache keys so the merged phases can cache at all"), for exactly the reason you give. The comment above this step records what happens without it: key uniqueness is global per ref, so the old -v1 entry would make the restore miss on version while the save was refused with "Unable to reserve cache with key ... another job may be creating this cache", i.e. the phase would re-download forever. That was measured on staging: two consecutive runs both logged "Cache not found for input keys" and both failed to save. Vision went -v2 -> -v3 for the same reason.

So the residual cost is one cold download per phase on the first run after merge, after which both caches are warm again. Keeping one phase on the bare gguf-cache name to save that single download would leave the two phases asymmetrically named in a shared workspace, which is the sharp edge worth avoiding here. The multi-gigabyte vision download is also the one that is already hardened -- authenticated, parallel, and behind the stall-retry watchdog.

Not changing this one.

…t all

Caught by an A/B on staging CI, not by inspection.

Splitting gguf-cache into gguf-cache-tools and gguf-cache-vision kept the cache
keys byte-identical, which looked safe. It is not. actions/cache identifies an
entry by key AND a version hash derived from the path input, while key
uniqueness is global per ref. So the pre-existing gguf-cache entries still hold
the old keys: a restore into the new directory misses on version, and the
matching save is then refused with "Unable to reserve cache with key ...,
another job may be creating this cache".

The result is not a one-time repopulation. It is permanent: two consecutive
staging runs of the merged workflow both logged "Cache not found for input
keys" and both failed to save, so both re-downloaded the tool model (~890MB)
and the vision model (~2.4GB + 986MB). That is roughly 3.3GB per run, forever,
on a macOS runner from a pool capped at 5 concurrent jobs.

Bumping the key suffixes (tools v1 -> v2, vision v2 -> v3) gives the new paths a
free key so the entries actually populate.

The rule this encodes: changing an actions/cache path requires changing the key
too, even though the key alone looks like it fully identifies the entry.
…smoke job

Merging the three mac inference jobs into one job lost two properties the
separate jobs had.

A step with no explicit `if:` gets an implicit `success()`, and that check is
job-wide, not per-step. So one failed step in phase 1 skipped every remaining
step of phases 2 and 3, and a tool-calling or vision regression went unreported
until phase 1 was fixed and the job re-run. Phases 2 and 3 now run under
`!cancelled() && steps.assert-llama.outcome == 'success'`: a failure inside a
phase no longer skips the phases after it, while a failure in the SHARED
preamble (checkout, install, llama.cpp load check) still skips them, since
assert-llama is itself skipped in that case. The job still ends red, because the
failed step already set the job status.

The three jobs were also capped at 25 / 25 / 30 minutes each; the merged job had
only the aggregate 90. hf-download-with-retry.sh retries forever and names the
enclosing timeout as its bound, so one stalled download could hold a macOS slot
for the full 90 minutes and leave nothing for the phases behind it. Every step
that can block now carries its own timeout-minutes, with 90 kept as the outer
guard.

Also drops the two leftover job divider comments that still announced jobs 2 and
3 in the middle of the step list.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

The previous round gated phases 2 and 3 on steps.assert-llama.outcome, so a
failure inside one phase no longer suppresses the others. It left the two shared
preamble steps on the implicit success() check, which reopens the same hole one
level up.

Install Unsloth and Assert llama.cpp both had no if:, so GitHub applied
success(), which is true only when every previous step succeeded. Phase 1's
Prime HF_HOME sits above them and carries a 15-minute timeout, and a step
timeout marks the step failed rather than cancelled. So a stalled or failing
phase-1 model download skips Install, skips Assert, leaves
steps.assert-llama.outcome == 'skipped', and silently takes phases 2 and 3 with
it. Before the consolidation those were independent jobs and still ran.

Install now runs under !cancelled(), and Assert gates on the install step
explicitly instead of on the job-wide implicit check. A phase-1 GGUF problem is
a phase-1 resource problem: the install probe that install.sh itself needs is
fetched live by hf_hub_download when the cache is cold, so the bootstrap can
still succeed and tool-calling and vision still get exercised. A genuinely
broken bootstrap still fails Install, which still skips Assert and correctly
holds both later phases out.

Ordering is unchanged, so no cache key or path moves.

Behaviour, verified against the step table: all green -> phases run; prime-hf
fails or times out -> phases run; checkout, setup-python or install fails ->
phases skipped; assert fails -> phases skipped; run cancelled -> all skipped.
@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: 24cf00a165

ℹ️ 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 433 to +434
- name: Reset auth + boot Unsloth (API-only, default tool policy)
if: ${{ !cancelled() && steps.assert-llama.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.

P1 Badge Gate phase-2 work on its own prerequisites

When the phase-2 restore or download fails (including the download's 20-minute timeout), this condition remains true because it checks only the shared assertion and cancellation state. It therefore overrides the implicit success() guard, allowing the boot, 15-minute load, and 20-minute tool test to run without the model; together with the cache-save timeout, these doomed steps can exhaust the 90-minute job cap before Phase 3 starts. Preserve cross-phase independence while also requiring phase-2 prerequisite success for its dependent steps.

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.

Declining this one, though the mechanism you describe is correct: because these conditions contain !cancelled(), the implicit success() is not applied, so after a phase-2 download failure the boot, load and tool steps do run.

Where it does not hold is the impact, and that is what the P1 rests on. Those steps fail in seconds, not in the ~37 minutes their timeout-minutes imply:

  • The boot backgrounds unsloth studio with & and exits in a few seconds; it needs no model, since the server starts API-only.
  • In the load step, ls -lh "$GGUF_PATH" sits immediately before the --max-time 600 curl. The default non-Windows shell is bash -e {0}, so the missing file aborts the step right there and the 10-minute call is never reached.
  • The tool test's first request returns HTTP 400 ("No model loaded"), and the helper re-raises HTTPError without retrying.
  • The save step is normally skipped anyway: hf download keeps partial bytes under .cache/huggingface/download/.incomplete, so hashFiles('gguf-cache-tools/**/.gguf') is empty after a failed download.

Measured against the budget: the step caps in this job already sum to 286 minutes against a 90-minute job cap, so cap-summing does not bound anything here. Roughly 40 seconds of extra red steps in an already-failing run does not threaten phase 3, and phase 3 gates only on assert-llama, so it starts regardless of what phase 2 did. No coverage is lost.

The stronger reason to decline is that the prescription is a footgun. On a cache hit the download step is skipped by its own if, so its outcome is 'skipped', not 'success'. Gating the dependent steps on steps.download-gguf-tools.outcome == 'success' would disable all of phase 2 on every warm-cache run, which is the common path. Only != 'failure' would be safe, and the restore step must stay out of any such gate since its continue-on-error exists so the download can recover from it. That trades ~40 seconds of log tidiness for a live way to silently lose a phase.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Phases 2 and 3 got timeout-minutes on their cache restore/save pairs in
the previous follow-up, but phase 1's pair was left unbounded. Before
consolidation that phase was a separate job with its own 25-minute
timeout, so a stalled cache action was bounded by it; after the merge
the only bound is the job's 90 minutes, and a stall there would hold a
macOS slot and starve phases 2 and 3.

15 minutes matches the sibling Prime HF_HOME step and phase 2's pair.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 4d32b486fe

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

…gate

#7990 gated every cache save on refs/heads/main, and this branch had renamed
the three phases' step ids and cache dirs so one job could hold all three.
Both are kept: the ref gate, and download-gguf-tools / gguf-cache-tools and
download-gguf-vision / gguf-cache-vision in place of the shared names.

The save step names stay literal rather than env.GGUF_REPO, which is now
reassigned three times in the one job.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 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. What shall we delve into next?

Reviewed commit: 1948f37305

ℹ️ 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 607b928 into main Aug 6, 2026
8 checks passed
@danielhanchen
danielhanchen deleted the ci/merge-mac-inference-phases branch August 6, 2026 08:52
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