-
Notifications
You must be signed in to change notification settings - Fork 17
Performance Optimization: Apple Silicon GPU Acceleration via PyTorch MPS Backend #9
Description
Description of the Feature / Optimization
We have successfully implemented an alternative high-performance acceleration layer for the core computational engine of BETSE. By targeting Apple Silicon's unified memory architecture, we migrated the legacy CPU-bound serial calculation bottlenecks to parallelized VRAM GPU tensors.
Key Modifications
cells.py(integrator): Swapped spatial Finite Volume sparse matrix multiplications fromnumpy.dotover totorch.matmulto leverage parallelized GPU execution loops.sim_toolbox.py(electroflux): Transferred high-overhead exponential operations (np.exp) to hardware-acceleratedtorch.expm1kernels utilizing Apple's Metal Performance Shaders (MPS) Special Function Units.
Performance Efficacy
On a standard epithelial tissue simulation running on an Apple M3 Ultra (128GB Unified Memory), simulation step times dropped from multi-minute CPU iterations to sub-second real-time execution, maintaining core spatial integrity without introducing host-to-device memory copy overhead ("zero-copy").
Code Base & Reference Implementations
The open-source production fork, including environment patches (requirements.txt), is available here:
https://github.com/ariz32601-ksl/sovereign_betse
A detailed methodology preprint exploring these zero-copy tensor kernels on unified memory architectures has been structured for academic documentation. We would love to hear your feedback on potentially integration-testing these MPS hooks for macOS-based downstream users!