KatInterview

Build a Cache-Aware DAG Format for GPU Test Pipelines

System DesignModel answer
MediumModel answerSystem Designdagintermediate-representationcaching

Last updated

Design a DAG-based intermediate representation for GPU test pipelines and explain how to compile it into a cached, incremental, deterministic plan that survives schema changes.

Your team runs automated graphics validation: compiling shaders, building driver or toolchain artifacts, rendering scenes on specific GPUs, comparing output against reference images, and measuring performance. Many teams author these pipelines, and the definitions must keep working as tooling changes.

Design an intermediate representation (IR) that describes such a pipeline as a directed acyclic graph, and explain how a compiler turns it into an executable plan.

Your answer should cover:

  1. Graph model: the node kinds and edge kinds, and what metadata each carries (resources, timeouts, tolerances, ownership).
  2. Side effects: how the IR represents pure steps, external reads, exclusive resources such as GPU leases, nondeterministic steps, and external writes such as publishing results.
  3. Compilation: the stages that take the IR to an executable plan, including validation and normalization.
  4. Caching: how results are identified and reused.
  5. Incremental rebuilds: how a small change triggers only the work it must.
  6. Deterministic ordering: how identical inputs always yield identical schedules.
  7. Versioning: how the format evolves without breaking existing pipeline files.

State your scale assumptions, for example the number of nodes per run, the number of machines, and the fraction of the graph touched by a typical change. Discuss trade-offs and failure modes.

Hints

Hint 1

Make the identity of every node a content hash of its operation, parameters, input digests and relevant environment. Caching, incremental rebuilds and stable ordering all follow from that.

Hint 2

Give each node an explicit effect class (pure, reads external state, acquires a resource, nondeterministic, writes externally). The compiler can then decide what is cacheable, retryable or must be fenced.

Hint 3

For deterministic ordering, use a topological sort with a priority queue keyed on (priority, stable id). For incremental builds, think about early cutoff: if a rebuilt node's output digest is unchanged, its dependents stay clean.

Hint 4

For schema evolution, put a version in every file, keep changes additive where possible, and ship automated upgraders that migrate old files to the current form before compilation.