quchip.utils.values

Ownership and cache keys for authored numerical values.

Functions

copy_value(value, *[, readonly])

Copy mutable values without detaching native JAX arrays or tracers.

scoped_entry(key, value, *, traced)

A cache entry (key, scope, value).

scoped_hit(entry, key)

Return if entry holds key and, when scoped, belongs to the current trace.

value_fingerprint(value, *[, traced])

Hash the contents of supported values; reject opaque mutable payloads.

Classes

DeferredValue(evaluate)

Evaluate captured inputs on demand; cache only concrete values.

TracedKey(ident)

Cache-key stand-in for a JAX tracer: its identity in the trace that owns it.

quchip.utils.values.copy_value(value, *, readonly=False)[source]

Copy mutable values without detaching native JAX arrays or tracers.

class quchip.utils.values.TracedKey(ident)[source]

Bases: object

Cache-key stand-in for a JAX tracer: its identity in the trace that owns it.

ident: int
quchip.utils.values.value_fingerprint(value, *, traced=False)[source]

Hash the contents of supported values; reject opaque mutable payloads.

It rejects a tracer unless traced is true. If traced is true, the key is the tracer’s identity (TracedKey). Such keys are valid only in the owning trace, so you must scope their cache entries with scoped_entry().

quchip.utils.values.scoped_entry(key, value, *, traced)[source]

A cache entry (key, scope, value).

An entry with a traced value, or with a key that holds a TracedKey, records the current JAX trace. Such an entry belongs to that trace, and quchip does not reuse it in a nested or later trace. Other entries are valid everywhere.

quchip.utils.values.scoped_hit(entry, key)[source]

Return if entry holds key and, when scoped, belongs to the current trace.

class quchip.utils.values.DeferredValue(evaluate)[source]

Bases: object

Evaluate captured inputs on demand; cache only concrete values.

evaluate: Callable[[], Any]