Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Triton language #5531

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

siboehm
Copy link

@siboehm siboehm commented Sep 29, 2023

This closes #5530.

From my POV, this is what's still TODO (would be happy about any input on these):

  1. Add Triton installation (from source) to CE infra repo.
  2. Adjust the path to Triton's compile.py script. It's hardcoded to work on my local machine right now.
  3. Make sure the nvdisasm path in properties is correct. I was following nvcc, but not sure I got it right.
  4. Is there any way to set default compiler flags for the default example.py? It will not compile without setting -n kernel --signature "*fp32:16, *fp16:16, *fp16:16, i32, 1024" -w 1 -g "M/16, 1, 1". That's not mandatory I guess and users would figure it out eventually from the error messages, but it'd make the experience a little nicer.

Lmk if you want me to move the doc stuff into a separate PR.

lib/compilers/triton.ts Outdated Show resolved Hide resolved
@siboehm
Copy link
Author

siboehm commented Sep 30, 2023

Adding Triton properly requires conda env support on CE infra. Matt mentioned he'd been meaning to add it, but this PR will probably be blocked until then.

If anyone wants to try this locally:

  1. Create conda env with torch + python + triton>=2.1
  2. adjust triton.defaults.properties to make sure python / nvdiasms / triton compile script path is correct
  3. make dev EXTRA_ARGS="--debug --language triton"

defaultCompiler=tritonHEAD

compiler.tritonHEAD.name=Triton (HEAD)
compiler.tritonHEAD.exe=/home/simon/mambaforge/envs/tritonNightly/bin/python
Copy link

Choose a reason for hiding this comment

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

should be /home/ce?

Copy link
Member

Choose a reason for hiding this comment

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

Defaults are whatever make sense as a default. I'm not any /home/ is a sensible default, but I'm also not sure what else to suggest here. Typically we refer in the defaults to things like /usr/bin/gcc etc, where compilers are (probably) installed. It's expected users will override in their *.local.properties, and the triton.amazon.properties will be completely different (referring to something in /opt/compiler-explorer/... somewhere)

Copy link
Author

Choose a reason for hiding this comment

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

I picked this default since I was hoping it makes it very obvious what it should be set to in the *.local.properties. I don't think it's common to have a package like Triton be installed globally using the system Python, but happy to take suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

I'd go with just triton or leave it unset entirely to make it error. But not a big deal really.

@siboehm
Copy link
Author

siboehm commented Oct 5, 2023

Ok I dug a bit deeper into the Triton codebase, and the "jit-ness" is really ingrained, in the sense that turning Triton into a cross-compiler is a fairly big refactoring, because it issues calls like torch.cuda.get_device_info() all over the place to retrieve things like SMEM size, even when running in AOT mode.

Running CE locally will still be pretty useful to many (like me) for figuring out what Triton is doing. I don't know how others feel about having compilers in the CE main repo that only run locally.

The other option would be to make sure Triton only ever runs on the GPU CE instances, and somehow make it clear to users that it cannot cross-compile and hence always targets the native GPU, and that they have to run a local instance themselves to fix that.

@mattgodbolt
Copy link
Member

From Discord, worth looking in to https://github.com/conda/conda-pack (noted by @siboehm as a potential help for installation)

@partouf
Copy link
Contributor

partouf commented May 29, 2024

I think we can merge this PR as is, as long as it doesn't break anything. It won't add the language to the website, but people will still be able to try it out.

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

Successfully merging this pull request may close these issues.

[LANGUAGE REQUEST]: Triton
4 participants