Skip to content

fix(unsupervised): move sampled values to the input table's device - #421

Open
punitvara wants to merge 2 commits into
PriorLabs:mainfrom
punitvara:fix/unsupervised-impute-device-420
Open

punitvara wants to merge 2 commits into
PriorLabs:mainfrom
punitvara:fix/unsupervised-impute-device-420

Conversation

@punitvara

Copy link
Copy Markdown

Fixes #420.

Problem

TabPFNUnsupervisedModel.generate_synthetic_data() and impute() crash on a CUDA machine with Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!. The table being filled (impute_X) is on the CPU, but since tabpfn 9.1 the regressor's logits and criterion are returned on the model's device, so the sampled values are on the GPU. The assignment only did .to(y_predict.dtype), which changes the dtype but not the device.

Change

Use .to(device=impute_X.device, dtype=y_predict.dtype) at both assignment sites (impute_ and impute_single_permutation_). The values already live in a CPU table, so this is a no-op on CPU-only setups.

Testing

  • Added test_impute_single_permutation_moves_samples_to_input_device. It needs no model weights or GPU: it stubs the sampling step with a tensor that records the arguments passed to .to. It fails before this change and passes after.
  • Not verified on a real CUDA GPU (I don't have one). Could a maintainer or the reporter confirm with the repro from generate_synthetic_data fails on GPU: tensors on cuda:0 and cpu #420?
  • ruff is clean for the lines I touched (3 pre-existing warnings remain in the test file).
  • Added changelog fragment.

🤖 Generated with Claude Code

With tabpfn>=9.1 the regressor's logits and criterion live on the model
device, so sampled values were on CUDA while the table being imputed is
on the CPU. Assigning them raised 'Expected all tensors to be on the same
device'. Move them with .to(device=impute_X.device, dtype=...) in both
impute_ and impute_single_permutation_.

Fixes PriorLabs#420

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 08:03
@CLAassistant

CLAassistant commented Nov 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions
github-actions Bot requested a review from priorphil November 19, 2026 08:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate_synthetic_data fails on GPU: tensors on cuda:0 and cpu

3 participants