Skip to content

CI: keep ccache on failed builds, bound the CUDA Windows timeout, stop uploading the debug bundle on green runs - #81

Merged
danielhanchen merged 3 commits into
masterfrom
ci/artifact-storage-and-ccache-fixes
Aug 8, 2026
Merged

danielhanchen merged 3 commits into
masterfrom
ci/artifact-storage-and-ccache-fixes

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Three independent CI fixes, each from a measurement on real runs. No build logic changes.

1. Save ccache now survives a failed build

Save ccache had no if:, so it only ran when every prior step succeeded. A failed or timed-out build discarded a cache containing hundreds of already-compiled objects, and left a hole in the cache lineage.

That matters because ccache hit rate tracks the gap between the restored cache tag and the tag being built:

run restored building gap hit rate wall clock
31136280015 b10290 b10297 7 68.0% (603/887) 54 min
31218133438 b10297 b10310 13 6.2% (55/887) 204 min

The saved-tag lineage for the portable profiles is b10241, b10265, b10290, b10297, b10310 -- b10298 is missing, so b10310 fell back to b10297 (gap 13) instead of gap 12. Every hole widens the next gap.

Now if: ${{ !cancelled() }} on all 9 Save ccache steps across the 6 prebuilt workflows. Not always(): a cancelled job has no useful cache state.

2. CUDA Windows timeout is bounded under assemble

assemble sets timeout-minutes: 350. The build children set nothing, so they inherit GitHub's 360-minute default.

Assemble therefore expires ~11 minutes before the job it is waiting on. A build leg in the 350-360 minute band kills the publish while the build is about to succeed, discarding the whole 40-job run. x64/cuda12-portable has already been observed at 214 minutes, so the band is reachable.

Adds timeout-minutes: 300 to the CUDA Windows job so it fails cleanly inside assemble's budget.

3. The debug bundle no longer uploads on green runs

Upload full release set (artifacts) had no if: and sat before the publish gate, so every run uploaded ~688 MiB of Actions artifact storage for a bundle nothing reads:

  • no download-artifact in this repo references it (children pull inputs.source_artifact, assemble pulls pattern: app-*)
  • an org-wide code search for actions/artifacts returns nothing
  • Studio resolves release assets, not artifacts (install_llama_prebuilt.py -> release_asset_download_url)

Uploading ahead of the gate also meant unpublished, unverified builds were world-downloadable -- on a public repo any signed-in user can download an artifact.

The step is kept, moved after Publish GitHub release and gated on failure(), so it still rescues a failed publish without re-running the matrix, and costs nothing when the run is green. if-no-files-found relaxed to warn so an early failure with no dist/ cannot turn one diagnosable failure into two.

Why this matters beyond CI hygiene

On 2026-08-07 org-wide Actions scheduling stalled for ~39 minutes of dead queue: Actions artifact storage had reached ~492 GiB, 449 GiB of it in this repo, and GitHub stopped scheduling runs across unslothai/* while personal-account repos ran the same workflows normally. Purging artifacts restored scheduling within ~45 seconds. Repo retention was already 1 day; volume alone did it.

Note every prebuilt is currently stored twice -- as an Actions artifact and as a release asset (measured on b10297: 37 artifacts / 7.42 GiB vs 42 assets / 7.81 GiB). A follow-up can delete each run's app-* artifacts once the release is published and verified, which reclaims 99.3% of that. This PR does not attempt it.

Test plan

  • Next nightly: confirm Save ccache runs on a failed leg
  • Next nightly: check the ccache stats group -- this is the first run to restore a post-fix uncapped cache (the 500 MB cap was lifted in 4a03725 on 08-07 09:52, but b10310 restored a cache written at 04:14, before it), so the hit rate should recover toward 68%+
  • Confirm a green run uploads no unsloth-prebuilt-<tag> artifact
  • Confirm a deliberately failed publish still produces one

All 7 workflow files parse (yaml.safe_load).

@danielhanchen

Copy link
Copy Markdown
Member Author

Review round 1 applied. Two findings were genuine blockers; both verified against real data before changing anything.

1. timeout-minutes: 300 would have killed a real successful build. Confirmed directly: run 27347317849, CUDA Windows / x64/cuda12-portable, 305.1 minutes, conclusion=success (286.9 min of it genuine cold-cache compile). Across 62 historical runs of that leg the max is 305.1 and nothing falls between 215 and 305, so a tighter cap buys no hang detection and would have cost a publish -- one killed leg fails the bundle-coverage gate and the night ships nothing.

Raised to 345: under GitHub's 360 hard cap, clear of the observed max by 40 min, still catches a genuine wedge.

2. !cancelled() does not cover the timeout case, which was the whole point. A timeout-minutes expiry puts the job on the cancellation path, not the failure path, so !cancelled() evaluates false and Save ccache would have been skipped on exactly the most expensive case -- a leg that compiled for hours then hit the cap. Combined with finding 1 that is self-reinforcing: timeout -> cache discarded -> next tag gap widens -> hit rate drops (68% at gap 7 vs 6.2% at gap 13) -> slower build -> times out again.

All 9 Save ccache steps are now if: ${{ always() }}.

Also in this push:

  • Evict stale ccache files given the same always() at all 9 sites, so the pair cannot drift and the failure-path save is not stored un-evicted.
  • overwrite: true on the debug-bundle upload -- rerun-failed-jobs reuses the run id and artifacts persist across attempts, so a second failed attempt would 409 on the duplicate name.
  • The whisper.cpp rationale comment moved back onto Notify whisper.cpp; moving the upload step had stranded it six lines above the wrong step.

Correction to the PR description. It says the child "must stay UNDER assemble's timeout-minutes: 350". The real binding constraint is the waiter's own DEADLINE=$(( $(date +%s) + 330 * 60 )), and timeout-minutes starts at job start so it excludes queue wait, while the waiter's 330 is wall-clock from assemble start and includes it. So this cap is a hang guard and a runner-cost saving, not a rescue: a leg needing more than ~330 min of wall clock fails the run either way. The comment now states that.

That points at a real pre-existing problem this PR does not fix: simulating the early-start pattern over 65 historical runs, 5 (7.7%) would have blown the 330-minute waiter deadline, dominated by queue wait rather than build time. Raising the waiter deadline and assemble's 350 is the change that would actually save those runs. Left out deliberately -- it is a behaviour change to the publish path and wants its own PR.

Not changed, with reasons:

  • A failed build's ccache cannot poison later builds or alter binaries: restore always precedes the build, so a saved cache is a superset of what was restored; ccache keys on preprocessed source plus compiler and flags with default sloppiness; and the pipeline independently verifies the Unsloth fingerprint in every bundle and full coverage before publish.
  • Other build children need no cap (family maxima: CUDA 127.8, macOS 97.0, ROCm 74.1, Vulkan 25.4, CPU 15.6 min). The two macOS legs at 97.0 against a 9-26 min p95 do look like hangs and deserve a ~120 min cap, but that is a separate change.
  • The small capability loss on publish: false dispatches (no manifest artifact when the run is green) is accepted; the bundles themselves remain available as the app-* child artifacts.

All 12 workflow files parse.

…fix the same cancelled-vs-failure bug on the rescue bundle
@danielhanchen

Copy link
Copy Markdown
Member Author

Round 2 applied. Verdict was no blockers, and the round-1 premise came back confirmed by direct experiment rather than inference: on a probe repo, a job killed by timeout-minutes concludes cancelled, and a probe step gated !cancelled() was skipped while always() ran. The mechanism is in actions/runner -- a step timeout sets TaskResult.Failed, a job timeout is server-side and issued as a plain JobCancelMessage. So always() was not merely a safe superset, it was required.

Two changes in this push.

1. Evict stale ccache files moved to !cancelled() -- deliberately different from the save.

I set both to always() in round 1, which was wrong. A cancelled job gets a single teardown window (measured ~4m50s after process kill, since escalation is SIGINT -> 7500 ms -> SIGTERM -> 2500 ms -> kill tree), it is shared by every remaining step, and it does not replenish. Spending it on ccache --evict-older-than is spending it on housekeeping when the save is the thing worth rescuing, and a 2 GB cache is not quick to write.

So on the timeout path evict now skips and the whole window goes to the save; on the ordinary failure path both still run. All 9 sites in both directions, verified through the YAML parser rather than grep: Evict !cancelled(): 9/9, Save always(): 9/9. The rocm file uses a shallower step indent and its two sites were initially missed, which is why I checked by parsing.

2. Upload full release set (artifacts) was carrying the same bug this PR exists to fix.

I gated it if: ${{ failure() }} in the first push. That is exactly the cancelled-vs-failure mistake corrected in round 1, one step away from where it was corrected: a cancelled assemble -- its own timeout-minutes: 350, or a superseding nightly under cancel-in-progress -- is not on the failure path, so failure() skips the rescue bundle on precisely the runs a human most wants it for. Now if: ${{ always() && !success() }}, which fires on cancellation and on failure and skips on green.

Worth noting nothing else in assemble competes for that teardown window (the ccache saves are all in the build children), so attempting the upload there is free, and if-no-files-found: warn keeps it quiet when dist/ was never populated -- which is the likely state if the waiter itself timed out.

Also confirmed by the reviewer and unchanged:

  • A workflow_call child that times out surfaces to the caller as &lt;caller-job&gt; / &lt;child-job&gt; with conclusion cancelled, so the waiter's PREFIXES matching reads the right records and its cancelled-is-BAD classification is correct. alert sees it too.
  • A matrix leg killed by timeout-minutes does not fail-fast its siblings, because fail-fast keys on failure and this is a cancellation. fail-fast: false is already set, so the 345 cap kills exactly one leg rather than the CUDA Windows matrix -- which is what the coverage gate assumes.

One consequence I am accepting rather than fixing: a step still running when the teardown window expires is recorded conclusion: failure even though the job stays cancelled. So a ccache save killed mid-write will show as a red step on a timed-out leg. It cannot turn a green build red, but it is worth knowing before it looks like a new fault.

Not taken: cancel-timeout-minutes (job-level, defaults to 5, verified accepted by the server-side parser) would raise the teardown window and give a 2 GB save real room at 345 + 10 = 355, still under the hard 360 cap. It is undocumented on docs.github.com and still tracked by actions/runner#464, and a parse rejection would break every prebuild, so it does not belong in a PR whose point is to stop breaking things. Worth a separate, testable change if the save turns out to be getting truncated.

@danielhanchen
danielhanchen marked this pull request as ready for review August 8, 2026 05:26
@danielhanchen
danielhanchen merged commit c9f74a3 into master Aug 8, 2026

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

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

# the CANCELLATION path, not the failure path, so !cancelled() would
# skip the save on the single most expensive case -- a leg that
# compiled for hours and then hit the cap.
if: ${{ always() }}

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 Update the stale cache-persistence rationale

When a configure, build, packaging, or upload step fails, always() now persists the partial cache, but the ccache setup at lines 265-267 still says that a failed package does not persist a cache for an unshipped bundle; the Ubuntu setup also refers readers back to that rationale. Update that earlier explanation so maintainers are not given the opposite failure behavior.

Useful? React with 👍 / 👎.

Comment on lines +195 to +198
# always(), not !cancelled(): a timeout-minutes expiry puts the job on
# the CANCELLATION path, not the failure path, so !cancelled() would
# skip the save on the single most expensive case -- a leg that
# compiled for hours and then hit the cap.

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 Condense the repeated cache commentary

This nine-line explanation, together with the preceding eviction explanation, is duplicated across every new cache-save site and repeatedly hard-wraps sentences. The repository requires comments to remain concise, avoid excessive commentary, and avoid fixed-column wrapping, so reduce this to the non-obvious condition rationale rather than copying the full operational history into every workflow.

AGENTS.md reference: AGENTS.md:L75-L81

Useful? React with 👍 / 👎.

# the CANCELLATION path, not the failure path, so !cancelled() would
# skip the save on the single most expensive case -- a leg that
# compiled for hours and then hit the cap.
if: ${{ always() }}

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 Use a fresh key for each failed cache snapshot

When a failed or cancelled attempt saves this partial directory, it claims the same tag-specific primary key that ccache-action restores at line 100; the trailing dash is deliberately an exact match. GitHub cache entries are immutable, so a rerun or superseding build can compile the remaining objects but cannot replace that first partial snapshot, leaving the next build to restore an unnecessarily incomplete cache. Add a unique attempt suffix to the manual save key while retaining the existing restore prefix.

Useful? React with 👍 / 👎.

Comment on lines +861 to +863
# Kept but moved after publish and gated on failure(), so it still rescues
# a failed-publish run without re-running the 40-job matrix, and costs
# nothing when the run is green.

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 Describe the cancellation fallback accurately

When the assemble job is cancelled by its timeout or a superseding nightly, always() && !success() is intended to run this upload even though failure() is false, but the immediately preceding summary still says the step is gated on failure(). Update that summary so it does not contradict the condition and the detailed cancellation rationale directly below it.

Useful? React with 👍 / 👎.

if-no-files-found: warn
# rerun-failed-jobs reuses the run id, and artifacts persist across
# attempts, so a second failed attempt would 409 on the duplicate name.
overwrite: true

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 previous rescue artifact across reruns

On a rerun of failed jobs where the previous attempt already uploaded this rescue bundle, overwrite: true deletes that artifact before uploading its replacement. If the new attempt is cancelled, times out, or loses the artifact service during this roughly 688 MiB upload, the only complete rescue bundle is lost; this is especially likely when the step is running inside the short cancellation teardown window described above. Give each run attempt a distinct artifact name instead of overwriting the prior fallback.

Useful? React with 👍 / 👎.

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