MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / _hash_source

Function _hash_source

kernels/cuda/_compile.py:86–96  ·  view source on GitHub ↗

Create a deterministic hash of the source + flags for cache keying.

(cuda_src: str, cpp_src: str, extra_flags: list)

Source from the content-addressed store, hash-verified

84
85
86def _hash_source(cuda_src: str, cpp_src: str, extra_flags: list) -> str:
87 """Create a deterministic hash of the source + flags for cache keying."""
88 h = hashlib.sha256()
89 h.update(cuda_src.encode("utf-8"))
90 h.update(cpp_src.encode("utf-8"))
91 h.update("|".join(sorted(extra_flags)).encode("utf-8"))
92 # Include torch version and CUDA version in hash
93 h.update(torch.__version__.encode("utf-8"))
94 cuda_ver = torch.version.cuda or "unknown"
95 h.update(cuda_ver.encode("utf-8"))
96 return h.hexdigest()[:16]
97
98
99# ---------------------------------------------------------------------------

Callers 1

compile_cudaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected