You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR implements serialization/de-serialization of kernel arguments
and meta data from Triton backend and enables fully functional generic
SPIRVRunner.
# Add preview-breaking-changes for ABI compatibility with SYCL library linked by PyTorch: https://github.com/pytorch/pytorch/commit/92bebb46fa9fd60523d8aeb7b5f1a3f488c4cd93
`SPIRVRunner` is configured to run the `add_kernel.spv` SPIRV binary with inputs `x.py` and `y.py`. `add_kernel.spv` was generated from the `01-vector-add.py` tutorial.
22
+
### Generate Data
23
23
24
-
Kernels of different shapes require modifying parameters manually in the `SPIRVRunner`. Two places require modification:
24
+
In order to utilize this utility, Triton application must be run with following environment variables enabled
25
+
Provide the path to the directory where the serialized JSON, tensors and SPRI-V binary stored. It is recommended to clear triton cache.
26
+
27
+
```
28
+
export TRITON_XPU_DUMP_SPIRV_KERNEL_ARGS=< Absolute path to SPV Dumps >
1.`launchKernel`: Add input Tensors to the function signature, add arguments as variables within the function. Arguments can be pulled from the `args` variable to `XPULauncher.__call__` method in `driver.py`. Arguments should be passed to the `sycl_kernel_launch` function. Note that we currently rely on `sycl::memcpy` to move the PyTorch Tensor to XPU. In later versions of PyTorch we should be able to delegate this responsibility to `PyTorch`, and pass the raw XPU `data_ptr()` from `PyTorch` to the kernel.
27
-
2.`sycl_kernel_launch`: Place all `arg*` parameters into the `params` array and add an appropriate call to `set_scalar_arg` for each param, which tells `SYCL` what the arguments are for the kernel we are going to launch.
28
37
29
38
## Running
30
39
31
-
Once the `SPIRVRunner` has been appropriately configured for the kernel and inputs, run the binary with no arguments:
40
+
Help:
41
+
`./build/SPIRVRunner` < Output Tensor Name >
42
+
43
+
Note: `Output Tensor Name` is essentially a chosen tensor that needs to be copied back to the CPU and written to disk. Additionally, the name must match the tensor's name (tensor_) and number as specified in the JSON file. Please refer args_data.json file.
44
+
45
+
### Demo (01-vector-add.py)
46
+
47
+
`SPIRVRunner` is configured to run the `add_kernel.spv` SPIRV binary with inputs `tensor_0.pt` and `tensor_1.pt` and output `tensor_2.pt`. `add_kernel.spv` was generated from the `01-vector-add.py` tutorial.
32
48
33
-
`./build/SPIRVRunner`
49
+
SPIRVRunner Usage:
50
+
`./build/SPIRVRunner tensor_2`
34
51
35
52
Expected output follows:
36
53
37
54
```
38
55
Running on device: Intel(R) Data Center GPU Max 1100
39
-
Tensor a: [98432], Float (393728 bytes)
40
-
Tensor b: [98432], Float (393728 bytes)
41
56
Read 3772 byte kernel.
57
+
create kernel:add_kernel
42
58
Loaded kernel with 0 registers and 0 register spills.
0 commit comments