predict() recomputes attention states for the training rows, even if training set had not changed.
Set fit_mode="fit_with_cache" to compute attention state during fit() and reuse it during prediction. This makes fitting slower and
uses more memory, but drastically reduces latency when you predict repeatedly against the same training set.
Quickstart
- TabPFN API
- Local package
fit_mode="fit_with_cache" is also available on TabPFNRegressor.
How it works
1
Fit
TabPFN preprocesses the training set and runs the training-side transformer
computation once. The KV cache stores the resulting attention state. Locally, the cache belongs to the fitted
estimator. The managed API stores it using a model ID.
2
Predict
TabPFN reuses the cached keys and values and runs only the test-side
computation. With
tabpfn-client, the fitted model ID identifies the cache
used for the request.When to use it
The break-even point depends on training-set size, ensemble size, hardware, and
the number of prediction calls.
Reuse an API fit in another process
After an API fit,model_id_ references the server-side fitted state. Store the
ID with your application metadata to use the same fit from another process or
machine.
model_id_ does not download the model or training data, the model stays on Prior Labs servers.
Limits and lifecycle
- A cache is valid only for the training data and model configuration used to
create it. Call
fit()again after either changes. - The managed API supports KV caching only for TabPFN-3 and later models.
- KV caching is not compatible with Thinking mode in the managed API.
- Cached API predictions accept up to 10,000 test rows per call. Split larger
test sets across multiple
predict()calls. - In the local package, the cache lives with the fitted estimator and consumes local RAM or VRAM. Releasing the estimator releases the cache.
Benchmark KV cache
Compare fit and prediction time with and without caching.
Interpretability
Speed up repeated explanation calls against a fixed training set.
Out-of-memory errors
Reduce memory pressure and choose an appropriate fit mode.
API getting started
Set up authentication and make your first API call.