Out-of-tree backend for pytorch supporting any GPU with a Vulkan driver!
Originally based pytorch_dlprim, but will likely have even more functionality in the future.
Currently pytorch version 2.4.0 is required, but this will change in the future.
See README-build.md
Example:
import pytorch_vk
import torch
a = torch.randn(256).to("vk:0")
- Many operators not implemented and there may be fallbacks to CPU. Sometimes it is minor but sometimes it may hamper the performance, some may just fail
- When you save/restore the model move it to CPU. Currently there is an issue with loading back saved state dictionary if it was saved from vk device
- Efficiency is currently abysmal due to GPU under-utilization. Optimization has been put on the backburner in order to focus on making sure all the computations pass correctness tests, but hopefully this will soon change.
In order of priority:
- Refactor codebases of upstream dependencies. They have far too many goofy abstractions that only exist because of limitations inherent to OpenCL and/or the ability to support multiple GPGPU APIs, and this makes maintenance and optimization difficult.
- Optimize as much as possible.
- Implement missing operators.
Some functions specific to pytorch_vk. When using pytorch >= 2.4 they are accessible from torch.vk and pytorch_vk, for 1.13 you must use pytorch_vk
torch.vk.empty_cache(): Same astorch.cuda.empty_cache()remove all cached GPU memorytorch.vk.synchronize(device=None): synchronize all operations queue on the device, if device is None - all of them same astorch.cuda.synchonizetorch.vk.manual_seed_all(seed): reset random number generator state.torch.manual_seed- it calls automatically for pytorch >= 2.4. Note for pytorch 1.13 you must callpytorch_vk.manual_seed_all