Fix device override in from_pretrained, add MPS support#9
Fix device override in from_pretrained, add MPS support#9yajur-khanna wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
- Move extractor device overrides to after config YAML is loaded;
previously they were applied before yaml.load() reassigned config,
silently discarding all overrides and causing AssertionError on
CPU-only systems ("Torch not compiled with CUDA enabled").
- Add MPS auto-detection via torch.backends.mps.is_available() so
Apple Silicon users get GPU acceleration on the FmriEncoder.
- Force neuralset feature extractors to CPU when device is mps,
since their device field is Literal["auto","cpu","cuda","accelerate"].
- Update docstring to document the CPU extractor fallback behavior.
|
Hi @yajur-khanna! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Bug Fix
The extractor device overrides in
from_pretrainedwere applied toconfigbefore
yaml.load()reassigned it to a freshConfDicton line 211,silently discarding all overrides. This caused:
on CPU-only systems (e.g. macOS), even when the config hardcodes
device: cuda.MPS Support
Adds MPS auto-detection for Apple Silicon. The
FmriEncoderbrain modelruns on MPS; neuralset feature extractors fall back to CPU since their
devicefield isLiteral["auto", "cpu", "cuda", "accelerate"].Changes
demo_utils.py: move extractor device overrides to after config YAML loaddemo_utils.py: addtorch.backends.mps.is_available()to auto-detectiondemo_utils.py: extend extractor CPU override to coverdevice="mps"