From a245bc0629c5f09f9630661f1cb1ab2a3e285cb1 Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Tue, 25 Aug 2026 16:51:30 +0300 Subject: [PATCH 01/10] use CUDA 12 GPUOcelot build --- .github/actions/setup-tinygrad/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index d55221f688724..af2287b1dd216 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -262,7 +262,7 @@ runs: shell: bash run: | sudo mkdir -p /usr/local/lib - sudo curl --output-dir /usr/local/lib -fLO https://github.com/tinygrad/gpuocelot/releases/download/v0.1.0/libgpuocelot.${{ runner.os == 'Linux' && 'so' || 'dylib' }} + sudo curl --output-dir /usr/local/lib -fLO https://github.com/li0nr/gpuocelot/releases/download/cuda-12-support/libgpuocelot.${{ runner.os == 'Linux' && 'so' || 'dylib' }} # **** WebGPU **** From c86a7a06c947f72ae6c46804b5a2068c4fb9c02e Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Tue, 25 Aug 2026 17:31:59 +0300 Subject: [PATCH 02/10] ci: update NVRTC to 12.9.86 --- .github/actions/setup-tinygrad/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index af2287b1dd216..120af5fa4ba1d 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -251,7 +251,7 @@ runs: shell: bash run: | sudo mkdir -p /usr/local/cuda/targets/x86_64-linux - curl -fL https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/linux-x86_64/cuda_nvrtc-linux-x86_64-11.5.119-archive.tar.xz \ + curl -fL https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/linux-x86_64/cuda_nvrtc-linux-x86_64-12.9.86-archive.tar.xz \ | sudo tar -xJ -C /usr/local/cuda/targets/x86_64-linux --strip-components=1 echo /usr/local/cuda/targets/x86_64-linux/lib | sudo tee /etc/ld.so.conf.d/cuda-nvrtc.conf sudo ldconfig From 0f16d58d680d99390fc9facba6a29e4e622cc9ac Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Fri, 28 Aug 2026 19:03:42 +0300 Subject: [PATCH 03/10] min gpu arch is now sm_50. --- test/mockgpu/nv/nvdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mockgpu/nv/nvdriver.py b/test/mockgpu/nv/nvdriver.py index d0f9d945ec20d..e4e4c970d7767 100644 --- a/test/mockgpu/nv/nvdriver.py +++ b/test/mockgpu/nv/nvdriver.py @@ -168,7 +168,7 @@ def rm_control(self, argp): else: for i,c in enumerate(classes): params.classList[i] = c elif struct.cmd == nv_gpu.NV2080_CTRL_CMD_GR_GET_INFO: - info = {nv_gpu.NV2080_CTRL_GR_INFO_INDEX_SM_VERSION: nv_gpu.NV2080_CTRL_GR_INFO_SM_VERSION_3_5, + info = {nv_gpu.NV2080_CTRL_GR_INFO_INDEX_SM_VERSION: nv_gpu.NV2080_CTRL_GR_INFO_SM_VERSION_5_0, nv_gpu.NV2080_CTRL_GR_INFO_INDEX_LITTER_NUM_GPCS: 1, nv_gpu.NV2080_CTRL_GR_INFO_INDEX_LITTER_NUM_TPC_PER_GPC: 1, nv_gpu.NV2080_CTRL_GR_INFO_INDEX_LITTER_NUM_SM_PER_TPC: 1, From 0c079707812f727ee30e13d2156718439cfb713d Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Fri, 28 Aug 2026 20:00:32 +0300 Subject: [PATCH 04/10] min gpu arch is now sm_86. --- test/mockgpu/nv/nvdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mockgpu/nv/nvdriver.py b/test/mockgpu/nv/nvdriver.py index e4e4c970d7767..dbad6d15c0d3f 100644 --- a/test/mockgpu/nv/nvdriver.py +++ b/test/mockgpu/nv/nvdriver.py @@ -168,7 +168,7 @@ def rm_control(self, argp): else: for i,c in enumerate(classes): params.classList[i] = c elif struct.cmd == nv_gpu.NV2080_CTRL_CMD_GR_GET_INFO: - info = {nv_gpu.NV2080_CTRL_GR_INFO_INDEX_SM_VERSION: nv_gpu.NV2080_CTRL_GR_INFO_SM_VERSION_5_0, + info = {nv_gpu.NV2080_CTRL_GR_INFO_INDEX_SM_VERSION: nv_gpu.NV2080_CTRL_GR_INFO_SM_VERSION_8_6, nv_gpu.NV2080_CTRL_GR_INFO_INDEX_LITTER_NUM_GPCS: 1, nv_gpu.NV2080_CTRL_GR_INFO_INDEX_LITTER_NUM_TPC_PER_GPC: 1, nv_gpu.NV2080_CTRL_GR_INFO_INDEX_LITTER_NUM_SM_PER_TPC: 1, From ec0681ba7a7a9efaae1e26ed8ff5d1276620d013 Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Fri, 28 Aug 2026 19:57:33 +0300 Subject: [PATCH 05/10] sm_86 CUDA half float casts --- tinygrad/renderer/cstyle.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tinygrad/renderer/cstyle.py b/tinygrad/renderer/cstyle.py index 3035395f96beb..104963b626454 100644 --- a/tinygrad/renderer/cstyle.py +++ b/tinygrad/renderer/cstyle.py @@ -426,6 +426,8 @@ def __init__(self, target:Target, use_nvcc=False): type_map = {dtypes.uint32: "uint", dtypes.bfloat16: "nv_bfloat16", dtypes.fp8e4m3: "__nv_fp8_e4m3", dtypes.fp8e5m2: "__nv_fp8_e5m2"} extra_matcher = create_non_native_float_pats(dtypes.fp8s, casting=False) + PatternMatcher([ (UPat(Ops.CAST, dtypes.fp8s, UPat.var("x", dtypes.fp8s), name='y'), lambda x,y: x.cast(dtypes.float).cast(y.dtype) if x.dtype!=y.dtype else None), + (UPat(Ops.CAST, (dtypes.char, dtypes.uchar, dtypes.long), (UPat.var("x", dtypes.half),), name="y"), + lambda x,y: x.cast(dtypes.float).cast(y.dtype)), ]) string_rewrite = PatternMatcher([ (UPat(Ops.BITCAST, name="x"), lambda ctx,x: f"tg_bitcast<{ctx.render_dtype(x.dtype)}>(({ctx.render_dtype(x.src[0].dtype)})({ctx[x.src[0]]}))" From 72c3147b521c859804982e920db9aaf33f3008b1 Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Fri, 28 Aug 2026 20:19:02 +0300 Subject: [PATCH 06/10] handle CUDA half casts to ulong and bfloat16 --- tinygrad/renderer/cstyle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinygrad/renderer/cstyle.py b/tinygrad/renderer/cstyle.py index 104963b626454..793af0d372d0c 100644 --- a/tinygrad/renderer/cstyle.py +++ b/tinygrad/renderer/cstyle.py @@ -426,7 +426,7 @@ def __init__(self, target:Target, use_nvcc=False): type_map = {dtypes.uint32: "uint", dtypes.bfloat16: "nv_bfloat16", dtypes.fp8e4m3: "__nv_fp8_e4m3", dtypes.fp8e5m2: "__nv_fp8_e5m2"} extra_matcher = create_non_native_float_pats(dtypes.fp8s, casting=False) + PatternMatcher([ (UPat(Ops.CAST, dtypes.fp8s, UPat.var("x", dtypes.fp8s), name='y'), lambda x,y: x.cast(dtypes.float).cast(y.dtype) if x.dtype!=y.dtype else None), - (UPat(Ops.CAST, (dtypes.char, dtypes.uchar, dtypes.long), (UPat.var("x", dtypes.half),), name="y"), + (UPat(Ops.CAST, (dtypes.char, dtypes.uchar, dtypes.long, dtypes.ulong, dtypes.bfloat16), (UPat.var("x", dtypes.half),), name="y"), lambda x,y: x.cast(dtypes.float).cast(y.dtype)), ]) string_rewrite = PatternMatcher([ From b6aaa1462f7fc717d9de79e596390b29297e25c8 Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Fri, 28 Aug 2026 21:36:02 +0300 Subject: [PATCH 07/10] half floats in cuda 12 bulk fixes. --- tinygrad/renderer/cstyle.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tinygrad/renderer/cstyle.py b/tinygrad/renderer/cstyle.py index 793af0d372d0c..55223ab9f68f8 100644 --- a/tinygrad/renderer/cstyle.py +++ b/tinygrad/renderer/cstyle.py @@ -428,6 +428,14 @@ def __init__(self, target:Target, use_nvcc=False): (UPat(Ops.CAST, dtypes.fp8s, UPat.var("x", dtypes.fp8s), name='y'), lambda x,y: x.cast(dtypes.float).cast(y.dtype) if x.dtype!=y.dtype else None), (UPat(Ops.CAST, (dtypes.char, dtypes.uchar, dtypes.long, dtypes.ulong, dtypes.bfloat16), (UPat.var("x", dtypes.half),), name="y"), lambda x,y: x.cast(dtypes.float).cast(y.dtype)), + (UPat(Ops.CAST, dtypes.half, (UPat.var("x", (dtypes.long, dtypes.ulong, dtypes.bfloat16)),)), + lambda x: x.cast(dtypes.float).cast(dtypes.half)), + (UPat(Ops.CAST, (dtypes.char, dtypes.uchar), (UPat.var("x", dtypes.bfloat16),), name="y"), + lambda x,y: x.cast(dtypes.float).cast(y.dtype)), + (UPat(Ops.CAST, (dtypes.long, dtypes.ulong), (UPat.var("x", dtypes.bfloat16),), name="y"), + lambda x,y: x.cast(dtypes.float).cast(y.dtype)), + (UPat(Ops.CAST, dtypes.bfloat16, (UPat.var("x", (dtypes.long, dtypes.ulong)),)), + lambda x: x.cast(dtypes.float).cast(dtypes.bfloat16)), ]) string_rewrite = PatternMatcher([ (UPat(Ops.BITCAST, name="x"), lambda ctx,x: f"tg_bitcast<{ctx.render_dtype(x.dtype)}>(({ctx.render_dtype(x.src[0].dtype)})({ctx[x.src[0]]}))" From 9a57f5dd58236f7a365d238d54a7d3373c8b3662 Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Sun, 30 Aug 2026 19:56:36 +0300 Subject: [PATCH 08/10] ci: use GPUOcelot CUDA 12 v2 release --- .github/actions/setup-tinygrad/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index 120af5fa4ba1d..12e2074a564d1 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -262,7 +262,7 @@ runs: shell: bash run: | sudo mkdir -p /usr/local/lib - sudo curl --output-dir /usr/local/lib -fLO https://github.com/li0nr/gpuocelot/releases/download/cuda-12-support/libgpuocelot.${{ runner.os == 'Linux' && 'so' || 'dylib' }} + sudo curl --output-dir /usr/local/lib -fLO https://github.com/li0nr/gpuocelot/releases/download/cuda-12-support-v2/libgpuocelot.${{ runner.os == 'Linux' && 'so' || 'dylib' }} # **** WebGPU **** From 43294c8e072969cffe9ce67a4ad2847e613df2df Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Sun, 30 Aug 2026 23:29:43 +0300 Subject: [PATCH 09/10] ci: use CUDA 12 and GPUOcelot sm86 --- .github/actions/setup-tinygrad/action.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index 12e2074a564d1..cd5ee0e17f45c 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -250,11 +250,15 @@ runs: if: inputs.cuda == 'true' shell: bash run: | - sudo mkdir -p /usr/local/cuda/targets/x86_64-linux - curl -fL https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/linux-x86_64/cuda_nvrtc-linux-x86_64-12.9.86-archive.tar.xz \ - | sudo tar -xJ -C /usr/local/cuda/targets/x86_64-linux --strip-components=1 - echo /usr/local/cuda/targets/x86_64-linux/lib | sudo tee /etc/ld.so.conf.d/cuda-nvrtc.conf - sudo ldconfig + cuda_root=/usr/local/cuda/targets/x86_64-linux + sudo mkdir -p "$cuda_root" + for archive in \ + cuda_nvrtc-linux-x86_64-12.9.86-archive.tar.xz \ + cuda_cudart-linux-x86_64-12.9.37-archive.tar.xz; do + curl -fL "https://developer.download.nvidia.com/compute/cuda/redist/${archive%%-linux-x86_64-*}/linux-x86_64/$archive" \ + | sudo tar -xJ -C "$cuda_root" --strip-components=1 + done + printf 'CUDA_PATH=%s\nLD_LIBRARY_PATH=%s%s\n' "$cuda_root" "$cuda_root/lib" "${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV" # **** gpuocelot **** - name: Install gpuocelot @@ -262,7 +266,7 @@ runs: shell: bash run: | sudo mkdir -p /usr/local/lib - sudo curl --output-dir /usr/local/lib -fLO https://github.com/li0nr/gpuocelot/releases/download/cuda-12-support-v2/libgpuocelot.${{ runner.os == 'Linux' && 'so' || 'dylib' }} + sudo curl --output-dir /usr/local/lib -fLO https://github.com/li0nr/gpuocelot/releases/download/cuda-12-support-sm86/libgpuocelot.${{ runner.os == 'Linux' && 'so' || 'dylib' }} # **** WebGPU **** From 7b1883cf0b68a7db1920a838553aa4b550e1cdd5 Mon Sep 17 00:00:00 2001 From: Ramy Fakhoury Date: Sun, 30 Aug 2026 23:51:24 +0300 Subject: [PATCH 10/10] ci: keep existing CUDA library setup --- .github/actions/setup-tinygrad/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index cd5ee0e17f45c..3ed15c4ab7f47 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -258,7 +258,9 @@ runs: curl -fL "https://developer.download.nvidia.com/compute/cuda/redist/${archive%%-linux-x86_64-*}/linux-x86_64/$archive" \ | sudo tar -xJ -C "$cuda_root" --strip-components=1 done - printf 'CUDA_PATH=%s\nLD_LIBRARY_PATH=%s%s\n' "$cuda_root" "$cuda_root/lib" "${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV" + echo "CUDA_PATH=$cuda_root" >> "$GITHUB_ENV" + echo "$cuda_root/lib" | sudo tee /etc/ld.so.conf.d/cuda-nvrtc.conf + sudo ldconfig # **** gpuocelot **** - name: Install gpuocelot