﻿# TabPFN repeated prediction: preprocessing cache and transformer KV cache save different work

Choose TabPFN fit modes by separating on-demand preprocessing, retained transformed context and transformer KV caching, with explicit memory and context invalidation.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-tabpfn-fit-cache-repeated-prediction-memory-context/
Language: en

## Separate one-shot and repeated inference workloads

A tabular application may predict one held-out table once or repeatedly score new rows against unchanged labeled context. The [TabPFN usage guide](https://raw.githubusercontent.com/PriorLabs/TabPFN/main/README.md) distinguishes batching predictions from reusing a prepared context. Measure the workload actually required by the application. A fit time measured once and excluded from every prediction can misrepresent a service whose labeled context changes frequently, while recomputing the same context can dominate repeated scoring unnecessarily.

## Identify which preparation is retained

The [estimator contract](https://raw.githubusercontent.com/PriorLabs/TabPFN/main/src/tabpfn/classifier.py) distinguishes low-memory on-demand preparation from a mode that fits and retains preprocessing. Reusing transformed context avoids repeating that preparation, but it does not necessarily avoid all transformer work. Preserve the fit mode in a benchmark description rather than presenting every cached configuration as one identical optimization. The first useful resource question is which intermediate state remains available between calls.

## Follow the transformer cache separately

The [inference-engine implementation](https://raw.githubusercontent.com/PriorLabs/TabPFN/main/src/tabpfn/inference.py) provides engines for different caching strategies. The fit-with-cache path additionally retains transformer context representations, trading memory for repeated prediction work. Its cache is derived from the fitted context and preprocessing configuration. Changing rows, labels, feature schema or relevant preparation invalidates assumptions about reuse; the same pretrained weight identifier alone does not make an old context cache appropriate for a newly fitted problem.

## Keep test-row chunking distinct from context changes

Current project guidance describes chunking test rows under cached inference to bound peak memory while retaining the same context. That is different from subsampling labeled context, which changes available evidence. Floating-point execution can still create small numerical differences across batch shapes. The [Chronos cross-learning guide](/journal/fg2-chronos2-cross-learning-batch-composition-estimand/) offers a contrasting case where group composition explicitly changes information. Document which axis is chunked instead of assuming every batch adjustment has identical statistical meaning.

## Benchmark cold and reused state

Measure initial preparation, resident memory, repeated scoring and refitting after a context change. The [TabPFN fit-semantics guide](/journal/fg2-tabpfn-standard-fit-context-state-versus-weight-training/) defines the underlying state. Verify output consistency against a valid uncached reference with the same context and supported numerical tolerance. Select a cache mode when its reuse assumptions match the application's update pattern, keeping memory savings, avoided computation and changes to the actual labeled evidence separate in both implementation and reporting.
