Design a GPU Test Pipeline in Jenkins Across Driver Matrices
System DesignModel answerLast updated
Design a Jenkins-based CI system that builds a graphics stack and runs GPU tests across hardware, driver and OS combinations, with flake handling, gating and safe driver rollouts.
Your team maintains a graphics stack: a renderer, driver-facing libraries and a test harness. Many tests need a real GPU. You are asked to design a continuous integration system on Jenkins that builds the stack and runs these GPU tests across a matrix of GPU architecture, driver version and operating system.
Describe your design and cover the following areas:
- Orchestration and pipeline-as-code: how jobs are defined, configured and reused across repositories.
- Parallelization and test sharding: how a large suite gets fast feedback on scarce GPU hardware.
- Artifact management: what gets stored, how it is versioned, and how long it is kept.
- Retry policy: how you tell infrastructure failures apart from genuine test failures.
- Flaky tests: detection, quarantine and the rules for leaving quarantine.
- Notifications and promotion gates: who hears about what, and what must pass before a change is merged or released.
- Driver updates and rollback: how to introduce a new driver version safely and revert it quickly if it causes problems.
State your assumptions about scale (commits per day, matrix size, number of tests, GPU node count, feedback-time targets) and explain how they shape the design. Discuss trade-offs, failure modes, and how you would roll out and validate the system itself.
Hints
Hint 1
Start by estimating sizes: matrix cells multiplied by test count multiplied by average test time gives total GPU-hours, which tells you whether sharding and a reduced pre-merge matrix are required.
Hint 2
Separate concerns: compile once on cheap CPU agents, publish an immutable artifact, and have GPU agents only pull and test. Treat GPU nodes as precisely labeled, health-checked, single-tenant resources.
Hint 3
Classify failures before retrying. Infrastructure faults (lost agent, GPU hang, fetch error) should reschedule the shard on another node and drain the bad one, while test failures should rerun only the failed tests, and every attempt must be recorded.
Hint 4
Treat a driver as a versioned dependency: pin it per node pool in git, canary it on a small pool, compare results against the baseline, and keep the previous node image ready for fast rollback.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify requirements and scale
Functional
- Build the stack on every commit and publish the outputs.
- Run tests over GPU architecture x driver branch x OS.
- Gate merges and releases on the results.
- Manage flaky tests, notify owners, and roll drivers forward and back safely.
Assumed scale (state it, then adjust)
- About 200 commits per day from roughly 50 engineers.
- 4 architectures x 3 driver branches (production, new-feature, beta) x 2 OSes = 24 cells.
- About 20,000 tests at about 6 s each, so roughly 33 GPU-hours per cell for the full suite. Sharding is mandatory.
- Targets: pre-merge feedback in 30-45 min, full matrix nightly within about 6 h.
- About 150 bare-metal GPU nodes. They are scarce, so utilization matters.
Non-functional: reproducible results (same commit + same driver gives the same outcome), infrastructure failures isolated from product failures, and every node, driver and artifact auditable.
2. Configuration and data model
Jenkinsfile+ shared library (for examplegfxci): teams declare intent, the library implements retries, sharding, health checks and result upload.matrix.yamlin git: supported cells and the pinned driver per node pool.- Test manifest: test ID, owner, tags (
smoke,perf,long), and per-architecture image tolerances. - Results service (REST over Postgres):
test_run(sha, cell, shard, test_id, status, duration, attempt, node, driver, artifact_url)quarantine(test_id, cell_scope, reason, ticket, owner, since, exit_criteria)node(name, arch, driver, image_version, health, last_error)
- Artifact store (Artifactory or S3): build outputs keyed by SHA and digest, plus golden images versioned per architecture and driver family.
3. Architecture
- A highly available Jenkins controller configured through JCasC with pinned plugins, and zero executors on the controller.
- Ephemeral CPU agents (Kubernetes) compile each OS variant once and publish an artifact.
- Bare-metal GPU agent pools labeled precisely (
gpu=ada && driver=550 && os=linux). Pipelines request labels, never node names. - GPU agents never compile. They pull the artifact by digest, which gives "build once, test many".
- A results service and dashboard feed notifications (chat, email, PR status).
4. Pipeline shape
Stages: build (matrix over OS), GPU tests (parallel over cells, each with a shard plan), gate, then a post { always } block for reporting and notification. The shared library chooses the profile: a pre-merge profile for PRs and a full profile for mainline and nightly runs. Set a global timeout and a log-rotation policy.
5. Deep dives
Parallelization and sharding
- Pre-merge does not run all 24 cells. It runs a smoke subset (about 1,500 tests) on a covering set of cells, for example one per architecture plus the production driver on both OSes. Pairwise coverage catches most interaction bugs.
- Shard by duration-based bin packing using p90 durations from the results service so shards finish together. 20k tests over 40 shards is roughly 50 min per cell nightly.
- One test process per GPU. Use Lockable Resources or one executor per GPU. Sharing a GPU makes performance and image results nondeterministic.
- Pre-shard health check: the GPU tooling responds, no recent Xid errors, ECC is clean, and the driver matches the label. A failing node takes itself offline and the shard is rescheduled.
Retry policy
| Failure type | Detection | Action |
|---|---|---|
| Infrastructure (agent lost, GPU hang, fetch error, setup timeout) | Exit codes, kernel log scrape, harness heartbeat | Retry the whole shard on a different node (max 2), drain the bad node, open an infra ticket |
| Test failure | Assertion or image diff | Rerun only the failed tests in isolation, up to 2 times |
| Pass on retry | Status flaky | Non-blocking for known tests; counts as a failure for tests new or modified in the PR |
Retries must never silently turn a failure into a pass. Record every attempt so flake rates are measurable.
Quarantining flaky tests
- Compute a flake score per (test, cell) over a rolling 14-day window from pass-on-retry events and pass/fail flips on the same SHA.
- Above a threshold (say 2%), auto-quarantine scoped to the affected cells and file a ticket to the owner.
- Quarantined tests still run but do not block. This preserves signal and enables automatic exit.
- Exit rule: 50 consecutive clean runs, or a fix lands and passes.
- Guardrails: a 14-day SLA with escalation, a per-team cap (about 1% of the suite), and release gates that list quarantined tests explicitly.
Image-based assertions
Compare against goldens with per-architecture tolerances (PSNR, SSIM or a perceptual metric), not exact equality. Store the actual image, the golden and a diff heatmap as artifacts linked from the failure. Golden updates go through code review.
Artifact management
Artifacts are immutable and content-addressed, with metadata (SHA, compiler, flags). Retention: PR artifacts 7 days, mainline 90 days, promoted releases indefinitely. Logs, dumps and images are compressed and expire sooner than binaries.
Notifications and promotion gates
- PR status checks report pass, fail or flaky with links to artifacts. Failures ping the author; nightly regressions ping the owning team's channel, deduplicated per root cause.
- Gates: pre-merge requires the smoke subset green on the covering cells. Promotion to release requires the full matrix green on production drivers, no unexplained new quarantines, and a perf-regression check within thresholds.
6. Driver updates and rollback
- Driver is pinned config. The version lives in
matrix.yamland in a versioned node image, never installed ad hoc. - Canary pool. Install the new driver on a small pool (5-10% of nodes of one architecture). Run the full suite on it and compare against the baseline pool on the same SHAs.
- Compare, don't just pass. Diff failures, image deltas and performance. New failures that appear only on the canary are driver suspects. Flake rates are checked separately.
- Staged rollout. Expand pool by pool, one architecture at a time, only while metrics stay within thresholds.
- Rollback. Keep the previous node image warm. Reverting is a one-line change to the pin, followed by reimaging (or switching labels) so nodes drain and return in minutes. Because jobs request labels, no pipeline edits are needed.
- Beta drivers live in a dedicated, non-blocking cell so upcoming regressions are seen early without gating merges.
7. Failure modes and trade-offs
- GPU scarcity: prioritize pre-merge over nightly, preempt long jobs, and autoscale only where cloud GPUs are acceptable. Trade-off: cost against latency.
- Controller overload: keep the controller light and move logic into the library. Shard the controller by team if needed.
- Bad node poisoning results: health checks plus auto-drain, and tracking failures per node to spot outliers.
- Golden drift: version goldens per architecture and driver family, or accept tolerance bands.
- Over-quarantine: the cap and SLA keep it from hiding real regressions.
8. Rollout and validation
Run the new CI in shadow mode alongside the existing system, compare verdicts, then make it advisory, and finally make it a required check. Track time to feedback, GPU utilization, infrastructure-failure rate, flake rate and the number of escaped regressions.
Common mistakes
- Running the full matrix on every PR.
- Retrying everything the same way, which hides real bugs.
- Letting quarantine become a permanent graveyard.
- Rolling a driver out everywhere at once with no baseline comparison.
- Addressing nodes by name instead of by label.