Fix MPS device movement for constant tensors in TabNet modules#279
Merged
DanielAvdar merged 6 commits intoadd-simple-tests-tab-networkfrom Nov 2, 2025
Merged
Conversation
Co-authored-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com>
Co-authored-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix device movement issues with PyTorch on macOS MPS
Fix MPS device movement for constant tensors in TabNet modules
Nov 2, 2025
Removed MPS device check from auto device selection. Signed-off-by: Daniel Avdar <66269169+DanielAvdar@users.noreply.github.com>
Signed-off-by: Daniel Avdar <66269169+DanielAvdar@users.noreply.github.com>
DanielAvdar
added a commit
that referenced
this pull request
Nov 2, 2025
* Initial plan * Add device movement tests for all tab_network modules Co-authored-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> * Fix MPS device movement for constant tensors in TabNet modules (#279) * Initial plan * Fix MPS device movement issues by registering tensors as buffers Co-authored-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> * Final verification: all tests pass, no security issues Co-authored-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> * Remove spurious nul file * Simplify device selection logic Removed MPS device check from auto device selection. Signed-off-by: Daniel Avdar <66269169+DanielAvdar@users.noreply.github.com> * Fix device selection logic for 'auto' case Signed-off-by: Daniel Avdar <66269169+DanielAvdar@users.noreply.github.com> --------- Signed-off-by: Daniel Avdar <66269169+DanielAvdar@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> --------- Signed-off-by: Daniel Avdar <66269169+DanielAvdar@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tensor device mismatch errors occur on macOS MPS backend because constant tensors (
group_matrix,embedding_group_matrix) are not registered as buffers, preventing automatic device movement during.to(device)calls.Changes
pytorch_tabnet/utils/device.py: Added MPS device detection with priority ordering: MPS → CUDA → CPUpytorch_tabnet/tab_network/random_obfuscator.py: Registergroup_matrixas buffer viaself.register_buffer()pytorch_tabnet/tab_network/embedding_generator.py: Registerembedding_group_matrixas buffer in both skip-embedding and with-embedding pathsExample
Before (device mismatch on MPS):
After (correct device movement):
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.