Skip to content

Conditionally clear MPS cache on OOM error#967

Open
tongchen126 wants to merge 1 commit into
PriorLabs:mainfrom
tongchen126:patch-1
Open

Conditionally clear MPS cache on OOM error#967
tongchen126 wants to merge 1 commit into
PriorLabs:mainfrom
tongchen126:patch-1

Conversation

@tongchen126
Copy link
Copy Markdown

@tongchen126 tongchen126 commented May 15, 2026

This commit will fix error on CUDA-only system.
Otherwise, the following error will occur:
"Cannot execute emptyCache() without MPS backend."

Issue

Please link the corresponding GitHub issue. If an issue does not already exist,
please open one to describe the bug or feature request before creating a pull request.

This allows us to discuss the proposal and helps avoid unnecessary work.

Motivation and Context

I encounterd error on my CUDA system. In torch, torch.backends.mps.is_available() must be verified before calling torch.mps.empty_cache() or the error "Cannot execute emptyCache() without MPS backend." will be raised.
This is a torch-specific behavior.


Public API Changes

  • [*] No Public API changes
  • Yes, Public API changes (Details below)

How Has This Been Tested?


Checklist

  • [*] The changes have been tested locally.
  • Documentation has been updated (if the public API or usage changes).
  • A changelog entry has been added (see changelog/README.md), or "no changelog needed" label requested.
  • [*] The code follows the project's style guidelines.
  • I have considered the impact of these changes on the public API.

This commit will fix error on CUDA-only system. 
Otherwise, the following error will occur:
"Cannot execute emptyCache() without MPS backend."
@tongchen126 tongchen126 requested a review from a team as a code owner May 15, 2026 08:09
@tongchen126 tongchen126 requested review from bejaeger and removed request for a team May 15, 2026 08:09
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the OOM error handling in src/tabpfn/architectures/tabpfn_v3.py by adding a check for MPS availability before calling torch.mps.empty_cache(). This change prevents potential errors on systems where MPS is not supported. I have no feedback to provide.

Copy link
Copy Markdown
Collaborator

@bejaeger bejaeger left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!
For the CI to succeed you will have to rebase to main and also add a chagelog. Thanks a lot.

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.

3 participants