diff --git a/.github/qualify-rocm/FEED.md b/.github/qualify-rocm/FEED.md index 480b42e4b..f2b95a3f9 100644 --- a/.github/qualify-rocm/FEED.md +++ b/.github/qualify-rocm/FEED.md @@ -93,12 +93,17 @@ jobs" keeps the earlier attempt's resolved commit, so it never changes the tag. Runs of `.github/workflows/build.yml` whose `release` job runs: the scheduled nightly runs, and manual runs with `create_release` ticked. Pass or fail, every one of them is published. The records normally come from the `release` job; if -it stopped before writing them, `publish-qualification` builds them from the -Tier 0 and Tier 1 reports instead. - -A nightly whose release tag is already fully published builds nothing (see -[`last_check`](#last_check)). It adds no rows, but it does update `last_check`, -so "nothing changed upstream" can be told apart from "the nightly did not run". +it stopped before writing them, or a newer run on the same tag cancelled it +while it waited, `publish-qualification` builds them from the Tier 0 and Tier 1 +reports instead. + +A release run whose release tag already holds every ROCm version builds no ROCm +archive (see [`last_check`](#last_check)). It adds no rows, but it does update +`last_check`, so "nothing changed upstream" can be told apart from "the nightly +did not run". That covers a release that is complete, and one that is missing +only non-ROCm archives (say the Metal build failed), its notes, or a +`checksums.txt` that matches its archives: the run then rebuilds only the other +families. Not in the feed: @@ -111,18 +116,18 @@ Not in the feed: ```jsonc { - "schema_version": 2, + "schema_version": 3, "repo": "lemonade-sdk/stable-diffusion.cpp", "updated_at": "2026-11-23T14:52:10Z", // the most recent generated_at of any row "last_check": { // what the most recent run decided - "status": "unchanged", // built | unchanged + "status": "built", // built | unchanged "tag": "master-1106-abc1234", "upstream_sha": "532d2c15c430a785a712b2d94281f04e733008a4", - "run_id": "45099999999", + "run_id": "45012345678", "run_attempt": 1, - "run_url": "https://github.com/lemonade-sdk/stable-diffusion.cpp/actions/runs/45099999999", + "run_url": "https://github.com/lemonade-sdk/stable-diffusion.cpp/actions/runs/45012345678", "event": "schedule", - "checked_at": "2026-11-24T12:18:40Z" + "checked_at": "2026-11-23T14:52:25Z" }, "builds": [ // newest run (highest run_id) first // ... the other rows of run 45012345678 ... @@ -148,6 +153,7 @@ Not in the feed: "qualified": false, "version_qualified": false, "published": false, + "already_published": false, "overall": "fail", "tier0": "missing", // should have run, but there was no archive "tier1": "missing", @@ -156,9 +162,9 @@ Not in the feed: "results": { "T0.1": "missing", "T0.2": "missing", "T0.3": "missing", "T0.4": "missing", "T0.5": "missing", "T0.6": "missing", "T0.7": "missing", "T0.8": "missing", - "T0.9": "missing", "T0.10": "missing", "T0.11": "missing", "T0.12": "not_applicable", + "T0.9": "missing", "T0.11": "not_applicable", "T0.12": "missing", "T0.14": "missing", "T1.1": "missing", "T1.2": "missing", "T1.3": "missing", "T1.4": "missing", - "T1.5": "missing", "T1.6": "missing" + "T1.6": "missing", "T1.7": "missing" }, "report_url": "reports/45012345678-win-rocm-10.2.json" }, @@ -186,18 +192,20 @@ Not in the feed: // release job requires, so it was never cleared to ship "version_qualified": false, // its Windows counterpart has no record "published": false, // so ROCm 10.2 was withheld from master-1106-abc1234 + "already_published": false, "overall": "fail", "tier0": "pass", "tier1": "pass", - "blocked_by": ["T0.12 missing"], + "blocked_by": ["T0.11 missing"], "blocking_tests": [], "results": { "T0.1": "pass", "T0.2": "pass", "T0.3": "pass", "T0.4": "pass", "T0.5": "pass", "T0.6": "pass", "T0.7": "pass", "T0.8": "pass", - "T0.9": "pass", "T0.10": "pass", "T0.11": "skip", - "T0.12": "not_applicable", // dropped before the final-archive check + "T0.9": "pass", + "T0.11": "not_applicable", // dropped before the final-archive check + "T0.12": "pass", "T0.14": "skip", "T1.1": "pass", "T1.2": "pass", "T1.3": "pass", "T1.4": "pass", - "T1.5": "pass", "T1.6": "pass" + "T1.6": "pass", "T1.7": "pass" }, "report_url": "reports/45012345678-ubuntu-rocm-10.2.json" }, @@ -223,9 +231,10 @@ Not in the feed: "build_result": "pass", // pass | fail | cancelled | skipped | unknown "tests": { "passed": 15, "failed": 0, "warned": 0, "skipped": 3, "missing": 0, "not_applicable": 0, "total": 18 }, "qualified": true, // passed every gating check required of it: Tier 0, - // Tier 1 and T0.12. Not whether it shipped. + // Tier 1 and T0.11. Not whether it shipped. "version_qualified": true, // both archives of ROCm 10.1 exist and qualified "published": true, // this run attached it to the release + "already_published": false, // true: an earlier run had already attached it "overall": "pass", // pass | warn | fail; fail exactly when qualified is false "tier0": "pass", // pass | warn | fail | missing "tier1": "pass", // pass | warn | fail | missing @@ -234,9 +243,9 @@ Not in the feed: "results": { "T0.1": "pass", "T0.2": "pass", "T0.3": "pass", "T0.4": "skip", "T0.5": "pass", "T0.6": "skip", "T0.7": "skip", "T0.8": "pass", - "T0.9": "pass", "T0.10": "pass", "T0.11": "pass", "T0.12": "pass", + "T0.9": "pass", "T0.11": "pass", "T0.12": "pass", "T0.14": "pass", "T1.1": "pass", "T1.2": "pass", "T1.3": "pass", "T1.4": "pass", - "T1.5": "pass", "T1.6": "pass" + "T1.6": "pass", "T1.7": "pass" }, "report_url": "reports/44999999999-win-rocm-10.1.json" } @@ -246,22 +255,23 @@ Not in the feed: ### Field notes -- **`results`** has one entry per test: T0.1–T0.12 and T1.1–T1.6, as listed in +- **`results`** has one entry per test: T0.1–T0.9, T0.11, T0.12, T0.14, T1.1–T1.4, + T1.6 and T1.7, as listed in [README.md](README.md). A test id added to the suite later appears here as soon as it runs, so the failure-frequency and heatmap views can be built from `index.json` alone. A retired test stops appearing in new rows and keeps its value in older ones; its id is never reused. The values: - `pass`: the check ran and passed. - `fail`: the check ran and found a problem. It blocks the archive only if - the test is gating; T1.5 never blocks. + the test is gating; T1.4 never blocks. - `warn`: the check ran and found something worth recording that does not block, e.g. upstream test programs shipped in the archive (T0.1). - `skip`: the check ran but could not apply, e.g. T0.4, T0.6 and T0.7 on - Windows, and T0.11 on Linux, which bundles no ROCm. + Windows, and T0.14 on Linux, which bundles no ROCm. - `missing`: the check should have run for this archive and did not. It blocks the archive (see `qualified`). - `not_applicable`: the check was never going to run for this archive. - T0.12 checks the final archive inside the release job, and only runs on + T0.11 checks the final archive inside the release job, and only runs on archives still in the release at that point. An archive dropped before then — because the other archive of its ROCm version was missing — or never built has it `not_applicable`. @@ -270,7 +280,7 @@ Not in the feed: always holds. Use `qualified`, not the counts, to decide pass or fail. - **`qualified`** is the verdict for this one archive: Tier 0 ran and no gating Tier 0 check failed, Tier 1 ran and no gating Tier 1 check failed, and the - release job's final-archive check (T0.12) passed. A `warn` does not block, + release job's final-archive check (T0.11) passed. A `warn` does not block, and non-gating tests never affect it. It does not say whether the archive shipped (`published`). - **`version_qualified`** is `true` when both archives of this ROCm version — @@ -280,10 +290,13 @@ Not in the feed: recorded no decision. - **`published`** says whether this run attached this archive to the release `tag`. It can be `false` even when `version_qualified` is `true`: an upload - can fail, and a nightly filling the gaps of an incomplete release never - replaces an archive that release already holds, so it reports `false` for - those. `published` describes what this run shipped, not what the release - holds today. + can fail, and a run filling the gaps of an incomplete release never replaces + an archive that release already holds. `published` describes what this run + shipped, not what the release holds today. +- **`already_published`** is `true` when this run did not upload its archive + because an earlier run had already attached an archive of the same name to + the release `tag`; `published` is then `false`. The release holds the earlier + run's bytes, which that run's own row (with `published: true`) describes. - **`overall`** is `fail` exactly when `qualified` is `false`. Otherwise it is the worst result of the gating tests that ran: `warn` if any of them warned, else `pass`. @@ -310,7 +323,7 @@ Not in the feed: - `tier0 missing`: no Tier 0 report; - `tier1=fail`: a gating Tier 1 check failed; - `tier1 missing`: no Tier 1 report, e.g. the GPU runner was offline; - - `T0.12 missing`: the release job's final-archive check did not run on it; + - `T0.11 missing`: the release job's final-archive check did not run on it; - on placeholder rows only: `build failed`, `build cancelled`, `build skipped` or `no report`. - **`blocking_tests`** lists the gating tests that failed; empty when none did. @@ -319,7 +332,7 @@ Not in the feed: names of any that are missing. - **`gfx_target`** is the gfx target Tier 1 ran on, and `null` when Tier 1 did not run. **`hardware_validated`** is `true` only when Tier 1 confirmed the GPU - it ran on is that target (T1.3). Every other target in `gfx.requested` was + it ran on is that target (T1.7). Every other target in `gfx.requested` was only checked for presence, never run. Don't present those as tested. - **`report_url`** is relative to the base URL; it holds every check's `status`, `gating`, `error` and `details`. @@ -330,11 +343,12 @@ An archive with no record at all gets a placeholder row. This happens when its build failed, so there was nothing to check, or when no check reported on it. In a placeholder row: -- every test is `missing` except T0.12, which is `not_applicable` (or +- every test is `missing` except T0.11, which is `not_applicable` (or `missing` in the rare case the archive reached the release job's final-archive check but the check itself could not run, e.g. its metadata was lost); `tier0` and `tier1` are `missing`; `qualified`, `version_qualified` and - `published` are `false`; and `overall` is `fail`; + `published` are `false`; `already_published` is `true` only when an earlier + run had already put that archive in the release; and `overall` is `fail`; - `blocked_by` follows `build_result`: `build failed`, `build cancelled`, `build skipped`, or `no report` when the build passed or its result is `unknown`; @@ -347,16 +361,16 @@ The first row of the [`index.json`](#example-indexjson) example is a placeholder ### `last_check` -A top-level object, not a row: what the most recent nightly or release run -decided. +A top-level object, written before `builds`, not a row: what the most recent +release run decided. -- **`status`** is `built` when the run built and qualified archives (its rows - are in `builds`), and `unchanged` when a nightly found the release for its tag - already holding every backend family and built nothing. The tag only changes - when upstream stable-diffusion.cpp or this repository changes, so a run of - `unchanged` nights means nothing new has landed upstream. +- **`status`** is `built` when the run built and qualified ROCm archives (its + rows are in `builds`), and `unchanged` when a release run found the release + for its tag already holding every ROCm version and built no ROCm archive. The + tag only changes when upstream stable-diffusion.cpp or this repository + changes, so a run of `unchanged` nights means nothing new has landed upstream. - **`tag`** and **`upstream_sha`** are what that run resolved — for an - `unchanged` night, the release that was already complete. + `unchanged` run, the release that already held every ROCm version. - **`run_id`**, **`run_attempt`**, **`run_url`**, **`event`** identify the run; **`checked_at`** is when it published. @@ -383,7 +397,9 @@ The `qualification-.json` record exactly as `aggregate.py` wrote it (`k - the `gfx` audit, and - `tiers` with every test. -The same content is attached to the release. Its own `build.build_id` (`@`) differs from the feed's `build_id`; use the feed's. +The same content is attached to the release, except that a withheld archive's +attached record is the one from the first run that withheld it on that tag and +attached a record. Its own `build.build_id` (`@`) differs from the feed's `build_id`; use the feed's. For a placeholder row it is a placeholder (`kind: "qualification_placeholder"`) with the same top-level fields: - `build` metadata, @@ -406,33 +422,50 @@ last good one. It is replaced only by a record from the same run or a newer one ## Differences from the llama.cpp feeds This feed has one archive per ROCm version, like lemonade-sdk/llama.cpp's, with -ROCm's math libraries installed separately by the user. Everything else in a row -means the same as there, except: +ROCm's math libraries installed separately by the user. lemonade-sdk/llamacpp-rocm +has one archive per GPU family, with ROCm bundled inside. Everything else in a +row means the same in all three, except: | Field | this repository | lemonade-sdk/llama.cpp | lemonade-sdk/llamacpp-rocm | |---|---|---|---| -| `schema_version` | `2` | `2` | `1` (same row shape) | +| `schema_version` | `3` (same row shape as `2`) | `2` | `1` (same row shape) | | `build_id` | `--rocm-` | same | `--rocm-` | | rows per run | 6 | 8 | 20 | -| `tag` | `master--`; set on every row | llama.cpp build number; set on every row | its own release tag; `null` unless `published` | +| `tag` | `master--`; set on every row | llama.cpp build number `b`; set on every row | its own release tag; `null` unless `published` | | `artifact` | the release asset name (`sd-master--…`) | the release name | the untagged CI name unless `published` | | `os` | `win` \| `ubuntu` | `win` \| `ubuntu` | `windows` \| `ubuntu` | -| `rocm_version` | `10.0` \| `10.1` \| `10.2` | `7.14` \| `10.0` \| `10.1` \| `10.2` | full nightly, e.g. `10.3.0a20261102` | -| `results` keys | T0.1–T0.12, T1.1–T1.6 — this repository's own ids | T0.1–T0.8, T0.11, T0.12, T1.1–T1.5 | T0.1–T0.3, T0.5–T0.9, T0.11, T0.13, T1.1–T1.6 | -| missing Tier 1 | blocks (`tier1 missing`) | does not block | blocks | -| final-archive check | T0.12; missing blocks | T0.11; missing does not block | T0.11; missing blocks | -| `hardware_validated` | `true` only when T1.3 confirmed the GPU | `true` whenever Tier 1 ran | `true` whenever Tier 1 ran | -| `last_check` | yes | — | — | +| `rocm_version` | `10.0` \| `10.1` \| `10.2`, one per archive | `7.14` \| `10.0` \| `10.1` \| `10.2`, one per archive | full nightly, e.g. `10.3.0a20261102`, same for the whole run | +| `rocm_newest_nightly`, `rocm_held_back_by` | — | — | whether the run fell back to an older nightly | +| `gfx_family` | — | — | the GPU family the archive serves | +| `version_qualified` | both archives of a ROCm version exist and qualified | same | not present (a release there is all or nothing) | +| `results` keys | T0.1–T0.9, T0.11, T0.12, T0.14, T1.1–T1.4, T1.6, T1.7 | T0.1–T0.8, T0.11, T0.12, T0.14, T1.1–T1.7 (older rows differ, see below) | T0.1–T0.3, T0.5–T0.9, T0.11, T0.13, T1.1–T1.6 | +| missing Tier 1 | blocks (`tier1 missing`) | same | blocks; Tier 1 runs only on gfx1151 (`not_applicable` elsewhere) | +| final-archive check | T0.11; missing blocks | same | same | +| `not_applicable` | T0.11 on an archive dropped before the release checks | same | T1.x outside gfx1151; T0.11 on a run with no release | +| `hardware_validated` | `true` only when T1.7 confirmed the GPU | same | `true` whenever Tier 1 ran | +| `last_check` | yes | yes | — | +| `already_published` | yes | yes | — | | placeholder `gfx` | all zero | all zero | requested targets, all in `missing` | - -Test ids are per repository: the same id names different checks in different -feeds (T0.11 is the final-archive check in llama.cpp and the bundled HIP runtime -check here). Compare checks across repositories by name, not by id. +| `latest/` file | `-rocm-.json` | same | `-rocm-.json` | + +Test ids are shared: an id means the same check in every one of these feeds +that runs it, and is never reused for a different check. Each feed runs only +some of the ids. T0.10 is retired, T0.13 is llamacpp-rocm's only, and T1.5 (the +reasoning pass) is run by llama.cpp and llamacpp-rocm only. llama.cpp does not +run T0.9; its rows up to 2026-11-11 carry its own retired T0.9 (and up to +2026-11-12 T0.10), which checked something else, and its rows without an +`already_published` field have no T0.14, T1.6 or T1.7. T0.14 (bundled HIP +runtime matches ROCm), T1.6 (ROCm loaded from the expected places) and T1.7 (GPU +target detected) mean the same here and in llama.cpp. ## Versioning and growth -Bump `schema_version` on any breaking change to `index.json` or the row shape. -Adding a field is not breaking (`last_check` was added without a bump). The +Bump `schema_version` on any breaking change to `index.json` or the row shape, +or when an existing value changes meaning. Version 3 replaced version 2 because +the checks were renumbered to the shared ids, so the same `results` key meant a +different check; the first version 3 publish started a fresh feed, and the +version 2 rows stay in the branch's git history. Adding a field is not breaking +(`last_check` and `already_published` were added without a bump). The dashboard should read `schema_version` and show a notice, rather than break, on a version it does not know. @@ -441,7 +474,7 @@ separate number. It versions the record written by `aggregate.py` (`report.py` sets it), not `index.json`, so the two do not have to match and change independently. -`index.json` grows by six rows per run that builds, and by nothing on a night -when upstream did not change. That is comfortable to poll for a long time, +`index.json` grows by six rows per run that builds ROCm archives, and by nothing +on a run whose release already held every ROCm version. That is comfortable to poll for a long time, especially compressed. If it ever is not, older rows will move into per-month files under a new `schema_version`. diff --git a/.github/qualify-rocm/README.md b/.github/qualify-rocm/README.md index 51b32d8fe..8c17e9545 100644 --- a/.github/qualify-rocm/README.md +++ b/.github/qualify-rocm/README.md @@ -7,8 +7,11 @@ any of them does. The design follows [lemonade-sdk/llama.cpp](https://github.com/lemonade-sdk/llama.cpp/tree/lemonade/.github/qualify-rocm) so both repositories behave the same way and feed the same dashboard. Test ids -are this repository's own, numbered from T0.1 and T1.1; they do not share -meanings with llama.cpp's. +are shared with lemonade-sdk/llama.cpp and lemonade-sdk/llamacpp-rocm: an id +means the same check in every repository that runs it, and is never reused for a +different check. This repository does not run T0.10 (retired in llama.cpp), +T0.13 (llamacpp-rocm's rocBLAS kernel check) or T1.5 (llama.cpp's reasoning +pass). T0.14, T1.6 and T1.7 mean the same as in llama.cpp, which runs them too. ## Why this exists @@ -59,9 +62,11 @@ sd-server against that driver copy instead crashes it with an access violation | Tier 0 — static checks | standard GitHub runners (`ubuntu-24.04`, `windows-2025`) | yes, affected ROCm version only | | Tier 1 — GPU inference | self-hosted Strix Halo (gfx1151) machines, Windows and Linux | yes, affected ROCm version only | -Both tiers run on every trigger — the nightly schedule, manual runs and pull -requests. The one exception is that Tier 1 is skipped for a pull request opened -from a fork, so code from outside this repository never runs on the self-hosted +Both tiers run on every pull request and manual run, and on every release run +that builds ROCm; a release run whose release already holds every ROCm version +builds and qualifies none (see [Release runs with nothing new](#release-runs-with-nothing-new)). +The one exception is that Tier 1 is skipped for a pull request opened from a +fork, so code from outside this repository never runs on the self-hosted machines. Each tier runs one job per published archive — two operating systems by three @@ -74,10 +79,12 @@ Vulkan, CUDA, Metal), publish as normal. The release job then exits non-zero so the gap is noticed. A version ships only when, for both of its archives, Tier 0 and Tier 1 both -reported and neither failed, and the final-archive check (T0.12) passed. Unlike +reported and neither failed, and the final-archive check (T0.11) passed. As in lemonade-sdk/llama.cpp, a Tier 1 that never reported — the GPU runner was offline, or ROCm failed to install — blocks the version rather than letting it ship untested. A `warn` never blocks. +The release job waits for Tier 1, so while the GPU runners are offline the whole +release waits too. On a pull request nothing is published at all, so there is no aggregate step to pass judgement. Each job therefore fails on its own as soon as a check fails — @@ -100,11 +107,11 @@ been packaged. | T0.7 | no build-machine folder left in the Linux binaries' library search path (RUNPATH): only `$ORIGIN` | yes | | T0.8 | `sd-server` still accepts the flags Lemonade launches it with | yes | | T0.9 | `sd-server` reports the upstream commit this run pinned | yes | -| T0.10 | the ROCm libraries the archive needs exist in the ROCm a user installs | yes | -| T0.11 | the bundled HIP runtime is byte-identical to that ROCm version's own copy | yes | -| T0.12 | the finished archive reads back intact and is the one the build job produced and the qualify jobs tested | yes | +| T0.11 | the finished archive reads back intact and is the one the build job produced and the qualify jobs tested | yes | +| T0.12 | the ROCm libraries the archive needs exist in the ROCm a user installs | yes | +| T0.14 | the bundled HIP runtime is byte-identical to that ROCm version's own copy | yes | -T0.12 comes from `check_final.py`, which runs in the release job on the archives +T0.11 comes from `check_final.py`, which runs in the release job on the archives about to be uploaded. It compares each archive's SHA-256 with the one its build job recorded, so the bytes that ship are the bytes every other check and Tier 1 ran on. The release job never repacks or merges an archive; it uploads it under @@ -125,20 +132,20 @@ for one 512x512 image over the same OpenAI-style endpoint Lemonade calls. |---|---|---| | T1.1 | the server starts and serves its web page | yes | | T1.2 | the GPU actually did the work | yes | -| T1.3 | the GPU sd-server found is the gfx target this runner validates | yes | -| T1.4 | the image is a PNG of the requested size that decodes and is not blank | yes | -| T1.5 | the same request again gives identical bytes | no | +| T1.3 | the image is a PNG of the requested size that decodes and is not blank | yes | +| T1.4 | the same request again gives identical bytes | no | | T1.6 | the running server loaded the bundled HIP runtime from the archive and every other ROCm library from the user's ROCm install | yes | +| T1.7 | the GPU sd-server found is the gfx target this runner validates | yes | **T1.2 is the one that matters.** Every other check in this tier passes perfectly well when the GPU was never used at all — the image is simply slower to arrive. How it avoids being fooled is described below. -T1.3 is what makes a record say `hardware_validated`. Only gfx1151 has test +T1.7 is what makes a record say `hardware_validated`. Only gfx1151 has test hardware today; the target comes from the workflow, so adding a runner with another GPU is one more Tier 1 leg, not a change to the scripts. -T1.5 is recorded but never blocks a release. On the gfx1151 runners sd-server +T1.4 is recorded but never blocks a release. On the gfx1151 runners sd-server is in fact bit-for-bit repeatable, so a difference is worth a look, but GPUs do not promise it and treating it as a release gate would block good builds. @@ -241,7 +248,7 @@ archive's libraries available?" depends entirely on what the user installed. Checking against the ROCm used to *build* the archive would always pass — those are the exact files it was compiled against. `install_rocm.py` therefore installs the components an end user gets (the kernels for their GPU) rather -than the components a build needs (compilers), and T0.10, T0.11 and Tier 1 all +than the components a build needs (compilers), and T0.12, T0.14 and Tier 1 all verify against that. Everything goes into a throwaway virtual environment under the runner's temporary directory; nothing is installed system-wide. @@ -258,21 +265,47 @@ release we support provides (Ubuntu 24.04, glibc 2.39). The check passes today and would fail if the build job's runner image moved to a newer Linux without that decision being made deliberately. -### Nightlies with nothing new +### Release runs with nothing new The release tag is `master--`, so it only -changes when upstream stable-diffusion.cpp or this repository changes. A nightly -first checks whether the release for its tag already holds every backend family -and `checksums.txt`; if it does, the whole run is skipped, and only a -`last_check` of `"unchanged"` is written to the feed. If the release is missing -anything — say ROCm 10.2 was withheld the night before — the nightly rebuilds, -re-qualifies, and uploads only the archives that are missing. An archive already -in a release is never replaced, because Lemonade may already be pinned to it. -`checksums.txt` is rebuilt from GitHub's own digests on every run. When the run -re-qualifies an archive that is still withheld, its qualification record is -replaced with the new one (an archive whose build produced no report this run -keeps its previous record); the record of an archive that shipped is never -touched. +changes when upstream stable-diffusion.cpp or this repository changes. A release +run (the nightly, or a manual run with `create_release`) first checks whether the +release for its tag already holds every backend family, its notes, and a +`checksums.txt` that lists each of its archives with GitHub's SHA-256 digest +and nothing else; if it does, the whole run is skipped, and only a `last_check` +of `"unchanged"` is written to the feed. If only every ROCm version is there — +say the Metal build failed the night before — the run rebuilds the other +families but builds and qualifies no ROCm archive, and again only `last_check` +changes in the feed. If a ROCm version is missing — say ROCm 10.2 was +withheld — the run rebuilds and re-qualifies every ROCm version, and uploads +only the archives that are missing; its feed rows for the versions already in +the release say `already_published`. +An archive already in a release is never replaced, because Lemonade may already +be pinned to it. A run that does not release (a pull request, or a manual run +without `create_release`) always builds and qualifies everything. A family this +run dropped, or a ROCm version that did not re-qualify, fails the release job +only when the release does not already hold it from an earlier run. + +Each archive's qualification record is uploaded just before the archive. A +withheld archive's record, which says why it was withheld, is uploaded once and +kept on later runs of the same tag, so its digest does not change; the feed has +each run's verdict. Only when a later run ships that archive is its +record replaced; the record of an archive that shipped is never touched. (A +record that says its archive qualified, left by an archive upload that failed, +is replaced too.) `checksums.txt` is rebuilt from GitHub's own digests on every +run, and replaced only when it changes: when an archive was added, or when an +earlier run uploaded an archive but stopped before rewriting `checksums.txt`. +A release whose `checksums.txt` does not match its archives counts as +incomplete, so the next release run rebuilds the non-ROCm families (and ROCm +too if a version is missing) and rewrites it. A run that fills a gap therefore +changes the digests of `checksums.txt` and of the filled archive's record: +anything pinning those for that tag must refresh its pins. The release notes +are written last, from the assets the release really holds, even when the +upload failed part way. A release whose notes were never written, which has +only the one-line summary, counts as incomplete, so the next release run writes +them. Two release runs on the same tag take turns, but GitHub keeps only one +waiting: a third cancels the waiting run's release job, which then uploads +nothing; its feed rows are still published. ## Running by hand @@ -331,22 +364,22 @@ The release job's records are also published, pass or fail, to the `qualification-data` branch by `publish_qualification.py`, so a dashboard can follow the history of every run without reading each release. An archive whose build failed gets a placeholder row, so a missing archive shows up as a failure -rather than a gap, and a nightly skipped for lack of changes is recorded too. +rather than a gap, and a release run with nothing new to build is recorded too. The layout and every field are described in [FEED.md](FEED.md). ## Files | File | Role | |---|---| -| `tier0_static.py` | Tier 0 checks T0.1–T0.11 | -| `check_final.py` | T0.12, in the release job | -| `tier1_gpu.py` | Tier 1 checks T1.1–T1.6 | +| `tier0_static.py` | Tier 0 checks T0.1–T0.9, T0.12 and T0.14 | +| `check_final.py` | T0.11, in the release job | +| `tier1_gpu.py` | Tier 1 checks T1.1–T1.4, T1.6 and T1.7 | | `install_rocm.py` | installs a user-style ROCm runtime for Tier 0 and Tier 1 | | `binfmt.py` | reads gfx targets, imports, RUNPATH and glibc out of ELF and PE files | | `archive.py` | unpacks an archive the way a user's unzip would | | `report.py` | the fragment and record format every tier writes | | `aggregate.py` | merges fragments per archive and decides which ROCm versions ship | -| `release_assets.py` | which assets make up each backend family; used to drop incomplete families and to skip unchanged nightlies | +| `release_assets.py` | which assets make up each backend family; used to drop incomplete families and to skip what a release already holds | | `release_notes.py` | renders the release notes from the attached assets | | `publish_qualification.py` | writes the `qualification-data` feed | @@ -354,7 +387,7 @@ The layout and every field are described in [FEED.md](FEED.md). - **Performance.** Tracked downstream against these same artifacts; a second set of numbers here would split the history. -- **Image quality.** T1.4 covers "the output is a real picture", which is what +- **Image quality.** T1.3 covers "the output is a real picture", which is what catches a backend producing NaNs or a blank image. Judging whether an image is *good* is a separate problem needing a different kind of test. - **Other backends.** CPU, Vulkan, CUDA and Metal archives get the release diff --git a/.github/qualify-rocm/aggregate.py b/.github/qualify-rocm/aggregate.py index 708b8352f..08c64374e 100644 --- a/.github/qualify-rocm/aggregate.py +++ b/.github/qualify-rocm/aggregate.py @@ -18,12 +18,12 @@ Within one archive, both tiers must have reported and neither may have failed: - the static checks (Tier 0) must be present and must pass. The release - job's own final-archive check (T0.12) is filed under Tier 0 too, but on its + job's own final-archive check (T0.11) is filed under Tier 0 too, but on its own it does not count as Tier 0 having reported: the Tier 0 job must have. - - the GPU checks (Tier 1) must be present and must pass. Unlike + - the GPU checks (Tier 1) must be present and must pass. As in lemonade-sdk/llama.cpp, a missing Tier 1 blocks: an offline GPU runner withholds the ROCm version rather than shipping it untested. - - with --require-final, the final-archive check (T0.12) must be present too, + - with --require-final, the final-archive check (T0.11) must be present too, so an archive whose bytes were never compared with the tested ones cannot ship. Each build covers 20 or more gfx targets and only one of them has test @@ -98,7 +98,7 @@ def published_name(tag, os_name, rocm_version): def tier_reported(record, tier): """Whether a tier's own job reported on this archive. - The release job's final-archive check (T0.12) is filed under tier0 too, so a + The release job's final-archive check (T0.11) is filed under tier0 too, so a tier0 bucket holding nothing else means the Tier 0 job itself never ran. The gate, the job summary and the feed all use this one rule. """ @@ -106,7 +106,7 @@ def tier_reported(record, tier): if not bucket: return False if tier == "tier0": - return bool({t.get("id") for t in bucket.get("tests", [])} - {"T0.12"}) + return bool({t.get("id") for t in bucket.get("tests", [])} - {"T0.11"}) return True @@ -122,8 +122,8 @@ def decide(record, require_final=False): elif tiers[tier]["status"] == report.STATUS_FAIL: reasons.append(f"{tier}=fail") - if require_final and "T0.12" not in tier0_ids: - reasons.append("T0.12 missing") + if require_final and "T0.11" not in tier0_ids: + reasons.append("T0.11 missing") return not reasons, reasons @@ -213,7 +213,7 @@ def main(): parser.add_argument("--rocm-versions", default=None, help="the ROCm versions this run builds, e.g. 10.0,10.1,10.2") parser.add_argument("--require-final", action="store_true", - help="block an archive the release job's final-archive check (T0.12) did not run on") + help="block an archive the release job's final-archive check (T0.11) did not run on") parser.add_argument("--fail-on-no-promote", action="store_true") args = parser.parse_args() @@ -330,8 +330,8 @@ def main(): handle.write(f"blocked_rocm_versions={' '.join(blocked)}\n") if blocked: - print(f"::error::ROCm {', '.join(blocked)} did not qualify and will be " - "dropped from this release. Other ROCm versions and every other " + print(f"::error::ROCm {', '.join(blocked)} did not qualify, so this run " + "does not upload them. Other ROCm versions and every other " "backend are unaffected.") if args.fail_on_no_promote and blocked: sys.exit(1) diff --git a/.github/qualify-rocm/check_final.py b/.github/qualify-rocm/check_final.py index 44116fd8f..14193534d 100644 --- a/.github/qualify-rocm/check_final.py +++ b/.github/qualify-rocm/check_final.py @@ -5,7 +5,7 @@ Runs inside the release job, after the family completeness check, which is the only place this question can be answered: - T0.12 final archive integrity -- the final archive opens, reads back intact + T0.11 final archive integrity -- the final archive opens, reads back intact (every entry's CRC-32 is checked), still contains sd-server and the file holding the GPU code, and is the archive the build job produced and the qualify jobs tested: its SHA-256 must match the one the build @@ -16,7 +16,7 @@ and uploads it under the same name, never repacking or merging anything into it. If any step in between ever changed the bytes -- a re-pack, a merge, a corrupted transfer -- the SHA-256 would no longer match and the archive's ROCm -version would be withheld. (lemonade-sdk/llama.cpp calls the same check T0.11, +version would be withheld. (lemonade-sdk/llama.cpp runs the same check, also T0.11, in check_post_merge.py.) The file is opened inside the check, so an archive that cannot be read is @@ -71,7 +71,7 @@ def check_integrity(path, os_name, expected_sha): def main(): - parser = argparse.ArgumentParser(description="Final release-archive check (T0.12)") + parser = argparse.ArgumentParser(description="Final release-archive check (T0.11)") parser.add_argument("--archive", required=True) parser.add_argument("--meta", required=True) parser.add_argument("--run-id", default=os.environ.get("GITHUB_RUN_ID")) @@ -85,7 +85,7 @@ def main(): artifact=os.path.basename(args.archive), os_name=info["os"], rocm_version=info["rocm_version"], sdcpp_tag=info.get("tag"), upstream_sha=info.get("upstream_sha"), run_id=args.run_id, run_attempt=args.run_attempt)) - tier.run("T0.12", "final archive integrity", + tier.run("T0.11", "final archive integrity", lambda: check_integrity(args.archive, info["os"], info.get("sha256"))) tier.write(args.output) tier.print_summary() diff --git a/.github/qualify-rocm/publish_qualification.py b/.github/qualify-rocm/publish_qualification.py index 671200245..a0ad45e8a 100644 --- a/.github/qualify-rocm/publish_qualification.py +++ b/.github/qualify-rocm/publish_qualification.py @@ -15,28 +15,33 @@ An archive with no record (its build failed / no check ever reported on it) gets a placeholder row and a placeholder report saying so. Therefore, a failing build shows up in the feed instead of silently leaving a gap. A test the record does not contain is reported as either: - - "not_applicable": it is never run for this archive -- the final-archive check T0.12 on an archive that never reached it (it was dropped from the release before they ran); or + - "not_applicable": it is never run for this archive -- the final-archive check T0.11 on an archive that never reached it (it was dropped from the release before they ran); or - "missing": it should have run and did not. Neither is folded into "failed"; `qualified` is the verdict. A feed written by an older schema_version is not mixed with this one: the first publish starts a fresh index.json, reports/ and latest/. The old files stay in the branch's git history. -index.json also carries a top-level "last_check": what the most recent nightly or -release run decided. A nightly whose tag was already fully published builds -nothing and so adds no rows; with --mark-unchanged it records only last_check +index.json also carries a top-level "last_check": what the most recent release run +decided. A release run whose tag already holds every ROCm version builds no ROCm +archive and so adds no rows; with --mark-unchanged it records only last_check (status "unchanged"), so the dashboard can tell "nothing changed upstream" apart from "the nightly did not run". +A run that refills an incomplete release rebuilds every ROCm version but uploads +only the missing ones. Its rows for the versions an earlier run already put in the +release say "already_published": true, with "published": false. + The contract this writes is FEED.md, copied to the branch as SCHEMA.md. Usage: python3 publish_qualification.py --records-dir ./records \ --data-dir ./data/qualification --operating-systems ubuntu,win \ --rocm-versions 10.0,10.1,10.2 --tag master-1106-abc1234 --upstream-sha \ - --jobs-file jobs.jsonl --published-artifacts "" --final-checked "" + --jobs-file jobs.jsonl --published-artifacts "" --already-published "" \ + --final-checked "" - # A nightly that found its release already complete: + # A release run that found every ROCm version already published: python3 publish_qualification.py --mark-unchanged --data-dir ./data/qualification \ --tag master-1106-abc1234 --upstream-sha """ @@ -54,18 +59,19 @@ import aggregate # noqa: E402 import report # noqa: E402 -SCHEMA_VERSION = 2 +# 3: the checks were renumbered to the IDs lemonade-sdk/llama.cpp and llamacpp-rocm use. +SCHEMA_VERSION = 3 # Every test the suite runs, in the order the README lists them. # A test absent from a record shows up as "missing" or "not_applicable", so the dashboard always has the same columns to draw. # A test id not listed here is still published, never dropped. TIER_TESTS = { "tier0": ["T0.1", "T0.2", "T0.3", "T0.4", "T0.5", "T0.6", "T0.7", "T0.8", - "T0.9", "T0.10", "T0.11", "T0.12"], - "tier1": ["T1.1", "T1.2", "T1.3", "T1.4", "T1.5", "T1.6"], + "T0.9", "T0.11", "T0.12", "T0.14"], + "tier1": ["T1.1", "T1.2", "T1.3", "T1.4", "T1.6", "T1.7"], } # Run by the release job on the archives still in the release after its completeness check. -FINAL_TESTS = {"T0.12"} +FINAL_TESTS = {"T0.11"} STATUS_MISSING = "missing" STATUS_NOT_APPLICABLE = "not_applicable" @@ -246,7 +252,7 @@ def make_placeholder(os_name, rocm_version, build_result, tag, upstream_sha, def build_entry(record, build_id, build_result, version_qualified, published, - final_checked, run_url, event, run_attempt): + already_published, final_checked, run_url, event, run_attempt): """Derive the compact, dashboard-facing index row from a full record.""" build = record.get("build", {}) results, blocking = collect_results(record, final_checked) @@ -286,6 +292,7 @@ def build_entry(record, build_id, build_result, version_qualified, published, "qualified": bool(record.get("promoted")), "version_qualified": version_qualified, "published": published, + "already_published": already_published, "overall": record.get("overall"), "tier0": tier_status(record, "tier0"), "tier1": tier_status(record, "tier1"), @@ -378,7 +385,6 @@ def upsert_index(index_path, repo, entries, check=None): "schema_version": SCHEMA_VERSION, "repo": repo or index.get("repo"), "updated_at": max((b.get("generated_at") or "" for b in builds), default="") or None, - "builds": builds, } # Like latest/, last_check never moves back to an older run: re-running an # old run must not make the dashboard report it as the newest decision. @@ -388,13 +394,14 @@ def upsert_index(index_path, repo, entries, check=None): check = previous if check or previous: out["last_check"] = check or previous + out["builds"] = builds return out def main(): parser = argparse.ArgumentParser(description="Publish qualification records to the dashboard feed") parser.add_argument("--mark-unchanged", action="store_true", - help="record only last_check: a nightly whose release was already complete") + help="record only last_check: a release run whose release already held every ROCm version") parser.add_argument("--records-dir", help="folder holding the qualification-*.json records aggregate.py wrote") parser.add_argument("--data-dir", required=True, @@ -409,8 +416,10 @@ def main(): help="this run's jobs, one {name, conclusion} JSON object per line") parser.add_argument("--published-artifacts", default="", help="the ROCm archives the release job uploaded, space separated") + parser.add_argument("--already-published", default="", + help="the ROCm archives an earlier run had already put in the release, space separated") parser.add_argument("--final-checked", default="", - help="the ROCm archives the final-archive check (T0.12) ran on, space separated") + help="the ROCm archives the final-archive check (T0.11) ran on, space separated") parser.add_argument("--event", default=os.environ.get("GITHUB_EVENT_NAME"), help="what triggered the run, e.g. schedule or workflow_dispatch") parser.add_argument("--repo", default=os.environ.get("GITHUB_REPOSITORY"), @@ -427,7 +436,7 @@ def main(): os.makedirs(args.data_dir, exist_ok=True) index = upsert_index(index_path, args.repo, [], last_check("unchanged", args, run_attempt)) write_json(index_path, index) - print(f"Recorded an unchanged nightly for {args.tag}; {len(index['builds'])} build(s) in the index") + print(f"Recorded an unchanged run for {args.tag}; {len(index['builds'])} build(s) in the index") return if not (args.records_dir and args.operating_systems and args.rocm_versions): parser.error("--records-dir, --operating-systems and --rocm-versions are required") @@ -435,6 +444,7 @@ def main(): expected = [(o, v) for v in aggregate.split_list(args.rocm_versions) for o in aggregate.split_list(args.operating_systems)] published_artifacts = set(args.published_artifacts.split()) + already_published = set(args.already_published.split()) final_checked = set(args.final_checked.split()) records, summary = load_records(args.records_dir) @@ -511,6 +521,7 @@ def main(): version_qualified = build.get("rocm_version") not in blocked_versions published = not is_placeholder and build.get("artifact") in published_artifacts entry = build_entry(record, build_id, build_result, version_qualified, published, + build.get("artifact") in already_published, final_checked, run_url, args.event, run_attempt) entries.append(entry) diff --git a/.github/qualify-rocm/release_assets.py b/.github/qualify-rocm/release_assets.py index 6b2a8534e..24a40e658 100644 --- a/.github/qualify-rocm/release_assets.py +++ b/.github/qualify-rocm/release_assets.py @@ -16,25 +16,41 @@ check-dir the release job: drop every incomplete family from the folder of built artifacts before anything is uploaded. Exits non-zero - only when nothing at all is left to publish. - check-release the resolve-upstream job, on a nightly: does the release for - this tag already hold every family (and checksums.txt)? If so, - the nightly has nothing to add and skips the whole build. + only when nothing at all is left to publish. Outputs missing, + summary and dropped (the families dropped). + check-release the resolve-upstream job, on a release run: does the release for + this tag already hold every family (and checksums.txt, and with + --body-file its notes)? With --checksums-file, checksums.txt + must also list every archive in the release with the SHA-256 + GitHub has for it (from --assets-json), and nothing else; a + stale one is a gap, which the next upload rewrites. If there is + no gap, the run has nothing to add and skips the whole build. + If only every ROCm version is there, it skips the ROCm builds + and their qualification, and rebuilds the rest. The release + job also runs it after the upload, so it fails only for + families the release really lacks. Outputs complete, + rocm_complete and gaps (the incomplete families). Keep the lists in step with the build matrices in build.yml. Usage: python3 release_assets.py check-dir --dir artifact --branch master \ --short abc1234 --rocm-versions 10.0,10.1,10.2 - python3 release_assets.py check-release --names-file assets.txt --branch master \ - --short abc1234 --rocm-versions 10.0,10.1,10.2 + python3 release_assets.py check-release --assets-json assets.json --branch master \ + --short abc1234 --rocm-versions 10.0,10.1,10.2 --body-file body.md \ + --checksums-file checksums.txt """ import argparse import fnmatch +import json import os import sys +# release_notes.py starts the notes with it; a release whose notes were never written has only the summary. +NOTES_MARKER = "
" +# What the release job lists in checksums.txt. +ARCHIVE_SUFFIXES = (".zip", ".tar.xz") CUDA_ARCHS = ["sm_75", "sm_80", "sm_86", "sm_89", "sm_90", "sm_100", "sm_120", "sm_121"] @@ -73,39 +89,91 @@ def write_outputs(**values): def check_dir(args, fams): names = sorted(os.listdir(args.dir)) - missing, summary = 0, [] + missing, summary, dropped = 0, [], [] for family, patterns in missing_by_family(names, fams).items(): for pattern in patterns: print(f"::error::[{family}] Missing artifact: {pattern}") if not patterns: continue print(f"::warning::{family} family is incomplete ({len(patterns)} artifact(s) missing) " - f"- dropping all {family} artifacts from this release.") + f"- not uploading any {family} artifact.") for pattern in fams[family]: for name in fnmatch.filter(names, pattern): os.remove(os.path.join(args.dir, name)) print(f"removed {name}") missing += len(patterns) summary.append(f"{family}: {len(patterns)} missing, family dropped") + dropped.append(family) - write_outputs(missing=missing, summary=", ".join(summary)) - left = [n for n in os.listdir(args.dir) if n.endswith((".zip", ".tar.xz"))] + write_outputs(missing=missing, summary=", ".join(summary), dropped=" ".join(dropped)) + left = [n for n in os.listdir(args.dir) if n.endswith(ARCHIVE_SUFFIXES)] if not left: print(f"::error::No release artifacts left in {args.dir}; refusing to publish nothing.") sys.exit(1) print(f"{len(left)} artifact(s) ready to publish" + (f"; {', '.join(summary)}" if summary else "")) -def check_release(args, fams): +def read_assets(args): + """The release's uploaded asset names, and {name: digest} when --assets-json gives them.""" + if args.assets_json: + with open(args.assets_json, encoding="utf-8") as handle: + assets = [a for a in json.load(handle)["assets"] if a.get("state") == "uploaded"] + return [a["name"] for a in assets], {a["name"]: a.get("digest") or "" for a in assets} with open(args.names_file, encoding="utf-8") as handle: - names = [line.strip() for line in handle if line.strip()] + return [line.strip() for line in handle if line.strip()], None + + +def checksums_problems(digests, path): + """What checksums.txt gets wrong: it lists each archive with GitHub's digest of it, and nothing else.""" + try: + with open(path, encoding="utf-8") as handle: + lines = handle.read().splitlines() + except (OSError, UnicodeDecodeError): + return ["could not be read"] + problems, listed = [], {} + for line in lines: + parts = line.split() + if len(parts) != 2: + if parts: + problems.append(f"has a malformed line: {line.strip()}") + continue + name = parts[1].lstrip("*") + if name in listed: + problems.append(f"lists {name} twice") + listed[name] = parts[0].lower() + archives = {n: d for n, d in digests.items() if n.endswith(ARCHIVE_SUFFIXES)} + problems += [f"does not list {n}" for n in sorted(archives) if n not in listed] + problems += [f"lists {n}, which the release does not hold" for n in sorted(listed) if n not in archives] + # An archive GitHub has no digest for can only be checked by name. + problems += [f"has the wrong digest for {n}" for n, d in sorted(archives.items()) + if n in listed and d.startswith("sha256:") and listed[n] != d[len("sha256:"):].lower()] + return problems + + +def check_release(args, fams): + names, digests = read_assets(args) gaps = {f: m for f, m in missing_by_family(names, fams).items() if m} if "checksums.txt" not in names: gaps["checksums"] = ["checksums.txt"] + elif args.checksums_file: + problems = checksums_problems(digests, args.checksums_file) + for problem in problems: + print(f"checksums.txt {problem}") + if problems: + gaps["checksums"] = ["an up-to-date checksums.txt"] + if args.body_file: + with open(args.body_file, encoding="utf-8") as handle: + if NOTES_MARKER not in handle.read(): + gaps["notes"] = ["release notes"] for family, patterns in gaps.items(): print(f"[{family}] not yet published: {', '.join(patterns)}") - write_outputs(complete="false" if gaps else "true") + rocm_complete = not any(family.startswith("rocm-") for family in gaps) + write_outputs(complete="false" if gaps else "true", + rocm_complete="true" if rocm_complete else "false", + gaps=" ".join(gaps)) print("The release already holds every family." if not gaps else "The release is incomplete.") + if gaps and rocm_complete: + print("Every ROCm version is already published, so no ROCm archive is built.") def main(): @@ -116,7 +184,16 @@ def main(): parser.add_argument("--rocm-versions", required=True, help="X.Y, e.g. 10.0,10.1,10.2") parser.add_argument("--dir", help="check-dir: folder of built artifacts") parser.add_argument("--names-file", help="check-release: asset names, one per line") + parser.add_argument("--assets-json", help="check-release, instead of --names-file: " + "what 'gh release view --json assets' prints, with each asset's state and digest") + parser.add_argument("--body-file", help="check-release: the release's notes; without it they are not checked") + parser.add_argument("--checksums-file", help="check-release, with --assets-json: the release's checksums.txt; " + "without it only its presence is checked") args = parser.parse_args() + if args.mode == "check-release" and not (args.names_file or args.assets_json): + parser.error("check-release needs --names-file or --assets-json") + if args.checksums_file and not args.assets_json: + parser.error("--checksums-file needs --assets-json for the digests") fams = families(args.branch, args.short, [v for v in args.rocm_versions.replace(" ", "").split(",") if v]) (check_dir if args.mode == "check-dir" else check_release)(args, fams) diff --git a/.github/qualify-rocm/report.py b/.github/qualify-rocm/report.py index a2549a994..6656ecd8a 100644 --- a/.github/qualify-rocm/report.py +++ b/.github/qualify-rocm/report.py @@ -26,7 +26,8 @@ import time import traceback -SCHEMA_VERSION = 1 +# 2: the checks were renumbered to the IDs lemonade-sdk/llama.cpp and llamacpp-rocm use. +SCHEMA_VERSION = 2 STATUS_PASS = "pass" STATUS_FAIL = "fail" diff --git a/.github/qualify-rocm/tier0_static.py b/.github/qualify-rocm/tier0_static.py index dcc3fd63a..95d3829f1 100644 --- a/.github/qualify-rocm/tier0_static.py +++ b/.github/qualify-rocm/tier0_static.py @@ -43,18 +43,20 @@ all still accepted (needs --run-binaries). T0.9 upstream provenance -- sd-server reports the upstream commit this run pinned (needs --run-binaries). - T0.10 ROCm dependency resolution -- the ROCm libraries this archive needs + T0.12 ROCm dependency resolution -- the ROCm libraries this archive needs exist in the ROCm a user will install (needs --rocm-dirs). - T0.11 bundled HIP runtime -- the HIP runtime shipped in the archive is + T0.14 bundled HIP runtime -- the HIP runtime shipped in the archive is byte-identical to that ROCm version's own copy (needs --rocm-dirs). -T0.12 (final archive integrity) is emitted separately by check_final.py, which +T0.11 (final archive integrity) is emitted separately by check_final.py, which runs in the release job on the exact files about to be uploaded. -Test ids are this repository's own: they do not share meanings with lemonade-sdk/llama.cpp's, -and an id is never reused for a different check. +Test ids are shared with lemonade-sdk/llama.cpp and lemonade-sdk/llamacpp-rocm: an id +means the same check in every repository that runs it, and is never reused for a +different check. This repository does not run T0.10 (retired in llama.cpp) or T0.13 +(llamacpp-rocm only). T0.14 means the same as in llama.cpp, which runs it too. Usage: python3 tier0_static.py --meta meta/qualify-meta-win-rocm-10.1.json \ @@ -124,7 +126,7 @@ "libresolv.so.2", "libgomp.so.1", } # Windows DLLs supplied by the OS or the MSVC redistributable. gdi32 and ntdll -# are needed by the bundled HIP runtime, which llama.cpp's archives do not ship. +# are needed by the bundled HIP runtime. BASE_DLLS_WIN = ("kernel32", "user32", "gdi32", "advapi32", "ws2_32", "shell32", "ole32", "oleaut32", "bcrypt", "crypt32", "dbghelp", "ntdll", "msvcp140", "vcruntime140", "vcruntime140_1", "msvcrt", @@ -133,7 +135,7 @@ # ROCm libraries. Apart from the bundled HIP runtime these are deliberately NOT # in the archive: the user installs ROCm, and stable-diffusion.cpp loads it from -# there at run time. T0.5 records which ones an archive needs; T0.10 confirms +# there at run time. T0.5 records which ones an archive needs; T0.12 confirms # they exist in the ROCm that will actually be installed. hipBLASLt is named # libhipblaslt.dll on Windows, hence both spellings. ROCM_LIB_PREFIXES = ( @@ -558,7 +560,7 @@ def _rocm_files(rocm_dirs): def check_rocm_dependencies(root, os_name, rocm_dirs): - """T0.10: the ROCm libraries this archive needs will actually be there. + """T0.12: the ROCm libraries this archive needs will actually be there. The archive says "I need hipblas.dll", and whether that is true depends entirely on what the user installed -- something the build machine can tell @@ -597,7 +599,7 @@ def check_rocm_dependencies(root, os_name, rocm_dirs): def check_bundled_runtime(root, os_name, rocm_dirs): - """T0.11: the HIP runtime shipped in the archive matches its ROCm version. + """T0.14: the HIP runtime shipped in the archive matches its ROCm version. The Windows zip carries amdhip64_7.dll, amd_comgr.dll and rocm_kpack.dll, and Windows loads those ahead of anything on PATH. A copy from another ROCm @@ -634,7 +636,7 @@ def check_bundled_runtime(root, os_name, rocm_dirs): return (report.STATUS_PASS, None, details) -# Every check this script runs, in order. T0.12 comes from check_final.py. +# Every check this script runs, in order. T0.11 comes from check_final.py. TIER0_CHECKS = [ ("T0.1", "archive contents"), ("T0.2", "HIP code present"), @@ -645,8 +647,8 @@ def check_bundled_runtime(root, os_name, rocm_dirs): ("T0.7", "library search path"), ("T0.8", "sd-server flag surface"), ("T0.9", "upstream provenance"), - ("T0.10", "ROCm dependency resolution"), - ("T0.11", "bundled HIP runtime matches ROCm"), + ("T0.12", "ROCm dependency resolution"), + ("T0.14", "bundled HIP runtime matches ROCm"), ] @@ -718,8 +720,8 @@ def main(): "T0.7": lambda: check_rpath(root, args.os_name), "T0.8": lambda: check_server_flags(help_run), "T0.9": lambda: check_provenance(help_run, args.upstream_sha), - "T0.10": lambda: check_rocm_dependencies(root, args.os_name, rocm_dirs), - "T0.11": lambda: check_bundled_runtime(root, args.os_name, rocm_dirs), + "T0.12": lambda: check_rocm_dependencies(root, args.os_name, rocm_dirs), + "T0.14": lambda: check_bundled_runtime(root, args.os_name, rocm_dirs), } for test_id, name in TIER0_CHECKS: tier.run(test_id, name, checks[test_id]) diff --git a/.github/qualify-rocm/tier1_gpu.py b/.github/qualify-rocm/tier1_gpu.py index 1ce83cfd6..214a62ab9 100644 --- a/.github/qualify-rocm/tier1_gpu.py +++ b/.github/qualify-rocm/tier1_gpu.py @@ -22,18 +22,21 @@ ROCm device with none left on the CPU, and compute buffers were allocated in VRAM on a ROCm device. - T1.3 GPU target detected -- GATING. The device sd-server found is the - gfx target this runner is meant to validate. - This is what makes `hardware_validated` true. - T1.4 image well-formed -- GATING. A PNG of the requested size that + T1.3 image well-formed -- GATING. A PNG of the requested size that decodes and is not blank. - T1.5 deterministic output -- NON-gating. The same request again gives + T1.4 deterministic output -- NON-gating. The same request again gives identical bytes. See check_determinism(). T1.6 ROCm loaded from the expected places -- GATING. The running server loaded the bundled HIP runtime from the archive and every other ROCm library from the user's ROCm install -- nothing from a stale display-driver copy in System32. + T1.7 GPU target detected -- GATING. The device sd-server found is the + gfx target this runner is meant to validate. + This is what makes `hardware_validated` true. + +The ids are shared with lemonade-sdk/llama.cpp and lemonade-sdk/llamacpp-rocm (see +tier0_static.py). T1.5 (llama.cpp's reasoning pass) has no counterpart here. Usage: python3 tier1_gpu.py --meta qualify-meta-win-rocm-10.1.json \ @@ -185,6 +188,11 @@ def file_sha256(path): return digest.hexdigest() +def model_is_valid(path): + return (os.path.exists(path) and os.path.getsize(path) == MODEL_BYTES + and file_sha256(path) == MODEL_SHA256) + + def ensure_model(cache_dir): """Return a verified copy of the test model, downloading it at most once per machine. @@ -199,7 +207,7 @@ def ensure_model(cache_dir): path = os.path.join(folder, MODEL_FILE) os.makedirs(folder, exist_ok=True) if os.path.exists(path): - if os.path.getsize(path) == MODEL_BYTES and file_sha256(path) == MODEL_SHA256: + if model_is_valid(path): print(f"Using cached model {path}") return path print(f"::warning::cached model {path} is corrupt; downloading it again") @@ -225,6 +233,10 @@ def ensure_model(cache_dir): last = exc if os.path.exists(part): os.remove(part) + # On Windows a copy another job moved into place and is serving cannot be replaced. + if model_is_valid(path): + print(f"Using the model another job downloaded: {path}") + return path time.sleep(10 * attempt) raise SystemExit(f"::error::could not download the test model: {last}") @@ -659,7 +671,7 @@ def check_gpu_did_work(server): def check_gpu_target(server, gfx_target): - """T1.3: the device sd-server found is the gfx target this runner validates. + """T1.7: the device sd-server found is the gfx target this runner validates. `gfx_target` comes from the workflow's Tier 1 leg, so adding a runner with another GPU is one more matrix leg, not a change here. Only when this passes @@ -678,7 +690,7 @@ def check_gpu_target(server, gfx_target): def check_image(state): - """T1.4: the image is a real picture of the requested size. + """T1.3: the image is a real picture of the requested size. A PNG of exactly WIDTHxHEIGHT that decodes completely, and is not flat: a GPU kernel that produces NaNs typically yields an all-black or uniform image @@ -705,7 +717,7 @@ def check_image(state): def check_determinism(base, state): - """T1.5: the same request with the same seed gives identical bytes. + """T1.4: the same request with the same seed gives identical bytes. Non-gating, and worth being honest about why. On a GPU thousands of threads add numbers in whatever order they happen to finish, so results can differ @@ -775,10 +787,10 @@ def check_loaded_from_expected(server, root, rocm_dirs): CHECKS_AFTER_BOOT = [ ("T1.2", "GPU really did the work", True), - ("T1.3", "GPU target detected", True), - ("T1.4", "image well-formed", True), - ("T1.5", "deterministic output", False), + ("T1.3", "image well-formed", True), + ("T1.4", "deterministic output", False), ("T1.6", "ROCm loaded from the expected places", True), + ("T1.7", "GPU target detected", True), ] @@ -894,22 +906,22 @@ def skip_rest(reason): details={"port": args.port, "args": SERVER_ARGS, "model": MODEL_FILE}) try: state["png"], state["seconds"] = generate(base) - except Exception as exc: # noqa: BLE001 - recorded by T1.4 + except Exception as exc: # noqa: BLE001 - recorded by T1.3 state["error"] = f"image request failed: {type(exc).__name__}: {exc}" if not server.running(): state = {"error": f"{server.exit_text()} while generating the image"} tier.run("T1.2", "GPU really did the work", lambda: check_gpu_did_work(server)) - tier.run("T1.3", "GPU target detected", + tier.run("T1.7", "GPU target detected", lambda: check_gpu_target(server, args.gfx_target)) - tier.run("T1.4", "image well-formed", lambda: check_image(state)) - tier.run("T1.5", "deterministic output", + tier.run("T1.3", "image well-formed", lambda: check_image(state)) + tier.run("T1.4", "deterministic output", lambda: check_determinism(base, state), gating=False) tier.run("T1.6", "ROCm loaded from the expected places", lambda: check_loaded_from_expected(server, root, rocm_dirs)) finally: server.stop() - meta["hardware_validated"] = tier.status_of("T1.3") == report.STATUS_PASS + meta["hardware_validated"] = tier.status_of("T1.7") == report.STATUS_PASS tier.write(args.output) tier.print_summary() print(f"\nWrote {args.output}") diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7951189a9..a2e4cf6f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,8 @@ jobs: tag: ${{ steps.resolve.outputs.tag }} short: ${{ steps.resolve.outputs.short }} skip: ${{ steps.published.outputs.complete == 'true' }} + # Every ROCm version is already in the release: build and qualify no ROCm archive. + rocm_skip: ${{ steps.published.outputs.rocm_complete == 'true' }} steps: - name: Clone uses: actions/checkout@v6 @@ -63,24 +65,37 @@ jobs: echo "tag=$tag" >> "$GITHUB_OUTPUT" echo "Pinning this run to upstream $sha ($tag)" - # The tag only changes when upstream or this fork changes, so a nightly on unchanged - # sources would rebuild a release that already exists. Skip it when that release - # already holds every family; rebuild to fill the gaps when it does not. + # The tag only changes when upstream or this fork changes, so a release run on unchanged sources would rebuild + # a release that already exists. Skip it when that release already holds every family, its notes and + # a checksums.txt that matches its archives; rebuild to fill the gaps when it does not. + # A run that does not release (a PR, or a manual run without create_release) always builds. - name: Check whether this tag is already fully published id: published - if: github.event_name == 'schedule' + if: github.event_name == 'schedule' || github.event.inputs.create_release == 'true' env: GH_TOKEN: ${{ github.token }} TAG: ${{ steps.resolve.outputs.tag }} SHORT: ${{ steps.resolve.outputs.short }} run: | - if gh release view "$TAG" -R "${{ github.repository }}" --json assets \ - --jq '.assets[] | select(.state == "uploaded") | .name' > assets.txt; then + if gh release view "$TAG" -R "${{ github.repository }}" --json assets > assets.json && + gh release view "$TAG" -R "${{ github.repository }}" --json body --jq '.body' > body.md; then + # Retried, so one failed download does not rebuild every family; a checksums.txt that + # is absent or still cannot be downloaded is a gap check-release reports. + if jq -e '.assets[] | select(.name == "checksums.txt" and .state == "uploaded")' assets.json > /dev/null; then + for i in 1 2 3; do + gh release download "$TAG" -R "${{ github.repository }}" -p checksums.txt -O checksums.txt --clobber && break + rm -f checksums.txt + if [ "$i" -lt 3 ]; then sleep $((10 * i)); fi + done + [ -f checksums.txt ] || echo "::warning::Could not download checksums.txt from $TAG." + fi python3 lemonade-ci/.github/qualify-rocm/release_assets.py check-release \ - --branch "$BRANCH_NAME" --short "$SHORT" --rocm-versions "$ROCM_VERSIONS" --names-file assets.txt + --branch "$BRANCH_NAME" --short "$SHORT" --rocm-versions "$ROCM_VERSIONS" --assets-json assets.json \ + --body-file body.md --checksums-file checksums.txt else echo "No complete release $TAG yet; building it." echo "complete=false" >> "$GITHUB_OUTPUT" + echo "rocm_complete=false" >> "$GITHUB_OUTPUT" fi ubuntu-latest-cmake: @@ -683,7 +698,7 @@ jobs: windows-latest-rocm: needs: resolve-upstream - if: needs.resolve-upstream.outputs.skip != 'true' + if: needs.resolve-upstream.outputs.rocm_skip != 'true' runs-on: windows-2022 strategy: @@ -823,7 +838,7 @@ jobs: 7z a sd-${{ env.BRANCH_NAME }}-${{ needs.resolve-upstream.outputs.short }}-bin-win-rocm-${{ matrix.ROCM_VERSION }}-x64.zip .\build\bin\* # The qualify jobs audit the archive against this job's own gpu_targets, and the - # release job proves with the SHA-256 that it uploads the archive they tested (T0.12). + # release job proves with the SHA-256 that it uploads the archive they tested (T0.11). - name: Record qualification metadata run: | $archive = 'sd-${{ env.BRANCH_NAME }}-${{ needs.resolve-upstream.outputs.short }}-bin-win-rocm-${{ matrix.ROCM_VERSION }}-x64.zip' @@ -860,7 +875,7 @@ jobs: ubuntu-latest-rocm: needs: resolve-upstream - if: needs.resolve-upstream.outputs.skip != 'true' + if: needs.resolve-upstream.outputs.rocm_skip != 'true' runs-on: ubuntu-24.04 env: @@ -1134,11 +1149,12 @@ jobs: # ROCm qualification. Each ROCm archive is checked as built. # Tier 0 statically, Tier 1 by generating an image on a Strix Halo (gfx1151) GPU. # The release job withholds a ROCm version unless both of its archives pass both tiers. + # It also waits for both, so an offline GPU runner delays the whole release. # See .github/qualify-rocm/README.md. # --------------------------------------------------------------------------- qualify-tier0: # !cancelled(): a failed build leaves nothing to audit, and the release job reports that gap. - if: ${{ !cancelled() && needs.resolve-upstream.result == 'success' && needs.resolve-upstream.outputs.skip != 'true' }} + if: ${{ !cancelled() && needs.resolve-upstream.result == 'success' && needs.resolve-upstream.outputs.rocm_skip != 'true' }} needs: - resolve-upstream - ubuntu-latest-rocm @@ -1147,7 +1163,7 @@ jobs: strategy: fail-fast: false matrix: - # Each leg runs on the archive's own OS: T0.8-T0.11 run sd-server and install a user's ROCm. + # Each leg runs on the archive's own OS: T0.8, T0.9, T0.12 and T0.14 run sd-server and install a user's ROCm. os: [ubuntu, win] rocm: ["10.0", "10.1", "10.2"] include: @@ -1189,7 +1205,7 @@ jobs: name: ${{ steps.archive.outputs.name }} path: ./artifact - # T0.8-T0.11 need the ROCm a user installs; this must not fail quietly or they would only skip. + # T0.8, T0.9, T0.12 and T0.14 need the ROCm a user installs; this must not fail quietly or they would only skip. - name: Install a user-style ROCm runtime run: >- python .github/qualify-rocm/install_rocm.py @@ -1214,9 +1230,9 @@ jobs: if-no-files-found: warn qualify-tier1: - # Runs on every event except a pull request from a fork, which must not reach the self-hosted GPU runners. + # Runs on every run that builds ROCm except a pull request from a fork, which must not reach the self-hosted GPU runners. if: >- - ${{ !cancelled() && needs.resolve-upstream.result == 'success' && needs.resolve-upstream.outputs.skip != 'true' && + ${{ !cancelled() && needs.resolve-upstream.result == 'success' && needs.resolve-upstream.outputs.rocm_skip != 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} needs: @@ -1231,22 +1247,22 @@ jobs: include: - os: ubuntu rocm: "10.0" - runner: [self-hosted, strix-halo, xsj-dispatch, Linux] + runner: [self-hosted, strix-halo, devlab-dispatch, Linux] - os: ubuntu rocm: "10.1" - runner: [self-hosted, strix-halo, xsj-dispatch, Linux] + runner: [self-hosted, strix-halo, devlab-dispatch, Linux] - os: ubuntu rocm: "10.2" - runner: [self-hosted, strix-halo, xsj-dispatch, Linux] + runner: [self-hosted, strix-halo, devlab-dispatch, Linux] - os: win rocm: "10.0" - runner: [self-hosted, strix-halo, xsj-dispatch, Windows] + runner: [self-hosted, strix-halo, devlab-dispatch, Windows] - os: win rocm: "10.1" - runner: [self-hosted, strix-halo, xsj-dispatch, Windows] + runner: [self-hosted, strix-halo, devlab-dispatch, Windows] - os: win rocm: "10.2" - runner: [self-hosted, strix-halo, xsj-dispatch, Windows] + runner: [self-hosted, strix-halo, devlab-dispatch, Windows] runs-on: ${{ matrix.runner }} @@ -1353,6 +1369,8 @@ jobs: # Two runs on the same tag (a manual release overlapping the nightly) would # otherwise upload into one release at once and could pair one run's # qualification record with the other run's archive. The second one waits. + # GitHub keeps only one waiting, so a third cancels the waiting one; + # publish-qualification still publishes that run's rows. concurrency: group: release-${{ needs.resolve-upstream.outputs.tag }} cancel-in-progress: false @@ -1373,14 +1391,18 @@ jobs: - qualify-tier0 - qualify-tier1 - # For publish-qualification: the ROCm archives T0.12 ran on, and the ones this run uploaded. + # For publish-qualification: the ROCm archives T0.11 ran on, the ones this run uploaded, + # and the ones an earlier run had already put in the release. outputs: final_checked: ${{ steps.final.outputs.archives }} published_rocm: ${{ steps.upload_release.outputs.rocm }} + preexisting_rocm: ${{ steps.upload_release.outputs.preexisting_rocm }} env: TAG: ${{ needs.resolve-upstream.outputs.tag }} SHORT: ${{ needs.resolve-upstream.outputs.short }} + # Every ROCm version is already in the release, so this run built no ROCm archive. + ROCM_SKIP: ${{ needs.resolve-upstream.outputs.rocm_skip }} steps: - name: Clone @@ -1406,14 +1428,18 @@ jobs: merge-multiple: true # Each backend family ships as a complete set or not at all; each ROCm version is - # its own family, so a gap in one version never withholds another. + # its own family, so a gap in one version never withholds another. A gap drops that + # family from this run's upload; the job still fails at the end if the release lacks it. - name: Check release artifacts id: check_artifacts - run: >- - python3 lemonade-ci/.github/qualify-rocm/release_assets.py check-dir - --dir artifact --branch "$BRANCH_NAME" --short "$SHORT" --rocm-versions "$ROCM_VERSIONS" + run: | + versions="$ROCM_VERSIONS" + if [ "$ROCM_SKIP" = "true" ]; then versions=""; fi + python3 lemonade-ci/.github/qualify-rocm/release_assets.py check-dir \ + --dir artifact --branch "$BRANCH_NAME" --short "$SHORT" --rocm-versions "$versions" - name: Download qualification fragments + if: env.ROCM_SKIP != 'true' uses: actions/download-artifact@v4 with: pattern: qualify-fragments-* @@ -1421,15 +1447,17 @@ jobs: merge-multiple: true - name: Download qualification metadata + if: env.ROCM_SKIP != 'true' uses: actions/download-artifact@v4 with: pattern: qualify-meta-* path: ./meta merge-multiple: true - # T0.12: the exact files about to be uploaded are the ones Tier 0 and Tier 1 tested. + # T0.11: the exact files about to be uploaded are the ones Tier 0 and Tier 1 tested. - name: Final-archive checks id: final + if: env.ROCM_SKIP != 'true' run: | shopt -s nullglob mkdir -p fragments @@ -1444,13 +1472,13 @@ jobs: python3 lemonade-ci/.github/qualify-rocm/check_final.py \ --archive "$archive" --meta "meta/qualify-meta-$os-rocm-$ver.json" \ --output "fragments/tier0-final-$os-rocm-$ver.json" \ - || echo "::error::check_final.py crashed on $base, so T0.12 will show as missing" + || echo "::error::check_final.py crashed on $base, so T0.11 will show as missing" done echo "archives=$checked" >> "$GITHUB_OUTPUT" - # So publish-qualification can still see T0.12 if this job stops before writing records. + # So publish-qualification can still see T0.11 if this job stops before writing records. - name: Upload final-archive reports - if: ${{ !cancelled() }} + if: ${{ !cancelled() && env.ROCM_SKIP != 'true' }} continue-on-error: true uses: actions/upload-artifact@v4 with: @@ -1460,6 +1488,7 @@ jobs: - name: Qualify ROCm release artifacts id: qualify + if: env.ROCM_SKIP != 'true' continue-on-error: true run: | mkdir -p qualification @@ -1475,7 +1504,7 @@ jobs: # Uploaded straight away so a later failure in this job cannot keep them out of the feed. - name: Upload qualification records - if: always() + if: ${{ always() && env.ROCM_SKIP != 'true' }} uses: actions/upload-artifact@v4 with: name: qualification-records @@ -1484,6 +1513,7 @@ jobs: - name: Drop unqualified ROCm versions id: rocm_gate + if: env.ROCM_SKIP != 'true' env: PROMOTE: ${{ steps.qualify.outputs.promote_rocm }} BLOCKED: ${{ steps.qualify.outputs.blocked_rocm_versions }} @@ -1504,7 +1534,7 @@ jobs: for archive in "artifact/sd-${BRANCH_NAME}-${SHORT}-bin-win-rocm-${version}.0-x64.zip" \ "artifact/sd-${BRANCH_NAME}-${SHORT}-bin-Linux-"*"-rocm-${version}.0.zip"; do [ -f "$archive" ] || continue - echo "::warning::ROCm ${version} did not qualify; withholding $(basename "$archive")." + echo "::warning::ROCm ${version} did not qualify; not uploading $(basename "$archive")." rm -fv "$archive" dropped=$((dropped + 1)) done @@ -1513,6 +1543,7 @@ jobs: echo "blocked=$blocked" >> "$GITHUB_OUTPUT" - name: Stage qualification records as release assets + if: env.ROCM_SKIP != 'true' run: | shopt -s nullglob for record in qualification/qualification-sd-*.json; do @@ -1557,8 +1588,10 @@ jobs: core.setOutput('id', release.id); # Assets already in the release are never replaced: Lemonade may already pin them, and - # they were qualified when they were uploaded. A record is uploaded with its archive. - # checksums.txt is rebuilt from GitHub's digests, so it always matches what is published. + # they were qualified when they were uploaded. A record goes up right before its archive, + # and that is the only time a record already in the release is replaced: it said why the + # archive was withheld. checksums.txt is rebuilt from GitHub's digests, so it always matches + # what is published, and replaced only when it changes. - name: Upload release id: upload_release uses: actions/github-script@v8 @@ -1568,6 +1601,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const fs = require('fs'); + const crypto = require('crypto'); const { owner, repo } = context.repo; const release_id = Number(process.env.RELEASE_ID); const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); @@ -1585,7 +1619,8 @@ jobs: } } } - const listAssets = () => github.paginate(github.rest.repos.listReleaseAssets, { owner, repo, release_id }); + const listAssets = () => withRetry('list assets', () => + github.paginate(github.rest.repos.listReleaseAssets, { owner, repo, release_id })); async function upload(name, data) { await withRetry(`upload ${name}`, () => github.rest.repos.uploadReleaseAsset({ owner, repo, release_id, name, data }) @@ -1603,65 +1638,110 @@ jobs: await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id }); } - const published = new Map(); - for (const a of await listAssets()) { - if (a.state === 'uploaded') published.set(a.name, a); - else await remove(a, `incomplete (${a.state})`); - } + try { + const published = new Map(); + for (const a of await listAssets()) { + if (a.state === 'uploaded') published.set(a.name, a); + else await remove(a, `incomplete (${a.state})`); + } + // The feed marks this run's rebuild of these as already published by an earlier run. + core.setOutput('preexisting_rocm', [...published.keys()].filter((n) => /-rocm-.*\.zip$/.test(n)).join(' ')); + + const isArchive = (f) => f.endsWith('.zip') || f.endsWith('.tar.xz'); + const stem = (f) => f.replace(/\.(zip|tar\.xz)$/, ''); + const files = fs.readdirSync('./artifact'); + const archives = files.filter(isArchive); + // A record goes up before its archive, so an archive is never published without one. + const records = files.filter((f) => /^qualification-sd-.*\.json$/.test(f)); + const recordFor = (archive) => `qualification-${stem(archive)}.json`; + async function uploadRecord(record) { + if (published.has(record)) await remove(published.get(record), 'superseded'); + await upload(record, fs.readFileSync(`./artifact/${record}`)); + } + async function saysWithheld(asset) { + try { + const { data } = await withRetry(`download ${asset.name}`, () => github.rest.repos.getReleaseAsset({ + owner, repo, asset_id: asset.id, headers: { accept: 'application/octet-stream' }, + })); + const record = data && typeof data === 'object' && !(data instanceof ArrayBuffer) && !ArrayBuffer.isView(data) + ? data : JSON.parse(Buffer.from(data).toString('utf8')); + return !record.promoted || record.promotion?.version_blocked_by?.length > 0; + } catch (e) { + core.warning(`could not read ${asset.name}, so it is kept: ${e.message}`); + return true; + } + } + const uploaded = []; + for (const file of archives) { + if (published.has(file)) { + core.info(`keeping ${file} (already published)`); + continue; + } + if (records.includes(recordFor(file))) await uploadRecord(recordFor(file)); + await upload(file, fs.readFileSync(`./artifact/${file}`)); + uploaded.push(file); + // Written after every upload, so a later failure still reports what did ship. + core.setOutput('rocm', uploaded.filter((f) => /-rocm-/.test(f)).join(' ')); + } + // A withheld archive's record says why it was withheld. One already in the release is kept, + // so a later run on the same tag does not change the digest of an asset Lemonade may pin. + // One that says its archive qualified was left by an archive upload that failed, so it is replaced. + const shipped = new Set([...published.keys(), ...uploaded].filter(isArchive).map(stem)); + for (const record of records) { + if (shipped.has(record.replace(/^qualification-/, '').replace(/\.json$/, ''))) continue; + if (published.has(record) && await saysWithheld(published.get(record))) { + core.info(`keeping ${record} (already published)`); + } else { + await uploadRecord(record); + } + } - const files = fs.readdirSync('./artifact'); - const archives = files.filter((f) => f.endsWith('.zip') || f.endsWith('.tar.xz')); - // A record goes up before its archive, so an archive is never published without one. - const records = files.filter((f) => f.startsWith('qualification-') && f.endsWith('.json')); - const recordFor = (archive) => `qualification-${archive.replace(/\.(zip|tar\.xz)$/, '')}.json`; - async function uploadRecord(record) { - if (published.has(record)) await remove(published.get(record), 'superseded'); - await upload(record, fs.readFileSync(`./artifact/${record}`)); - } - const uploaded = []; - for (const file of archives) { - if (published.has(file)) { - core.info(`keeping ${file} (already published)`); - continue; + let assets = []; + for (let i = 1; i <= 5; i++) { + assets = (await listAssets()).filter((a) => a.state === 'uploaded'); + if (assets.every((a) => !isArchive(a.name) || a.digest?.startsWith('sha256:'))) break; + await sleep(5000 * i); + } + const sums = assets.filter((a) => isArchive(a.name)) + .sort((a, b) => a.name.localeCompare(b.name)) + .map((a) => { + if (!a.digest?.startsWith('sha256:')) throw new Error(`no SHA-256 digest for ${a.name}`); + return `${a.digest.slice('sha256:'.length)} ${a.name}`; + }); + const content = Buffer.from(sums.join('\n') + '\n'); + const digest = `sha256:${crypto.createHash('sha256').update(content).digest('hex')}`; + const old = assets.find((a) => a.name === 'checksums.txt'); + if (old?.digest === digest) { + core.info('checksums.txt already lists every archive'); + } else { + if (old) await remove(old, 'superseded'); + await upload('checksums.txt', content); + } + core.info(`Done: ${uploaded.length} archive(s) uploaded, ${archives.length - uploaded.length} already published.`); + } finally { + // The notes are written from this list, even after a failed upload. + try { + const names = (await listAssets()).filter((a) => a.state === 'uploaded').map((a) => a.name).sort(); + fs.writeFileSync('release-assets.txt', names.join('\n') + '\n'); + } catch (e) { + core.warning(`could not list the release's assets for the notes: ${e.message}`); } - if (records.includes(recordFor(file))) await uploadRecord(recordFor(file)); - await upload(file, fs.readFileSync(`./artifact/${file}`)); - uploaded.push(file); - // Written after every upload, so a later failure still reports what did ship. - core.setOutput('rocm', uploaded.filter((f) => /-rocm-/.test(f)).join(' ')); - } - // Records of withheld archives say why they were withheld. - for (const record of records) { - const archive = record.replace(/^qualification-/, '').replace(/\.json$/, '.zip'); - if (!published.has(archive) && !uploaded.includes(archive)) await uploadRecord(record); } - const assets = (await listAssets()).filter((a) => a.state === 'uploaded'); - const sums = assets.filter((a) => a.name.endsWith('.zip') || a.name.endsWith('.tar.xz')) - .sort((a, b) => a.name.localeCompare(b.name)) - .map((a) => { - if (!a.digest?.startsWith('sha256:')) throw new Error(`no SHA-256 digest for ${a.name}`); - return `${a.digest.slice('sha256:'.length)} ${a.name}`; - }); - const old = assets.find((a) => a.name === 'checksums.txt'); - if (old) await remove(old, 'superseded'); - await upload('checksums.txt', Buffer.from(sums.join('\n') + '\n')); - - const names = assets.map((a) => a.name).filter((n) => n !== 'checksums.txt'); - fs.writeFileSync('release-assets.txt', [...names, 'checksums.txt'].join('\n') + '\n'); - core.setOutput('rocm', uploaded.filter((f) => /-rocm-/.test(f)).join(' ')); - core.info(`Done: ${uploaded.length} archive(s) uploaded, ${archives.length - uploaded.length} already published.`); - + # Also after a failed upload, so the notes always match what the release holds. - name: Write release notes + id: notes + if: ${{ !cancelled() && hashFiles('release-assets.txt') != '' }} env: RELEASE_SUMMARY: ${{ steps.release_summary.outputs.value }} run: >- python3 lemonade-ci/.github/qualify-rocm/release_notes.py --tag "$TAG" --repo "${{ github.repository }}" --assets-file release-assets.txt --rocm-versions "$ROCM_VERSIONS" - --summary "$RELEASE_SUMMARY" --output release-notes.md + --summary="$RELEASE_SUMMARY" --output release-notes.md - name: Update release notes + if: ${{ !cancelled() && steps.notes.outcome == 'success' }} uses: actions/github-script@v8 env: RELEASE_ID: ${{ steps.release.outputs.id }} @@ -1670,32 +1750,87 @@ jobs: script: | const fs = require('fs'); const { owner, repo } = context.repo; - await github.rest.repos.updateRelease({ - owner, repo, release_id: Number(process.env.RELEASE_ID), - name: process.env.TAG, body: fs.readFileSync('release-notes.md', 'utf8'), - }); + const body = fs.readFileSync('release-notes.md', 'utf8'); + // Retried like the uploads: the next run only rewrites notes that are missing, not stale ones. + for (let i = 1; ; i++) { + try { + await github.rest.repos.updateRelease({ + owner, repo, release_id: Number(process.env.RELEASE_ID), name: process.env.TAG, body, + }); + break; + } catch (e) { + const transient = !e.status || e.status >= 500 || e.status === 429; + if (i >= 5 || !transient) throw e; + const delay = Math.min(30000, 1000 * 2 ** (i - 1)); + core.warning(`updating the release notes failed (attempt ${i}/5): ${e.message}. Retrying in ${delay}ms`); + await new Promise((r) => setTimeout(r, delay)); + } + } + + # A family this run dropped can still be in the release from an earlier run, so the two + # checks below fail only for what the release really lacks. + - name: Check what the release holds + id: holds + if: ${{ !cancelled() && hashFiles('release-assets.txt') != '' }} + run: >- + python3 lemonade-ci/.github/qualify-rocm/release_assets.py check-release + --branch "$BRANCH_NAME" --short "$SHORT" --rocm-versions "$ROCM_VERSIONS" + --names-file release-assets.txt - name: Fail if any artifacts were missing if: steps.check_artifacts.outputs.missing != '0' + env: + DROPPED: ${{ steps.check_artifacts.outputs.dropped }} + SUMMARY: ${{ steps.check_artifacts.outputs.summary }} + GAPS: ${{ steps.holds.outputs.gaps }} + HOLDS: ${{ steps.holds.outcome }} run: | - echo "::error::${{ steps.check_artifacts.outputs.missing }} artifact(s) were missing (${{ steps.check_artifacts.outputs.summary }}) — the incomplete families were dropped from this release; other families were still published. See the 'Check release artifacts' step for the full per-file list." - exit 1 + absent="" + for family in $DROPPED; do + if [ "$HOLDS" != "success" ] || [[ " $GAPS " == *" $family "* ]]; then + absent="${absent:+$absent }$family" + else + echo "::warning::This run's $family build was incomplete; the release keeps the $family archives an earlier run published." + fi + done + if [ -n "$absent" ]; then + echo "::error::Not in this release: $absent ($SUMMARY). Other families were still published. See the 'Check release artifacts' step for the full per-file list." + exit 1 + fi - name: Fail if ROCm qualification did not pass - if: steps.rocm_gate.outputs.dropped != '0' + if: env.ROCM_SKIP != 'true' && steps.rocm_gate.outputs.dropped != '0' + env: + BLOCKED: ${{ steps.rocm_gate.outputs.blocked }} + GAPS: ${{ steps.holds.outputs.gaps }} + HOLDS: ${{ steps.holds.outcome }} run: | - echo "::error::ROCm ${{ steps.rocm_gate.outputs.blocked }} did not qualify — ${{ steps.rocm_gate.outputs.dropped }} archive(s) were withheld. Every other ROCm version and backend was published normally. The attached qualification-*.json records list each failing check." - exit 1 + absent="" + for version in $BLOCKED; do + if [ "$HOLDS" != "success" ] || [[ " $GAPS " == *" rocm-$version "* ]]; then + absent="${absent:+$absent }$version" + else + echo "::warning::ROCm $version did not qualify in this run; the release keeps the ROCm $version archives an earlier run published." + fi + done + if [ -n "$absent" ]; then + echo "::error::ROCm $absent did not qualify, so it is not in this release. Every other ROCm version and every other backend was published normally. The qualification-records artifact lists each failing check." + exit 1 + fi # Publishes every run's ROCm qualification records, passing or failing, to the # qualification-data branch the ROCm readiness dashboard reads (format: .github/qualify-rocm/FEED.md). - # A nightly skipped because its release was already complete records only that it - # checked and found nothing new (index.json "last_check"). The branch is created on the first publish. + # A release run that built no ROCm archive, because every ROCm version was already in the + # release, records only that it checked and found nothing new (index.json "last_check"). + # The branch is created on the first publish. + # A release job cancelled by a newer run on the same tag (see its concurrency) shipped + # nothing, but its rows are still published; a cancelled run publishes nothing. publish-qualification: if: >- ${{ !cancelled() && needs.resolve-upstream.result == 'success' && - (needs.resolve-upstream.outputs.skip == 'true' || - needs.release.result == 'success' || needs.release.result == 'failure') }} + (needs.resolve-upstream.outputs.rocm_skip == 'true' || + needs.release.result == 'success' || needs.release.result == 'failure' || + needs.release.result == 'cancelled') }} needs: - resolve-upstream - release @@ -1713,7 +1848,7 @@ jobs: path: lemonade-ci - name: Download qualification records - if: needs.resolve-upstream.outputs.skip != 'true' + if: needs.resolve-upstream.outputs.rocm_skip != 'true' continue-on-error: true uses: actions/download-artifact@v4 with: @@ -1721,7 +1856,7 @@ jobs: path: ./records - name: Download qualification fragments - if: needs.resolve-upstream.outputs.skip != 'true' + if: needs.resolve-upstream.outputs.rocm_skip != 'true' continue-on-error: true uses: actions/download-artifact@v4 with: @@ -1731,7 +1866,7 @@ jobs: # If the release job stopped before writing records, build them from the tier reports. - name: Collect qualification records - if: needs.resolve-upstream.outputs.skip != 'true' + if: needs.resolve-upstream.outputs.rocm_skip != 'true' env: TAG: ${{ needs.resolve-upstream.outputs.tag }} run: | @@ -1754,7 +1889,7 @@ jobs: --require-final - name: Read build job results - if: needs.resolve-upstream.outputs.skip != 'true' + if: needs.resolve-upstream.outputs.rocm_skip != 'true' env: GH_TOKEN: ${{ github.token }} run: | @@ -1779,7 +1914,8 @@ jobs: UPSTREAM_SHA: ${{ needs.resolve-upstream.outputs.sha }} PUBLISHED_ROCM: ${{ needs.release.outputs.published_rocm }} FINAL_CHECKED: ${{ needs.release.outputs.final_checked }} - UNCHANGED: ${{ needs.resolve-upstream.outputs.skip }} + PREEXISTING_ROCM: ${{ needs.release.outputs.preexisting_rocm }} + UNCHANGED: ${{ needs.resolve-upstream.outputs.rocm_skip }} run: | set -euo pipefail git config --global user.name "github-actions[bot]" @@ -1818,6 +1954,7 @@ jobs: --upstream-sha "$UPSTREAM_SHA" \ --jobs-file jobs.jsonl \ --published-artifacts "$PUBLISHED_ROCM" \ + --already-published "$PREEXISTING_ROCM" \ --final-checked "$FINAL_CHECKED" fi cp lemonade-ci/.github/qualify-rocm/FEED.md data/qualification/SCHEMA.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..c18dd8d83 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/README.md b/README.md index 571a34741..714c22c94 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The builds include code for gfx1010, gfx1011, gfx1012, gfx1030–gfx1036, gfx110 ### 2. Download a build -From the [latest release](https://github.com/lemonade-sdk/stable-diffusion.cpp/releases/latest), pick one ROCm version and download your OS's zip: +On the [Releases](https://github.com/lemonade-sdk/stable-diffusion.cpp/releases) page, open the newest release that lists ROCm downloads. Not every release has them: when a ROCm version does not pass its checks, the release says so under "Not in this release". Pick one ROCm version and download your OS's zip: - Windows: `sd-master--bin-win-rocm--x64.zip` - Linux: `sd-master--bin-Linux-Ubuntu-24.04-x86_64-rocm-.zip` (Ubuntu 24.04 or newer)