reference_cache#

Caches reference benchmark results in the database so repeated build_and_test/submit_task invocations can reuse a reference result instead of rebuilding/rebenchmarking it every time.

Functions

load_cached_reference(task, config)

Looks up a cached reference benchmark result for this task's reference content + gpu_arch(es).

store_reference(task, config, ...[, job_id])

Persists a freshly-computed reference result so later invocations can reuse it.

kernelfoundry.algorithm.utils.reference_cache.load_cached_reference(task: Task, config) → tuple[TestResult, BuildResult | None] | None[source]#

Looks up a cached reference benchmark result for this task’s reference content + gpu_arch(es).

Parameters:
  • task (Task) – Task whose reference-relevant files are hashed to form the cache key.

  • config – Execution config (dict or DictConfig), used to read use_cached_reference and the gpu_arch(es) to key the lookup on.

Returns:

The cached (test_result_reference,

build_result_reference), or None if caching is disabled, any requested architecture is missing from the cache, or the lookup failed.

Return type:

tuple[TestResult, BuildResult | None] | None

kernelfoundry.algorithm.utils.reference_cache.store_reference(task: Task, config, test_result_reference: TestResult | None, build_result_reference: BuildResult | None, job_id: int | None = None) → None[source]#

Persists a freshly-computed reference result so later invocations can reuse it.

One row is stored per individual gpu_arch (see module docstring). The build result, which isn’t arch-specific, is duplicated across each arch’s row.

Parameters:
  • task (Task) – Task whose reference-relevant files are hashed to form the cache key.

  • config – Execution config (dict or DictConfig), used to read use_cached_reference and the gpu_arch(es) to key the entry on.

  • test_result_reference (TestResult | None) – Freshly-computed reference test result. No-op if None (nothing to cache).

  • build_result_reference (BuildResult | None) – Freshly-computed reference build result, if any.

  • job_id (int | None) – Job that produced this result, stored for traceability.