[docs] Add RFC0017: Fingerprint-Based CI Artifact Cache #9500
<!-- therock-pr-bot-policy-check -->
✅ All Checks Passed — Ready for Review
| Check | Status | Details |
|---|:---:|---|
| 📝 PR Description | ✅ Pass | — |
| ⛔ Forbidden Files | ✅ Pass | — |
| 🧪 Unit Test | ✅ Pass | PR does not contain code files — Unit Test auto-passed |
| 🔎 pre-commit | ✅ Pass | — |
| 🚫 Draft PR | 🔜 To Be Enabled | — |
| 🚩 Feature Flag | 🔜 To Be Enabled | — |
| 📊 Code Coverage | 🔜 To Be Enabled | — |
| 🤖 therock-pr-bot | ✅ Pass | — |
🎉 All checks passed! This PR is ready for review.
📖 Need help? See the Policy FAQ for details on every check and how to fix failures.
<!-- therock-pr-bot-precommit-failed -->
Pre-commit check failed
⛔ pre-commit failed
Please run locally:
python -m pip install pre-commitpre-commit installpre-commit run --all-files --show-diff-on-failureThis repo uses .pre-commit-config.yaml.
Explicit build variant seems okay to add, but I'm not sure it's strictly necessary if we already have the underlying CMake flags used in the fprint.
Let's be careful here with the details of targets vs target families of how multi-arch CI works.
A build of the math-libs stage with the target family gfx110X-all like https://github.com/ROCm/rockrel/actions/runs/42133689495/job/127624314660 builds for targets gfx1100,gfx1101,gfx1102,gfx1103.
logs: https://therock-nightly-artifacts.s3.amazonaws.com/42133689495-linux/logs/math-libs/gfx110X-all/index.html
Note rocFFT_build.log, hipFFT_build.log, etc.
artifacts: https://therock-nightly-artifacts.s3.amazonaws.com/42133689495-linux/index.html
Note fft_lib_gfx1100.tar.zst, fft_lib_gfx1101.tar.zst, fft_lib_gfx1102.tar.zst, etc.
It could be reasonable to say that "fft_lib_gfx1100.tar.zst and fft_lib_gfx1101.tar.zst built from the same source have the same fprint". Then if someone builds gfx110X-all as a family _or_ gfx1100 on its own they would get the same cache hits:
Scenario 1:
First CI build of gfx110X-all writes gfx1100,gfx1101,gfx1102,gfx1103 artifacts into cache with some fprint
Second CI build of gfx110X-all requests gfx1100,gfx1101,gfx1102,gfx1103 artifacts, cache hits for all
Third CI/local build of gfx1100 requests gfx1100 artifacts and gets cache hits for it
Scenario 2:
First CI build of gfx1100 writes gfx1100 artifacts into cache with some fprint
Second CI build of gfx110X-all requests gfx1100,gfx1101,gfx1102,gfx1103 artifacts, cache hits for only gfx1100, decides to build from source
Third CI/local build of gfx1100 requests gfx1100 artifacts and gets cache hits for it
Note that the cache lookup there is not just "this is the fprint", it's "this is the artifact name I want at this fprint". If we handle artifact caching at the very start of the build, we would need to build that complete list of expected artifacts during CI configure. We could also push caching down into the build itself, so each build action would compute its fprint on demand and check the database for a cache hit prior to building (as ccache/sccache/bazel/etc. function).
Also note that the artifact naming schema refers to target family but that predates multi-arch. All current artifacts produced by CI use a single target (not family) after splitting: https://github.com/ROCm/TheRock/blob/4a0d18306bb5085d7a7482c93dd1bae6ca08339d/build_tools/_therock_utils/artifacts.py#L38-L42
this file is stored in docs/assets/ but this tries to load from docs/rfcs/assets/
See above. I'm not sure if we need this.
There are some fragments of good ideas in here, but I'm not following each individual item fully. Could you expand this out?
This plan could use more sequencing and risk analysis. Start small - see https://github.com/ROCm/TheRock/pull/2432 where fprints were first added for example:
This will be used in CI in combination with a special bootstrap script for certain stages to cache entire artifacts in the remote cache for presubmits. This will be enabled first for base artifacts like the compiler and certain base libraries that change infrequently but are expensive to build and should effectively reduce them to no-ops. We'll evaluate which stages this is suitable for carefully: the further we go in the system the more variable the build system and therefore the higher the risk of accidental cache poisoning, so the first target here is the compiler, which is quite self contained and well managed.
The outline here, together with the task outline on https://github.com/ROCm/TheRock/issues/8651 seems reasonable to me to proceed. Let's proceed milestone by milestone and not try to boil the ocean too much here. First priority is cache hits for the compiler and other nodes near the start of the build graph, then we can expand out from there.
Please update the RFC number to 17 now that https://github.com/ROCm/TheRock/tree/main/docs/rfcs already includes a different 16.
Run pre-commit (mdformat) to format this file:
https://github.com/ROCm/TheRock/blob/main/CONTRIBUTING.md#pre-commit-checks
https://github.com/ROCm/TheRock/actions/runs/44116894950/job/134157327416?pr=9500
I'd like for the fprint computation discussion to be either part of this RFC or the tracking issues, not a separate RFC.
I wouldn't frame this as "outgrows manual maintenance". The checked in file is not going to be viable for anything but early proofs of concept and prototypes.
We _could_ use https://github.com/ROCm/Quartz (or a similar repository) as our "database" but we'd be writing a large volume of commits there (Quartz has 60k commits already).
This really calls for a server-side database that is written to as artifacts are uploaded and can also be regenerated from a cold start by either backfilling from github run history or listing files across the artifact S3 buckets directly. The static checked in JSON lets us experiment and test while we're still setting up the server-side component.
ditto here - fprint stability/robustness should go in this RFC or issues, not its own separate RFC
@erman-gurses
Release builds will not use artifact caches. That's not a per-invocation "kill switch", it's a standard mode that is expected to run regularly.
This does not make sense. What this RFC initially proposes affects only the CI system directly, then there is no on _or_ off mode for local developers just using the build system to use.
What we should provide is
1. Scripts like https://github.com/ROCm/TheRock/blob/main/build_tools/find_latest_artifacts.py that can find artifacts that are compatible with the current source using the shared database, as well as scripts to bootstrap the build using those artifacts, such as https://github.com/ROCm/TheRock/blob/main/build_tools/buildctl.py
2. Documentation for those scripts
If we were using a build system like Bazel with remote caching built in (or even ccache/sccache with our existing cmake builds) then that would be different - there would be the option to naturally opt-in/out to remote cache use with a build configuration or toolchain file.
I don't think we need to design "read-bypass" or "revoke a manifest" at this point. Let's start simple. Could leave those as future ideas.
This overlaps with the "Build from source (THEROCK_CACHE=off)" point above.
I don't think we need/want these fields:
trust: only write trusted entries to the cache
validation: irrelevant. The build cache does not care whether tests ran or passed. It's just "for this source, here is what the build produced"
Same here, unnecessary complexity.
Only trusted runs write to the cache.
"build passed" is irrelevant.
Thanks, this is improving.
I think we should restructure this to make it easier to digest though. In particular I see three main components that are worth calling out directly as section headings
1. The build system produces fprints for artifacts. If the fprint is the same, artifacts are expected to be equivalent (ideally bit identical).
* Here we can list open areas for improvement - support both generic artifacts (already works) and device-specific artifacts (not yet implemented), make more artifacts reproducible (link the llvm changes so far)
2. The CI system, under certain conditions, reads and writes from/to a remote cache for fprint cache. Trusted runs can write to the cache, non-release runs can read from the cache.
3. The remote cache database provides efficient lookup of cache entries.
Right now the document leads with "cache key design" and "cache value (manifest)" when those are implementation details between 2 and 3. Then other sections like "Required changes" are lacking qualification/detail.
Can you guys rewrite sections of this RFC to better represent the overall architecture, putting implementation decisions under appropriate sections within that?
<!-- therock-pr-bot-fix-policies -->
🎉 All checks passed! This PR is ready for review.
Keeping them as issues is better - I consolidated anything regarding fingerprint stability under this issue: https://github.com/ROCm/TheRock/issues/9525.
I opened this one just for communication for the POC regarding fingerprint stability : https://github.com/ROCm/TheRock/pull/9732 - closed it
Also updated some of the 16s -> 17s in the PR description
Anything related to fingerprint stability - we can refer this issue: https://github.com/ROCm/TheRock/issues/9525
Maybe overstated (~3 s )- we still have download and extraction time.
By source_fingerprint, do you mean THEROCK_FPRINT?
_only trusted runs (push/scheduled on a protected branch) write to the cache_ - Maybe we can mention how is this enforced?
Please see my comments, I will do one more pass.
I consolidated anything regarding fingerprint stability under this issue: https://github.com/ROCm/TheRock/issues/9525
Worked on these updates below:
1. Restructured around three components: the build system (fingerprints), CI (read/write policy, consumer and producer flows) and the remote cache database.
2. Rewrote the Problem to describe how reuse works today (baseline runs, stage granularity, API cost, release branches disabled), and moved the AMD LLVM slice out of the design sections into the Implementation Plan.
3. The first slice (AMD LLVM) moved out of the design sections and into an incremental Implementation Plan. The plan expands outward to ROCm Systems and Libraries, with one enablement checklist and retiring baseline reuse as the last step.
4. Reorganized the plan into one enablement checklist plus an 8-milestone table, from AMD LLVM outward to ROCm Systems and Libraries, ending with retiring baseline reuse.
5. Made the test scenarios concrete (rocFFT, runtime, HSA headers, TheRock PR) and cut evidence and open-decision text to a short list.
CC: @ammallya
the consumer should assert the restored artifact's fprint matches the producer's before trusting it, so config drift becomes a clean miss rather than a silent bad hit.
I think it might be helpful to define the compatibility scope and rules of reuse in this doc
We should pin down whether target goes into the fingerprint or stays a separate lookup-key field
can we also update the demonstration RFC0017-cache-flow.svg based on the remote database?
can we also update the demonstration RFC0017-cache-flow.svg based on the remote database.
Will do
Great, this is looking good now. Thanks for the edits.
Please fix pre-commit (https://github.com/ROCm/TheRock/actions/runs/45514042521/job/138868758847?pr=9500) and let me know when you are both happy with the state of this RFC @erman-gurses and @ammallya so I can merge it.
Or maybe @amd-shiraz could review too?
We don't necessarily need the remaining product manager team review for this eng RFC (implementation detail of the CI system, not user-facing).
Please fix pre-commit (https://github.com/ROCm/TheRock/actions/runs/45514042521/job/138868758847?pr=9500) and let me know when you are both happy with the state of this RFC @erman-gurses and @ammallya so I can merge it.
> Or maybe @amd-shiraz could review too?
> We don't necessarily need the remaining product manager team review for this eng RFC (implementation detail of the CI system, not user-facing).
Updated items below:
1. Fix pre-commit
2. Add CI reuse decision step
@ammallya , I think only remaining work is to update RFC0017-cache-flow.svg flow chart that shows the remote database.
@amd-shiraz can you review this section of the design? See also https://github.com/ROCm/TheRock/blob/main/docs/development/s3_buckets.md#authentication
@amd-shiraz another section to review here for the remote cache database aspect
LGTM - After @amd-shiraz's review and approval, we can merge it.
ScottTodd
ammallya
Motivation
Adds RFC0017, proposing a fingerprint-based CI artifact cache to replace the current "baseline run" stage-reuse mechanism.
Reuse today selects a baseline workflow run by commit ancestry + S3 archive-filename presence + job health. It is O(N) over workflow runs, costs many API calls, cannot express rocm-libraries → rocm-libraries dependencies or arbitrary build-graph subsets, and is fragile on release branches. This RFC instead keys reuse on the
THEROCK_FPRINTthe build already computes.GitHub issue: https://github.com/ROCm/TheRock/issues/8651 (parent #3399)
Technical Details
docs/rfcs/RFC0017-Fingerprint-Based-Artifact-Cache.mddocs/rfcs/assets/RFC0017-cache-flow.svg(plan/restore/publish flow diagram)The RFC specifies: the cache key (
e{EPOCH}:{variant}:{fingerprint}) and its composition, incl. proposed additions (output identity /target_family, container digest, compiler id); the manifest cache value and the trust / validation / publication states with a read policy; the plan → restore → publish flows; and storage (S3 pointers + the team's ClickHouse index; SQLite for local builds). It composes with but stays independent of RFC0013 (test selection) and RFC0008 (Kpack split packaging).Test Plan
assets/RFC0017-cache-flow.svgdisplay and all relative links resolve.Test Result
Submission Checklist