Skip to main content
fit() and predict() return once the server has finished the work. A fit can run for a long time, in thinking mode especially, and a large prediction can take a while too. In the meantime, the process that waits can stop: a closed notebook, a crash, a job timeout. With tabpfn-client, you can submit a fit or a prediction and wait for it later. Submitting returns as soon as the server has accepted the work. Save the model, and a later run can load it and wait for the same fit or prediction instead of starting it again.
Requires tabpfn-client 0.7.0 or later.

When to use it

  • A fit or a prediction can outlast the process that starts it.
  • You want the process to do other work while the server runs the job.
  • You start the work in one run, such as a scheduled job, and use the result in another.
For short fits and predictions, use fit() and predict().

Submit a fit and wait for it later

submit_fit() starts the fit and returns as soon as the server has accepted it. Save the model then, and a later run can load it and wait for the same fit instead of fitting again:
Until wait_for_fit() has seen the fit complete, the model is pending, and predict() raises NotFittedError without asking the server. wait_for_fit() polls the server until the fit has completed, and returns at once if it already has.
  • The id of the fit is in model.model_id_ as soon as submit_fit() returns, for logs or support requests.
  • If the server reports that the fit failed, wait_for_fit() raises FitFailedError. If the server no longer has the fit, it raises FittedModelNotFoundError. In both cases the model is unfitted.
  • If the fit has not completed within TABPFN_CLIENT_ASYNC_POLL_TIMEOUT seconds (by default the server’s 2 hours), wait_for_fit() raises TimeoutError. The model is still pending, so call wait_for_fit() again.
submit_fit() is also available on TabPFNRegressor.

Submit a prediction and wait for it later

submit_predict() starts a prediction and returns as soon as the server has accepted it, so the process can do other work in the meantime. wait_for_predict() then waits for the prediction and returns it. The model holds the pending prediction until then, and save_model() saves it, so a later run can load the model and wait for the same prediction:
submit_predict() takes the arguments of predict(), and wait_for_predict() returns what predict() returns for them. A classifier’s submit_predict() also takes output_type: A model holds one pending prediction:
  • A new submit_predict() or predict() replaces it once the server has accepted the new prediction, and a new fit drops it. The id of a dropped prediction is logged as a warning.
  • The server keeps the result of a prediction for at least a day after it completes.
  • Submit a prediction only after the fit has completed. On a pending model, submit_predict() raises NotFittedError: call wait_for_fit() first.

Resume an interrupted predict()

predict() holds its own prediction the way fit() holds its fit: while it waits for a prediction that the server runs as a background job, the model holds it. If that wait stops, for a timeout or an interrupt, call wait_for_predict() to wait for the same prediction instead of starting a new one, or save_model() to wait for it in a later run. A regressor’s "full" output split over several requests is not held; its ids are logged instead.

Save and load

save_model() writes a small JSON record: the id of the fitted model, the hyperparameters, the class labels and the training-set size, and whether the fit or a prediction is still pending. It holds no training data. load_model() makes no request, so loading a pending model is instant; the wait happens in wait_for_fit() or wait_for_predict().
  • Load with the same account that ran the fit.
  • save_model() also returns the record as a dict, so you can keep it elsewhere, such as a database or an experiment tracker, and pass it to load_model().
See Model selection and persistence for the full reference.

Methods

submit_fit() and submit_predict() always run the work as a background job on the server, whatever api_mode is.

Thinking mode

Longer fits for higher prediction quality.

KV cache

Reuse a fit for faster repeated predictions.

API rate limits

Request limits for the TabPFN API.

API metering

Token charges, budgets, and usage tracking.