ctypeslib based python bindings to the Dawn WebGPU engine with a focus on the compute pipeline. Besides the autogenerated bindings, a small utils interface (similar to wgpu-py) is provided to make it easier to run compute.
Chromium version used in pydawn: 133.0.6940.0
- Install from PyPI
pip install dawn-python
- Import utils, and webgpu
from pydawn import utils, webgpu
if __name__ == "__main__":
# Creating an adapter
adapter = utils.request_adapter_sync(power_preference=webgpu.WGPUPowerPreference_HighPerformance)
# Creating a device with a list of required features
dev = utils.request_device_sync(adapter, [webgpu.WGPUFeatureName_ShaderF16, webgpu.WGPUFeatureName_TimestampQuery])For more details see examples/query_set.py
- Build dawn or use the pre-built lib in the repo
pip install ctypeslib2clang2py -l libwebgpu_dawn.dylib webgpu.h --nm nm_patch.py -o webgpu.py
python3 examples/simple_compute.py
- tinygrad - tinygrad is a deep learning framework, and in its WebGPU backend it uses the Dawn binaries from pydawn. It uses the same autogened python around the binaries as pydawn.
The experimental folders in pydawn, pydawn/lib, and examples contain code related to experimental Dawn builds. Currently pydawn experimental is used to test the new chromium_experimental_subgroup_matrix feature.
| Platform | Architectures | Backend |
|---|---|---|
| macOS | x86_64, arm64 |
Metal |
| Ubuntu | x86_64, arm64 |
Vulkan |
| Windows | x86_64 |
DirectX |
BSD 3-Clause, please see LICENSE