cuda.core.utils.ProgramCacheResource#

class cuda.core.utils.ProgramCacheResource#

Abstract base class for compiled-program caches.

Concrete implementations store and retrieve ObjectCode instances keyed by arbitrary hashable objects. A typical key is produced by make_program_cache_key(), but any hashable value is acceptable.

Warning

Persistent backends use pickle for serialization. Only read cache files that you trust — loading a cache from an untrusted source can execute arbitrary code. Cache directories should have the same access controls as any other sensitive build artifact.

Note

Cache only bytes-backed ObjectCode instances. Path-backed objects (created via ObjectCode.from_cubin("/path")) store the path, not the content — if the file is later modified or deleted, cache hits will return stale or broken data. Normalize to bytes before caching.

Methods

__init__()#
abstract clear() None#

Remove every entry from the cache.

close() None#

Release backend resources. No-op by default.

get(
key: Hashable,
default: ObjectCode | None = None,
) ObjectCode | None#

Return self[key] or default if absent.