CBlas ABI changes #3
Merged
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.
Remove use of
torch.set_default_tensor_type(Remove use oftorch.set_default_tensor_typeexplosion/thinc#674)Remove use of
torch.set_default_tensor_typeThis PR removes use of
torch.set_default_tensor_type. There arevarious reasons why we should probably move away from using this
function:
Deprecate and remove torch.set_default_tensor_type pytorch/pytorch#53124
Metal Performance Shaders.
devices.
This PR makes
PyTorchWrapper/PyTorchShimflexible in terms of thedevices it can use. Both classes add a
deviceargument to theirconstructors that takes a
torch.deviceinstance. The shim ensures thatthe model is on the given device. The wrapper ensures that input tensors
are on the correct device, by calling
xp2torchwith the newdevicekeyword argument.
Even though this approach offers more flexibility, as a default we want
to use the
cpudevice whenNumpyOpsis used andcuda:NwhenCupyOps is used. In order to do so, this PR also adds a new function
get_torch_default_devicethat returns the correct device for thecurrently active Ops.
PyTorchWrapper/PyTorchShim/xp2torchuse thisfunction when
Noneis given as the device to fall back on thisdefault, mimicking the behavior from before this PR.
Add some typing fixes
Remove spurious cupy import
Small fixes
torch.cuda.current_device()to get the current PyTorch CUDAdevice.
torch_set_default_tensor_typeinset_active_gpu.Add
test_slow_gpuexplosion-bot commandAuto-format code with black (Auto-format code with black explosion/thinc#682)
Co-authored-by: explosion-bot [email protected]
Azure: pin protobuf to fix Tensorflow
Extend typing_extensions to <4.2.0 (Extend typing_extensions to <4.2.0 explosion/thinc#689)
Add support for PyTorch Metal Performance Shaders (Add support for PyTorch Metal Performance Shaders explosion/thinc#685)
Add
test_slow_gpuexplosion-bot commandAuto-format code with black (Auto-format code with black explosion/thinc#682)
Co-authored-by: explosion-bot [email protected]
Nightly PyTorch versions add support for Metal Performance Shaders
(MPS). Metal is a low-level graphics API for Apple platforms that also
supports compute kernels (shaders). MPS is a framework of
highly-optimized compute and graphics kernels, including kernels for
neural networks. MPS is supported on both Apple Silicon, such as the M1
family of SoC, as well as a range of AMD GPUs used in Macs.
Since devices are handled in Thinc through a specific
Opsimplementation (e.g.
CupyOps== CUDA GPUs), this change introduces theMPSOpsclass. This class is a subclass ofNumpyOpsorAppleOps(when available).MPSOpsdoes not override any methods, butis used to signal to relevant code paths (e.g.
xp2torch) that Torchtensors should be placed on the MPS device.
The mapping in the previously introduced
get_torch_default_devicefunction is updated to:
NumpyOps->cpuCupyOps->cuda:N, where N is the selected CUDA device.MPSOps->mpsto ensure placement of Torch tensors on the
mpsdevice whenMPSOpsis active.
Finally, the following booleans have been added to or changed in
compat:has_torch_mps(new): PyTorch has MPS supporthas_torch_mps_gpu(new): PyTorch has MPS support and anMPS-capable GPU is available.
has_torch_cuda_gpu(new): PyTorch has CUDA support and aCUDA-capable GPU is available.
has_torch_gpu(changed): PyTorch has a GPU available (CUDAor MPS).
Test PyTorch wrapper with all xp ops
Azure: pin protobuf to fix Tensorflow
Extend typing_extensions to <4.2.0 (Extend typing_extensions to <4.2.0 explosion/thinc#689)
Fix type checking error
Only back-off to NumpyOps on import error
We do not want to hide other issues while importing thinc_apple_ops.
Remove unneeded
has_torch_mpsboolAdd
has_gpubool and use it inutilReplace another expression by has_gpu
Set
has_torch_gputohas_torch_cuda_gpuWe need to decide whether we want to make the potentially breaking
change from
has_torch_cuda_gputohas_torch_cuda_gpu or has_torch_mps_gpu. But since the latter is not needed for this PR,remove the change.
Co-authored-by: Sofie Van Landeghem [email protected]
Co-authored-by: shademe [email protected]
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: explosion-bot [email protected]
Co-authored-by: Adriane Boyd [email protected]
Co-authored-by: Sofie Van Landeghem [email protected]
Co-authored-by: shademe [email protected]
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: explosion-bot [email protected]
Co-authored-by: Adriane Boyd [email protected]
Co-authored-by: Sofie Van Landeghem [email protected]