Skip to content

Fix device handling for MPS#3055

Merged
pplantinga merged 1 commit into
speechbrain:developfrom
flexthink:device-fix
May 13, 2026
Merged

Fix device handling for MPS#3055
pplantinga merged 1 commit into
speechbrain:developfrom
flexthink:device-fix

Conversation

@flexthink

Copy link
Copy Markdown
Collaborator

What does this PR do?

This PR will set device_type for all devices, preventing subsequent checks from crashing

Fixes #3054

  • Did you read the contributor guideline?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Does your code adhere to project-specific code style and conventions?

PR review

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified
  • Confirm that the changes adhere to compatibility requirements (e.g., Python version, platform)
  • Review the self-review checklist to ensure the code is ready for review

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.

Pull request overview

This PR addresses #3054 by ensuring device_type is always set when initializing training (Brain) and inference (Pretrained) interfaces, so non-CPU/non-CUDA device strings (e.g., "mps") don’t trigger AttributeError during subsequent device checks / autocast setup.

Changes:

  • Add a fallback branch in Brain.__init__ to set self.device_type for non-CPU/non-CUDA devices.
  • Add a fallback branch in Pretrained.__init__ to set self.device_type for non-CPU/non-CUDA devices.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
speechbrain/inference/interfaces.py Sets device_type for non-CPU/non-CUDA devices during inference interface initialization.
speechbrain/core.py Sets device_type for non-CPU/non-CUDA devices during core training interface initialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread speechbrain/core.py
Comment thread speechbrain/inference/interfaces.py

@pplantinga pplantinga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@pplantinga pplantinga merged commit 8a89eba into speechbrain:develop May 13, 2026
9 checks passed
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.

device = "mps" causes issues with device_type (AttributeError)

3 participants