sparsax.set_num_cache_size

sparsax.set_num_cache_size(n)[source]

Cap the value-keyed numeric-factor cache per CHOLMOD pattern (default 32).

Every CHOLMOD call — solve(), logdet(), factor_solve(), factor() and the rest — takes its factor from a per-pattern cache keyed on Ax, so a repeated call with identical values skips the factorization. When the cache is full the oldest entry is evicted. A token from factor() holds its own reference, so eviction never invalidates it; only clear_cache() does. Each entry is a whole Cholesky factor, so the cap bounds memory.

As with set_lu_cache_size(), hold at least one factor per vmap batch element: a vmap(value_and_grad(logp)) over more chains than the cap silently refactors on every solve and logdet within an evaluation.