Skip to content

Commit 8da19fe

Browse files
etafpytorchmergebot
authored andcommitted
1 parent 2820e1d commit 8da19fe

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

torch/_inductor/codecache.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def get_path(
386386
def get_hash(content: Union[str, bytes], extra: str = "", hash_type: str = "code"):
387387
if hash_type == "code":
388388
return code_hash(content, extra)
389-
if hash_type in ["cubin", "hsaco"]:
389+
if hash_type in ["cubin", "hsaco", "spv"]:
390390
return code_hash(repr(content))
391391
raise AssertionError(f"Unknown hash type {hash_type}")
392392

@@ -1582,8 +1582,7 @@ class CudaKernelParamCache:
15821582
cache_clear = staticmethod(cache.clear)
15831583

15841584
@classmethod
1585-
def set(cls, key: str, params: Dict[str, str], cubin: str) -> None:
1586-
bin_type = "cubin" if torch.version.hip is None else "hsaco"
1585+
def set(cls, key: str, params: Dict[str, str], cubin: str, bin_type: str) -> None:
15871586
_, path = write(
15881587
cubin,
15891588
bin_type,

torch/_inductor/codegen/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ def generate_save_uncompiled_kernels(self):
14911491
if not kernel.cuda_kernel_saved:
14921492
if len(kernel.launchers) == 0:
14931493
kernel.precompile()
1494-
kernel.save_cuda_kernel(
1494+
kernel.save_gpu_kernel(
14951495
grid=(0, 0, 0), # use dummy grid
14961496
stream="stream", # use dummy stream
14971497
launcher=kernel.launchers[0],

torch/_inductor/runtime/triton_heuristics.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def autotune_to_one_config(self, *args, **kwargs):
723723
if self.save_cache_hook:
724724
self.save_cache_hook(self.launchers[0].config, time_taken_ns)
725725

726-
def save_cuda_kernel(self, grid, stream, launcher):
726+
def save_gpu_kernel(self, grid, stream, launcher):
727727
if callable(grid):
728728
grid_x, grid_y, grid_z = grid(launcher.config.kwargs)
729729
else:
@@ -753,12 +753,9 @@ def save_cuda_kernel(self, grid, stream, launcher):
753753
}
754754
from torch._inductor.codecache import CudaKernelParamCache
755755

756-
binary = (
757-
launcher.bin.asm["cubin"]
758-
if self.device_props.type != "hip"
759-
else launcher.bin.asm["hsaco"]
760-
)
761-
CudaKernelParamCache.set(key, params, binary)
756+
bin_type = {"hip": "hsaco", "xpu": "spv"}.get(self.device_props.type, "cubin")
757+
binary = launcher.bin.asm[bin_type]
758+
CudaKernelParamCache.set(key, params, binary, bin_type)
762759

763760
self.cuda_kernel_saved = True
764761

@@ -831,7 +828,7 @@ def run(self, *args, grid, stream, **kwargs):
831828

832829
(launcher,) = self.launchers
833830
if launcher.store_cubin:
834-
self.save_cuda_kernel(grid, stream, launcher)
831+
self.save_gpu_kernel(grid, stream, launcher)
835832

836833
if launcher.config.pre_hook is not None:
837834
launcher.config.pre_hook(

0 commit comments

Comments
 (0)