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

Triton #6798

Merged
merged 67 commits into from
Jun 7, 2024
Merged

Triton #6798

Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
6dccf0a
Update infra_triggers.tf
ManfeiBai Oct 4, 2023
9828123
Skeleton trition support
bhavya01 Mar 20, 2024
99bf48d
Merge branch 'master' into triton
bhavya01 Mar 20, 2024
b89e558
Fix bugs
bhavya01 Mar 21, 2024
64189bd
Fix custom call invocation
bhavya01 Mar 21, 2024
0c208ef
Refactor to include gpu custom call and create triton dir
bhavya01 Mar 22, 2024
b553ba7
Lint fixes
bhavya01 Mar 22, 2024
c5129e6
python lint fix
bhavya01 Mar 22, 2024
48e7127
Updated base image for CI
bhavya01 Mar 27, 2024
e04fc97
Update github workflow gcr image
bhavya01 Mar 28, 2024
37bf127
Merge branch 'master' into custom
bhavya01 Mar 28, 2024
6061895
Remove xrt build and test file
bhavya01 Mar 28, 2024
f59ddbf
Add temporary test to run triton kernel
bhavya01 Mar 28, 2024
158aed4
Fix tests
bhavya01 Mar 28, 2024
87b92c5
Update payload for xla gpu custom call
bhavya01 Mar 29, 2024
847ccc5
Update gpu runner
bhavya01 Mar 29, 2024
eca6d52
Merge branch 'master' into triton
bhavya01 Apr 4, 2024
2348ca3
Extract payload from triton kernel programatically
bhavya01 Apr 12, 2024
110c8c6
Merge branch 'master' into triton
bhavya01 Apr 12, 2024
a226150
Lint fixes
bhavya01 Apr 12, 2024
4c1f4f5
Only build triton files for GPU
bhavya01 Apr 12, 2024
431f822
build pytorch for ampere gpus
bhavya01 Apr 13, 2024
4bade16
c++ lint fix
bhavya01 Apr 13, 2024
1c5b47d
Python lint fix
bhavya01 Apr 13, 2024
3138a92
Fix torch cuda arch list
bhavya01 Apr 13, 2024
3f00cfd
Use a bigger machine for CI build
bhavya01 Apr 13, 2024
e729cfb
Add triton test to run_tests.sh
bhavya01 Apr 13, 2024
8e304c0
Update triton env variable
bhavya01 Apr 15, 2024
27bdc3a
Set up a separate CI for triton tests
bhavya01 Apr 15, 2024
9a3ef84
Fix github workflow to add _triton.yml
bhavya01 Apr 15, 2024
ade444d
Rebuild torch xla for triton tests
bhavya01 Apr 15, 2024
cb0bb85
Create a separate CI tab for triton tests
bhavya01 Apr 16, 2024
015b1ad
Separate build and test phase for triton
bhavya01 Apr 16, 2024
a18028a
Fix flags for docker run container
bhavya01 Apr 16, 2024
993ee92
Update triton.yml to output docker image
bhavya01 Apr 16, 2024
a87b782
Add a python binding to register custom calls and remove jax files
bhavya01 May 10, 2024
bf05d1b
Fix lint
bhavya01 May 10, 2024
4582fe8
Merge main
bhavya01 May 10, 2024
9680167
Merge master
bhavya01 May 10, 2024
a7b94c6
Merge master after updating
bhavya01 May 10, 2024
e14636a
Update CI to use cuda plugin
bhavya01 May 10, 2024
256d819
Install jaxlib while setting up triton tests
bhavya01 May 10, 2024
c616e64
Install triton package while running triton tests
bhavya01 May 10, 2024
60b8d18
Experimental: Build pytorch with cuda
bhavya01 May 13, 2024
2bde624
Revert build pytorch with CUDA
bhavya01 May 14, 2024
e6c4e0a
Merge branch 'master' into triton
bhavya01 May 14, 2024
14ee545
Remove ansible path for triton CI
bhavya01 May 14, 2024
25acb26
Style fixes
bhavya01 May 20, 2024
6b0ac18
[Experimental] test new CI
bhavya01 May 28, 2024
4d97150
[Experimental] Set XLA_CUDA=0 for cuda arch in ansible
bhavya01 May 28, 2024
e079049
[Experimental] Update CI to build pytorch cuda with ansible
bhavya01 May 29, 2024
d9c89b6
Update CI
bhavya01 May 30, 2024
7a6c809
Fix CI workflow file
bhavya01 May 30, 2024
6b1954d
Fix CI workflow
bhavya01 May 30, 2024
21797a6
Fix the wheels installed for tests requiring torch cuda
bhavya01 May 30, 2024
e6e89d3
Add compute_capability=8.6 for xla cuda plugin
bhavya01 May 31, 2024
ac45fe1
update TORCH_CUDA_ARCH_LIST
bhavya01 May 31, 2024
f828fbb
Experimental build torch and torch_xla cuda wheels
bhavya01 May 31, 2024
ac56c00
Merge branch 'master' into triton
bhavya01 May 31, 2024
c3b8653
Update build_and_test.yml
bhavya01 May 31, 2024
a1168c6
Update dlpack test to only use one device
bhavya01 May 31, 2024
39551a2
Remove compute capability 8.6 from cuda plugin
bhavya01 May 31, 2024
35e0869
Remove triton.sh
bhavya01 May 31, 2024
f95d898
Default empty torch_cuda_arch_list in ansible config
bhavya01 May 31, 2024
291104d
Merge branch 'master' into triton
bhavya01 Jun 5, 2024
f5c9b1a
Revert CI changes
bhavya01 Jun 6, 2024
5b23969
Revert CI changes pt2
bhavya01 Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bazel/rules_def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load(
"@xla//xla:xla.bzl",
"xla_cc_test",
)
load("@rules_cc//cc:defs.bzl", _cc_proto_library = "cc_proto_library")

def ptxla_cc_library(
deps = [],
Expand Down Expand Up @@ -38,3 +39,4 @@ def ptxla_cc_test(
],
**kwargs
)
cc_proto_library = _cc_proto_library
26 changes: 26 additions & 0 deletions test/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,32 @@ def foo(x):
for dtype in test_dtypes:
test(dtype)

@unittest.skipIf(xr.device_type() != 'CUDA', "This test only works on GPU.")
def test_gpu_custom_call_triton(self):
# This payload is generated by the following Triton code:
# import triton
# import triton.language as tl
# @triton.jit
# def add_kernel(x_ptr, y_ptr, length, output_ptr, block_size: tl.constexpr,
# ):
# """Adds two vectors."""
# pid = tl.program_id(axis=0)
# block_start = pid * block_size
# offsets = block_start + tl.arange(0, block_size)
# mask = offsets < length
# x = tl.load(x_ptr + offsets, mask=mask)
# y = tl.load(y_ptr + offsets, mask=mask)
# output = x + y
# tl.store(output_ptr + offsets, output, mask=mask)
payload = b'x\x9c\xcdW]o\xdb6\x14E\x8b=\xcc|\n\xb6\x87\xf5\x91\xebf \xce\\\x99\xa4>,\xb9iP\x0c\x18\xf6\xb0\xae\xd8CQ\x0c\x18\nA\xb6\x98D\xa8,i\x12\x9d%3\xfc?\xf6#\xf6\xbe_\xb1\xff\xb4KR\x92E\xc5v\xd2`\x05\n\x18\xb2uy\xee9\xf7\x1e\x92\x12\x8d\xfe9A\x7f\x9d\xa0/\xa38\x0e\xdf\xf32\xe3iHb\x1a3n\xc7G\x9f=\xfd\xf7\xab\xc9\x04M&\xf8G\x9e\xf12\x12<\xc6\xf3\x1b\xfc\xea\xd5\xdb\x9f\xf1\xeb\xb7\xbf\xbc\xf9\x15\x7f\x1f-\xde?\xfb!\x8b\x01\x83\x90u\xc5\xcb*\xc93\xec[\x0cY"*/\xb8\xc0\xd52\x9c\xba\xc8\x02\xfa\x92WUX%\x7fr\xec9\x08\r\x80\xd5\xbaH\xf3y:\xd8!-\xc9\x92*\x99\xa7\x1c[<\x13\xe5\r\xde\x01:F\x03\xab\x88\xcah\x89\xad\x95\xe7\xecB\x84j8$\xe3\xfb"i\x17i\xb3\x03HvoN\x1b\x8d\x90\xb5\x8c\xae3\x91\xc4\x982\x7f\x8c)|\xd0\x1a\xf2K~\x81\xad\xa2\x04[\x07\xc3\xe2\xd4={\xde\xc4\xe6\xa0=\x18\x96\xa7\x94vb\xa0\x02\xb1\xf8\xd4W\xb14_\x0c(\xf60A\xdf\xbe\n\xc3\xf3U\xb6\x08\xe7\xfc"\xc9\xc8\xcc\x18D\x834\xd6u\xaa2%\x813\xc6\xbf\x1d0\xeb\xdd\xf3\x1d9\xee\xc1\x1c\n9\xb2\n\xb1,:\xf2\xd4\xc3v\x80\x06\xcb\xfcJy\t4\xc02\x04\x17\xack\x90\x88\xb2X\xb5)\xe3\x1e\xc4\xe5\xe0\xd4\x90\xd69\xd3\x83\xcal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b\x9eUyy\xea_\xc3\xfdYKi\xd7\x94\xb6\xa6\xac\x8a4\x12\xb2\xa2\x19>\x06\xdc\x08?;\xdb\x93\xe8\xd4\x89N[<,R(^\x1e\xcd\xd8^\xb9&\xcb5\xe4\xe4\n\xb9[\xd1\xads\xbd\xad\xb3\xcb"\xc1U*@R\x1e\x06\xdd\xbd\xb2M\xea\xb4/+\xfd9\xee\xad\'\xb3\x84\xde\xe0\x96\xd3\xab9}\xcd\t\xdd\x03\x0c$d1\xddB\xfa\x04\xe3=56|\x81\xe6K\xf3(\x06\xf2\xb1\xecw\xbd\x88\x16\x97rU\xd2f~\xf9U\xb2\x10\xdd@R\xbd\xcd\xa1)8\xaen\x17\xef>7\xa6\xcd\xba#};\xe8\xc3\xed\xf0\x1bRj\xfa\xa1\x8e\xf8\x0f2\xa4ed]G(\xfd\x18\x96\x04\x8d\x96\xdd[\xce\xf2\xef!\xdd\xbf\x9e)i\x12\x9d\xbe\x97\xf6\xc3\xbd\xa4\xcd\x93\x84\xba=3\x9d\x87\x9a\xd9P\xca\x12E^r\xc9-[\xb3\xef\xe7\xe6~\xe7(k\x89\xe1\xff\xd4\xaa\xcc\xb6#\xea\xd9\xb2i\xefG\xa8\xfb[!\x0e\xbe\x14\xa93cL\x03\xd9a\xa0\xdb\x02\xed\xc3@of\x07\x1a\xe8\xdc\x05d\x9e\x06\xba\x87\x81\xd3\x19\xad\x19\xbd\xc3@\xbf\xadqz\x17\x90:\x1a\xe8\x1f\x06\x06-cp\x17\xb0aT;~?\x92\x11\xf0\xb2F\x1e\x9e\x1bFg\xac\xe1<<9\x80\xb4\xed\x1ayxv$\xe7\x08\x91\x9f\x8e\x1e=y\x84\x1f\x9d|\x86\x1e\x1f\x1d\xd5\xd7\xc7O>\xd7\xbf\xfe\x03\x97\x03\xa4b'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I expect we have more than one test kernel going fwd - wdyt we put all kernel payloads for Triton (and Pallas) in a separate yaml file?

cc @jiawenliu64

x = torch.arange(8, dtype=torch.int).to("xla")
y = torch.arange(8, dtype=torch.int).to("xla")
expected_output = x + y
output = torch.arange(8, dtype=torch.int).to("xla")

torch_xla._XLAC._xla_gpu_custom_call_(output, [x, y], payload)
self.assertTrue(torch.allclose(output.cpu(), expected_output.cpu()))


class MNISTComparator(nn.Module):

Expand Down
1 change: 1 addition & 0 deletions torch_xla/csrc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ ptxla_cc_library(
":dtype",
":tensor",
":version",
"//torch_xla/csrc/triton:triton_kernels",
"//torch_xla/csrc/runtime",
"//torch_xla/csrc/runtime:metrics",
"//torch_xla/csrc/runtime:metrics_analysis",
Expand Down
7 changes: 7 additions & 0 deletions torch_xla/csrc/init_python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,13 @@ void InitXlaModuleBindings(py::module m) {
return tensor_methods::tpu_custom_call_(
x_output, bridge::GetXlaTensors(inputs), payload);
});
m.def("_xla_gpu_custom_call_",
[](at::Tensor& output, const std::vector<at::Tensor>& inputs,
const std::string& payload) {
auto x_output = bridge::GetXlaTensor(output);
return tensor_methods::gpu_custom_call_(
x_output, bridge::GetXlaTensors(inputs), payload);
});
m.def("_set_xla_custom_op_name_prefix",
[](const at::Tensor& input, const std::string& op_name_prefix,
size_t max_call_stack_depth) -> bool {
Expand Down
36 changes: 36 additions & 0 deletions torch_xla/csrc/ops/gpu_custom_call.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "torch_xla/csrc/ops/gpu_custom_call.h"

#include "torch_xla/csrc/lowering_context.h"
#include "torch_xla/csrc/ops/xla_ops.h"
#include "torch_xla/csrc/xla_lower_util.h"

namespace torch_xla {

GpuCustomCall::GpuCustomCall(torch::lazy::OpList inputs,
xla::Shape output_shape,
const std::string& payload)
: XlaNode(xla_gpu_custom_call, inputs, std::move(output_shape),
/*num_outputs=*/1, torch::lazy::MHash(payload)),
payload_(payload) {}

torch::lazy::NodePtr GpuCustomCall::Clone(torch::lazy::OpList operands) const {
return torch::lazy::MakeNode<GpuCustomCall>(operands, xla_shape(), payload_);
}

XlaOpVector GpuCustomCall::Lower(LoweringContext* loctx) const {
std::vector<xla::XlaOp> inputs;
inputs.reserve(operands().size());
for (auto& operand : operands()) {
inputs.push_back(loctx->GetOutputOp(operand));
}
xla::XlaOp output = BuildGpuCustomCall(inputs, xla_shape(), payload_);
return ReturnOp(output, loctx);
}

std::string GpuCustomCall::ToString() const {
std::stringstream ss;
ss << XlaNode::ToString() << ", " << payload_;
return ss.str();
}

} // namespace torch_xla
26 changes: 26 additions & 0 deletions torch_xla/csrc/ops/gpu_custom_call.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef XLA_TORCH_XLA_CSRC_OPS_GPU_CUSTOM_CALL_H_
#define XLA_TORCH_XLA_CSRC_OPS_GPU_CUSTOM_CALL_H_

#include "torch_xla/csrc/ir.h"

namespace torch_xla {
// TODO: Merge GPU and TPU custom call.
bhavya01 marked this conversation as resolved.
Show resolved Hide resolved
class GpuCustomCall : public XlaNode {
public:
// Make a GPU custom call with payload, e.g., Triton.
GpuCustomCall(torch::lazy::OpList inputs, xla::Shape output_shape,
const std::string& payload);

torch::lazy::NodePtr Clone(torch::lazy::OpList operands) const override;

XlaOpVector Lower(LoweringContext* loctx) const override;

std::string ToString() const override;

private:
std::string payload_;
};

} // namespace torch_xla

#endif // XLA_TORCH_XLA_CSRC_OPS_GPU_CUSTOM_CALL_H_
1 change: 1 addition & 0 deletions torch_xla/csrc/ops/xla_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ const OpKindWrapper xla_unselect("xla::unselect");
const OpKindWrapper xla_update_slice("xla::update_slice");
const OpKindWrapper xla_custom_sharding("xla::custom_sharding");
const OpKindWrapper xla_tpu_custom_call("xla::tpu_custom_call");
const OpKindWrapper xla_gpu_custom_call("xla::gpu_custom_call");

} // namespace torch_xla
1 change: 1 addition & 0 deletions torch_xla/csrc/ops/xla_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extern const OpKindWrapper xla_unselect;
extern const OpKindWrapper xla_update_slice;
extern const OpKindWrapper xla_custom_sharding;
extern const OpKindWrapper xla_tpu_custom_call;
extern const OpKindWrapper xla_gpu_custom_call;

} // namespace torch_xla

Expand Down
12 changes: 12 additions & 0 deletions torch_xla/csrc/tensor_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "torch_xla/csrc/ops/generic.h"
#include "torch_xla/csrc/ops/generic_slice.h"
#include "torch_xla/csrc/ops/get_dimensions_size.h"
#include "torch_xla/csrc/ops/gpu_custom_call.h"
#include "torch_xla/csrc/ops/hardtanh_backward.h"
#include "torch_xla/csrc/ops/index_ops.h"
#include "torch_xla/csrc/ops/index_select.h"
Expand Down Expand Up @@ -526,6 +527,17 @@ void custom_sharding_(
input->SetShardingSpec(*sharding_spec);
}

void gpu_custom_call_(XLATensorPtr& output,
const std::vector<XLATensorPtr>& inputs,
const std::string& payload) {
std::vector<torch::lazy::Value> values;
for (const auto& input : inputs) {
values.push_back(input->GetIrValue());
}
output->SetInPlaceIrValue(torch::lazy::MakeNode<GpuCustomCall>(
values, output->shape().get(), payload));
}

void tpu_custom_call_(XLATensorPtr& output,
const std::vector<XLATensorPtr>& inputs,
const std::string& payload) {
Expand Down
4 changes: 4 additions & 0 deletions torch_xla/csrc/tensor_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ std::pair<XLATensorPtr, torch::lazy::Value> collective_permute(
void custom_sharding_(const XLATensorPtr& input,
const std::shared_ptr<XLATensor::ShardingSpec>& spec);

void gpu_custom_call_(XLATensorPtr& output,
const std::vector<XLATensorPtr>& inputs,
const std::string& payload);

void tpu_custom_call_(XLATensorPtr& output,
const std::vector<XLATensorPtr>& inputs,
const std::string& payload);
Expand Down
93 changes: 93 additions & 0 deletions torch_xla/csrc/triton/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
load("//bazel:rules_def.bzl","cc_proto_library",)

cc_library(
name = "cuda_vendor",
hdrs = [
"gpu_vendor.h",
],
deps = [
"@local_config_cuda//cuda:cuda_headers",
"@local_config_cuda//cuda:cudnn_header",
],
)

proto_library(
name = "triton_proto",
srcs = ["triton.proto"],
)

cc_proto_library(
name = "triton_cc_proto",
deps = [":triton_proto"],
)

cc_library(
name = "cuda_gpu_kernel_helpers",
srcs = [
"gpu_kernel_helpers.cpp",
],
hdrs = [
"gpu_kernel_helpers.h",
],
copts = [
"-fexceptions",
],
features = ["-use_header_modules"],
deps = [
":cuda_vendor",
"@xla//xla/tsl/cuda:cupti",
"@xla//xla/tsl/cuda:cusolver",
"@xla//xla/tsl/cuda:cusparse",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@local_config_cuda//cuda:cublas_headers",
"@local_config_cuda//cuda:cuda_headers",
],
)

cc_library(
name = "triton_utils",
srcs = ["triton_utils.cpp"],
hdrs = ["triton_utils.h"],
visibility = ["//visibility:public"],
deps = [
":cuda_gpu_kernel_helpers",
":cuda_vendor",
":triton_cc_proto",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@zlib",
],
)

cc_library(
name = "triton_kernels",
srcs = ["triton_kernels.cpp"],
hdrs = ["triton_kernels.h"],
deps = [
":cuda_gpu_kernel_helpers",
":cuda_vendor",
":triton_utils",
":triton_cc_proto",
"@xla//xla/service:custom_call_target_registry",
"@xla//xla/service:custom_call_status",
"@xla//xla/stream_executor/gpu:asm_compiler",
"@xla//xla/tsl/cuda:cudart",
"@tsl//tsl/platform:env",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
],
)
Loading
Loading