Skip to content

gpuocelot cuda12 sm 86 - #17856

Open
li0nr wants to merge 15 commits into
tinygrad:masterfrom
li0nr:cuda12-sm86
Open

gpuocelot cuda12 sm 86#17856
li0nr wants to merge 15 commits into
tinygrad:masterfrom
li0nr:cuda12-sm86

Conversation

@li0nr

@li0nr li0nr commented Aug 30, 2026

Copy link
Copy Markdown

This PR uses the GPUOcelot CUDA 12 sm86 release (which is the main change), adds CUDA 12 NVRTC/runtime header setup.

Gpuocelot add support to cuda12 and sm_50 and sm_86.

at the beginng i just wanted for gpuocelot to run with cuda-12 with minimal arch support sm_50.
Changes where small we can see it in this branch https://github.com/li0nr/tinygrad/commits/gpuocelot-cuda-12.
if it is safer we can go this route.

The next best thing (to be bounty worthy) was supporting sm_86 arch in gpuocelot.

this needs to be modfied after we merge the ocelot branch to the tinygrad repo.
tinygrad/gpuocelot#12 / https://github.com/li0nr/gpuocelot/tree/cuda-12-sm86

CI: li0nr#2

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I neede to add this bc of failures like this https://github.com/li0nr/tinygrad/actions/runs/33324336717/job/99291747648,
maybe bc of this condition if (nvrtcMajor.value, nvrtcMinor.value) >= (12, 4): self.compile_options.append("--minimal")
If there is any cleaner way of doing this, I can change

name='/usr/local/lib/libgpuocelot.${{ runner.os == 'Linux' && 'so' || 'dylib' }}',
sha256='${{ runner.os == 'Linux' && 'a24705276a9a187111371465987b3258f8836ef512a34266e3075bc4714e125a' || '5106c998c795a36dec79eb7b2aae324a93d1338236d36eeaae232649ec457663' }}').chmod(0o644)"
sudo mkdir -p /usr/local/lib
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' }}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we approve the changes to ocelot, I will change this to be more offical release ....

@geohot geohot closed this Aug 31, 2026
@geohot geohot reopened this Aug 31, 2026
@geohot

geohot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Tests passing? You need to remove those matchers from cstyle, it needs to work on 100% of SM86 PTX.

@li0nr

li0nr commented Aug 31, 2026

Copy link
Copy Markdown
Author

yep tests are passing.

the matchers are for sm86, the cuda cpp generated code is being rejected by the new nvrtc, for example :

  *(data0_16 + alu0) = ((long)(alu3));

  Exact NVRTC error:

  <null>(26): error: more than one conversion function from "half" (aka "__half") to "long" applies:
      function "__half::operator float() const"
      function "__half::operator short() const"
      function "__half::operator unsigned short() const"
      function "__half::operator int() const"
      function "__half::operator unsigned int() const"
      function "__half::operator long long() const"
      function "__half::operator unsigned long long() const"
      function "__half::operator __nv_bool() const"

  *(data0_16+(alu0+1)) = ((long)(alu6));
                                ^
  4 errors detected in the compilation of "<null>".

or maybe i did not understand your point.

running the full test suite with sm86 with these matchers is passing.

@geohot

geohot commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

You don't need the matchers for 3090/4090/5090, what version is that?

@li0nr

li0nr commented Sep 2, 2026

Copy link
Copy Markdown
Author

I chose the SM86 specifaclly because it matches 3090 according to this https://developer.nvidia.com/cuda/gpus.
I will try to targeting 4090/5090 sm. As well as testing cuda11 with sm_86.

@li0nr

li0nr commented Sep 2, 2026

Copy link
Copy Markdown
Author

found the issue, I was not using the correct cuda_cudart, in my linux env.
I will clean the matcher.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This branch currently is behind tinygrad/master. The line count difference bot is disabled.

@li0nr

li0nr commented Sep 3, 2026

Copy link
Copy Markdown
Author

cleaned up and remvoed the matchers, tests are passing in both modes:
DEV=MOCK+CUDA:CUDA
DEV=MOCK+CUDA:PTX

Comment thread test/mockgpu/cuda/cuda.py Outdated
return orig_cuda.CUDA_ERROR_INVALID_VALUE
device._obj.value = ordinal
cuda_state.devices[ordinal] = {"compute_capability": (3, 5)}
cuda_state.devices[ordinal] = {"compute_capability": (8, 6)}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this work the same way MOCK+AMD::<arch> does?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like this ?

gpu_arch = int(MOCKGPU_ARCH[3:])
cuda_state.devices[ordinal] = {"compute_capability": divmod(gpu_arch, 10)}

i have added a commit

@geohot geohot added the bounty locked Bounty is locked to someone label Sep 7, 2026
@geohot

geohot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Are you confident the GPUOcelot port is complete, or did you just target making the tests pass?

@geohot

geohot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Bounty locked to you, let's get this merged first. tinygrad/gpuocelot#12

@li0nr

li0nr commented Sep 7, 2026

Copy link
Copy Markdown
Author

So my apprach was running tinygrad with the ocelot and list all the stuff we needed to support.
I will look at the MR there and address stuff.
Do we need/want to support everyting sm86 needs or just partial stuff?

@geohot

geohot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

We need everything in sm86! tinygrad may change and we need an emulator we can rely on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bounty locked Bounty is locked to someone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants