triton-windows 3.2.0.post11__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of triton-windows might be problematic. Click here for more details.
- triton/_C/libtriton.pyd +0 -0
- triton/__init__.py +85 -0
- triton/_internal_testing.py +123 -0
- triton/backends/__init__.py +50 -0
- triton/backends/amd/compiler.py +368 -0
- triton/backends/amd/driver.c +211 -0
- triton/backends/amd/driver.py +512 -0
- triton/backends/amd/include/hip/amd_detail/amd_channel_descriptor.h +358 -0
- triton/backends/amd/include/hip/amd_detail/amd_device_functions.h +1031 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_atomic.h +1612 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_bf16.h +1337 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_bfloat16.h +293 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_common.h +32 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_complex.h +174 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_cooperative_groups.h +829 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_fp16.h +1809 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_gl_interop.h +108 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_math_constants.h +124 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_runtime.h +405 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_runtime_pt_api.h +196 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_unsafe_atomics.h +565 -0
- triton/backends/amd/include/hip/amd_detail/amd_hip_vector_types.h +2226 -0
- triton/backends/amd/include/hip/amd_detail/amd_math_functions.h +104 -0
- triton/backends/amd/include/hip/amd_detail/amd_surface_functions.h +244 -0
- triton/backends/amd/include/hip/amd_detail/amd_warp_functions.h +494 -0
- triton/backends/amd/include/hip/amd_detail/concepts.hpp +30 -0
- triton/backends/amd/include/hip/amd_detail/device_library_decls.h +133 -0
- triton/backends/amd/include/hip/amd_detail/functional_grid_launch.hpp +218 -0
- triton/backends/amd/include/hip/amd_detail/grid_launch.h +67 -0
- triton/backends/amd/include/hip/amd_detail/grid_launch.hpp +50 -0
- triton/backends/amd/include/hip/amd_detail/grid_launch_GGL.hpp +26 -0
- triton/backends/amd/include/hip/amd_detail/helpers.hpp +137 -0
- triton/backends/amd/include/hip/amd_detail/hip_api_trace.hpp +1350 -0
- triton/backends/amd/include/hip/amd_detail/hip_assert.h +101 -0
- triton/backends/amd/include/hip/amd_detail/hip_cooperative_groups_helper.h +242 -0
- triton/backends/amd/include/hip/amd_detail/hip_fp16_gcc.h +254 -0
- triton/backends/amd/include/hip/amd_detail/hip_fp16_math_fwd.h +96 -0
- triton/backends/amd/include/hip/amd_detail/hip_ldg.h +100 -0
- triton/backends/amd/include/hip/amd_detail/hip_prof_str.h +10169 -0
- triton/backends/amd/include/hip/amd_detail/hip_runtime_prof.h +77 -0
- triton/backends/amd/include/hip/amd_detail/host_defines.h +180 -0
- triton/backends/amd/include/hip/amd_detail/hsa_helpers.hpp +102 -0
- triton/backends/amd/include/hip/amd_detail/macro_based_grid_launch.hpp +798 -0
- triton/backends/amd/include/hip/amd_detail/math_fwd.h +698 -0
- triton/backends/amd/include/hip/amd_detail/ockl_image.h +177 -0
- triton/backends/amd/include/hip/amd_detail/program_state.hpp +107 -0
- triton/backends/amd/include/hip/amd_detail/texture_fetch_functions.h +491 -0
- triton/backends/amd/include/hip/amd_detail/texture_indirect_functions.h +478 -0
- triton/backends/amd/include/hip/channel_descriptor.h +39 -0
- triton/backends/amd/include/hip/device_functions.h +38 -0
- triton/backends/amd/include/hip/driver_types.h +468 -0
- triton/backends/amd/include/hip/hip_bf16.h +36 -0
- triton/backends/amd/include/hip/hip_bfloat16.h +44 -0
- triton/backends/amd/include/hip/hip_common.h +100 -0
- triton/backends/amd/include/hip/hip_complex.h +38 -0
- triton/backends/amd/include/hip/hip_cooperative_groups.h +46 -0
- triton/backends/amd/include/hip/hip_deprecated.h +95 -0
- triton/backends/amd/include/hip/hip_ext.h +159 -0
- triton/backends/amd/include/hip/hip_fp16.h +36 -0
- triton/backends/amd/include/hip/hip_gl_interop.h +32 -0
- triton/backends/amd/include/hip/hip_hcc.h +24 -0
- triton/backends/amd/include/hip/hip_math_constants.h +36 -0
- triton/backends/amd/include/hip/hip_profile.h +27 -0
- triton/backends/amd/include/hip/hip_runtime.h +75 -0
- triton/backends/amd/include/hip/hip_runtime_api.h +8919 -0
- triton/backends/amd/include/hip/hip_texture_types.h +29 -0
- triton/backends/amd/include/hip/hip_vector_types.h +41 -0
- triton/backends/amd/include/hip/hip_version.h +17 -0
- triton/backends/amd/include/hip/hiprtc.h +421 -0
- triton/backends/amd/include/hip/library_types.h +78 -0
- triton/backends/amd/include/hip/math_functions.h +42 -0
- triton/backends/amd/include/hip/surface_types.h +63 -0
- triton/backends/amd/include/hip/texture_types.h +194 -0
- triton/backends/amd/include/hsa/Brig.h +1131 -0
- triton/backends/amd/include/hsa/amd_hsa_common.h +91 -0
- triton/backends/amd/include/hsa/amd_hsa_elf.h +436 -0
- triton/backends/amd/include/hsa/amd_hsa_kernel_code.h +269 -0
- triton/backends/amd/include/hsa/amd_hsa_queue.h +109 -0
- triton/backends/amd/include/hsa/amd_hsa_signal.h +80 -0
- triton/backends/amd/include/hsa/hsa.h +5729 -0
- triton/backends/amd/include/hsa/hsa_amd_tool.h +91 -0
- triton/backends/amd/include/hsa/hsa_api_trace.h +566 -0
- triton/backends/amd/include/hsa/hsa_ext_amd.h +3090 -0
- triton/backends/amd/include/hsa/hsa_ext_finalize.h +531 -0
- triton/backends/amd/include/hsa/hsa_ext_image.h +1454 -0
- triton/backends/amd/include/hsa/hsa_ven_amd_aqlprofile.h +488 -0
- triton/backends/amd/include/hsa/hsa_ven_amd_loader.h +667 -0
- triton/backends/amd/include/roctracer/ext/prof_protocol.h +107 -0
- triton/backends/amd/include/roctracer/hip_ostream_ops.h +4435 -0
- triton/backends/amd/include/roctracer/hsa_ostream_ops.h +1467 -0
- triton/backends/amd/include/roctracer/hsa_prof_str.h +3027 -0
- triton/backends/amd/include/roctracer/roctracer.h +779 -0
- triton/backends/amd/include/roctracer/roctracer_ext.h +81 -0
- triton/backends/amd/include/roctracer/roctracer_hcc.h +24 -0
- triton/backends/amd/include/roctracer/roctracer_hip.h +37 -0
- triton/backends/amd/include/roctracer/roctracer_hsa.h +112 -0
- triton/backends/amd/include/roctracer/roctracer_plugin.h +137 -0
- triton/backends/amd/include/roctracer/roctracer_roctx.h +67 -0
- triton/backends/amd/include/roctracer/roctx.h +229 -0
- triton/backends/amd/lib/ockl.bc +0 -0
- triton/backends/amd/lib/ocml.bc +0 -0
- triton/backends/compiler.py +304 -0
- triton/backends/driver.py +48 -0
- triton/backends/nvidia/__init__.py +0 -0
- triton/backends/nvidia/bin/ptxas.exe +0 -0
- triton/backends/nvidia/compiler.py +410 -0
- triton/backends/nvidia/driver.c +451 -0
- triton/backends/nvidia/driver.py +524 -0
- triton/backends/nvidia/include/cuda.h +24359 -0
- triton/backends/nvidia/lib/libdevice.10.bc +0 -0
- triton/backends/nvidia/lib/x64/cuda.lib +0 -0
- triton/compiler/__init__.py +4 -0
- triton/compiler/code_generator.py +1303 -0
- triton/compiler/compiler.py +430 -0
- triton/compiler/errors.py +51 -0
- triton/compiler/make_launcher.py +0 -0
- triton/errors.py +5 -0
- triton/language/__init__.py +294 -0
- triton/language/_utils.py +21 -0
- triton/language/core.py +2694 -0
- triton/language/extra/__init__.py +26 -0
- triton/language/extra/cuda/__init__.py +13 -0
- triton/language/extra/cuda/_experimental_tma.py +108 -0
- triton/language/extra/cuda/libdevice.py +1629 -0
- triton/language/extra/cuda/utils.py +109 -0
- triton/language/extra/hip/__init__.py +3 -0
- triton/language/extra/hip/libdevice.py +475 -0
- triton/language/extra/libdevice.py +786 -0
- triton/language/math.py +250 -0
- triton/language/random.py +207 -0
- triton/language/semantic.py +1796 -0
- triton/language/standard.py +452 -0
- triton/runtime/__init__.py +23 -0
- triton/runtime/autotuner.py +408 -0
- triton/runtime/build.py +111 -0
- triton/runtime/cache.py +295 -0
- triton/runtime/driver.py +60 -0
- triton/runtime/errors.py +26 -0
- triton/runtime/interpreter.py +1235 -0
- triton/runtime/jit.py +951 -0
- triton/testing.py +511 -0
- triton/tools/__init__.py +0 -0
- triton/tools/build_extern.py +365 -0
- triton/tools/compile.c +67 -0
- triton/tools/compile.h +14 -0
- triton/tools/compile.py +155 -0
- triton/tools/disasm.py +144 -0
- triton/tools/experimental_descriptor.py +32 -0
- triton/tools/link.py +322 -0
- triton/windows_utils.py +375 -0
- triton_windows-3.2.0.post11.dist-info/METADATA +39 -0
- triton_windows-3.2.0.post11.dist-info/RECORD +154 -0
- triton_windows-3.2.0.post11.dist-info/WHEEL +5 -0
- triton_windows-3.2.0.post11.dist-info/top_level.txt +12 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#define __HIP_PLATFORM_AMD__
|
|
2
|
+
// clang-format off
|
|
3
|
+
// hip_depreated.h needs definitions from hip_runtime.h.
|
|
4
|
+
#include <hip/hip_runtime.h>
|
|
5
|
+
#include <hip/hip_deprecated.h>
|
|
6
|
+
// clang-format on
|
|
7
|
+
#define PY_SSIZE_T_CLEAN
|
|
8
|
+
#include <Python.h>
|
|
9
|
+
#include <dlfcn.h>
|
|
10
|
+
#include <stdio.h>
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
|
|
13
|
+
// The list of paths to search for the HIP runtime library. The caller Python
|
|
14
|
+
// code should substitute the search path placeholder.
|
|
15
|
+
static const char *hipLibSearchPaths[] = {"/*py_libhip_search_path*/"};
|
|
16
|
+
|
|
17
|
+
// The list of HIP dynamic library symbols and their signature we are interested
|
|
18
|
+
// in this file.
|
|
19
|
+
// |FOR_EACH_ERR_FN| is a macro to process APIs that return hipError_t;
|
|
20
|
+
// |FOR_EACH_STR_FN| is a macro to process APIs that return const char *.
|
|
21
|
+
//
|
|
22
|
+
// HIP 6.0 introduced an updated hipGetDeviceProperties API under a new symbol,
|
|
23
|
+
// hipGetDevicePropertiesR0600. However, the associated hipDeviceProp_t was
|
|
24
|
+
// directly updated with breaking changes to match hipGetDevicePropertiesR0600
|
|
25
|
+
// in the header file. We include the header file from HIP 6.0. So here if we
|
|
26
|
+
// use hipGetDeviceProperties together with hipDeviceProp_t we will use the
|
|
27
|
+
// old API with a new struct definition and mess up the interpretation.
|
|
28
|
+
//
|
|
29
|
+
// This is a known issue: https://github.com/ROCm/ROCm/issues/2728.
|
|
30
|
+
//
|
|
31
|
+
// For now explicitly defer to the old hipDeviceProp_t struct. This should work
|
|
32
|
+
// for both 5.x and 6.x. In the long term we need to switch to use
|
|
33
|
+
// hipGetProcAddress once available:
|
|
34
|
+
// https://github.com/ROCm/clr/commit/0479cdb3dd30ef58718cad44e424bd793c394cc0
|
|
35
|
+
#define HIP_SYMBOL_LIST(FOR_EACH_ERR_FN, FOR_EACH_STR_FN) \
|
|
36
|
+
FOR_EACH_STR_FN(hipGetErrorString, hipError_t hipError) \
|
|
37
|
+
FOR_EACH_ERR_FN(hipGetDeviceProperties, hipDeviceProp_tR0000 *prop, \
|
|
38
|
+
int deviceId) \
|
|
39
|
+
FOR_EACH_ERR_FN(hipModuleLoadDataEx, hipModule_t *module, const void *image, \
|
|
40
|
+
unsigned int numOptions, hipJitOption *options, \
|
|
41
|
+
void **optionValues) \
|
|
42
|
+
FOR_EACH_ERR_FN(hipModuleGetFunction, hipFunction_t *function, \
|
|
43
|
+
hipModule_t module, const char *kname) \
|
|
44
|
+
FOR_EACH_ERR_FN(hipFuncGetAttribute, int *, hipFunction_attribute attr, \
|
|
45
|
+
hipFunction_t function)
|
|
46
|
+
|
|
47
|
+
// The HIP symbol table for holding resolved dynamic library symbols.
|
|
48
|
+
struct HIPSymbolTable {
|
|
49
|
+
#define DEFINE_EACH_ERR_FIELD(hipSymbolName, ...) \
|
|
50
|
+
hipError_t (*hipSymbolName)(__VA_ARGS__);
|
|
51
|
+
#define DEFINE_EACH_STR_FIELD(hipSymbolName, ...) \
|
|
52
|
+
const char *(*hipSymbolName)(__VA_ARGS__);
|
|
53
|
+
|
|
54
|
+
HIP_SYMBOL_LIST(DEFINE_EACH_ERR_FIELD, DEFINE_EACH_STR_FIELD)
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
static struct HIPSymbolTable hipSymbolTable;
|
|
58
|
+
|
|
59
|
+
bool initSymbolTable() {
|
|
60
|
+
// Use the HIP runtime library loaded into the existing process if it exits.
|
|
61
|
+
void *lib = dlopen("libamdhip64.so", RTLD_NOLOAD);
|
|
62
|
+
if (lib) {
|
|
63
|
+
// printf("[triton] chosen loaded libamdhip64.so in the process\n");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Otherwise, go through the list of search paths to dlopen the first HIP
|
|
67
|
+
// driver library.
|
|
68
|
+
if (!lib) {
|
|
69
|
+
int n = sizeof(hipLibSearchPaths) / sizeof(hipLibSearchPaths[0]);
|
|
70
|
+
for (int i = 0; i < n; ++i) {
|
|
71
|
+
void *handle = dlopen(hipLibSearchPaths[i], RTLD_LAZY | RTLD_LOCAL);
|
|
72
|
+
if (handle) {
|
|
73
|
+
lib = handle;
|
|
74
|
+
// printf("[triton] chosen %s\n", hipLibSearchPaths[i]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!lib) {
|
|
79
|
+
PyErr_SetString(PyExc_RuntimeError, "cannot open libamdhip64.so");
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Resolve all symbols we are interested in.
|
|
84
|
+
dlerror(); // Clear existing errors
|
|
85
|
+
const char *error = NULL;
|
|
86
|
+
#define QUERY_EACH_FN(hipSymbolName, ...) \
|
|
87
|
+
*(void **)&hipSymbolTable.hipSymbolName = dlsym(lib, #hipSymbolName); \
|
|
88
|
+
error = dlerror(); \
|
|
89
|
+
if (error) { \
|
|
90
|
+
PyErr_SetString(PyExc_RuntimeError, \
|
|
91
|
+
"cannot query " #hipSymbolName " from libamdhip64.so"); \
|
|
92
|
+
dlclose(lib); \
|
|
93
|
+
return false; \
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
HIP_SYMBOL_LIST(QUERY_EACH_FN, QUERY_EACH_FN)
|
|
97
|
+
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static inline void gpuAssert(hipError_t code, const char *file, int line) {
|
|
102
|
+
{
|
|
103
|
+
if (code != HIP_SUCCESS) {
|
|
104
|
+
{
|
|
105
|
+
const char *prefix = "Triton Error [HIP]: ";
|
|
106
|
+
const char *str = hipSymbolTable.hipGetErrorString(code);
|
|
107
|
+
char err[1024] = {0};
|
|
108
|
+
snprintf(err, 1024, "%s Code: %d, Messsage: %s", prefix, code, str);
|
|
109
|
+
PyGILState_STATE gil_state;
|
|
110
|
+
gil_state = PyGILState_Ensure();
|
|
111
|
+
PyErr_SetString(PyExc_RuntimeError, err);
|
|
112
|
+
PyGILState_Release(gil_state);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#define HIP_CHECK(ans) \
|
|
119
|
+
{ \
|
|
120
|
+
gpuAssert((ans), __FILE__, __LINE__); \
|
|
121
|
+
if (PyErr_Occurred()) \
|
|
122
|
+
return NULL; \
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static PyObject *getDeviceProperties(PyObject *self, PyObject *args) {
|
|
126
|
+
int device_id;
|
|
127
|
+
if (!PyArg_ParseTuple(args, "i", &device_id))
|
|
128
|
+
return NULL;
|
|
129
|
+
|
|
130
|
+
hipDeviceProp_tR0000 props;
|
|
131
|
+
HIP_CHECK(hipSymbolTable.hipGetDeviceProperties(&props, device_id));
|
|
132
|
+
|
|
133
|
+
// create a struct to hold device properties
|
|
134
|
+
return Py_BuildValue(
|
|
135
|
+
"{s:i, s:i, s:i, s:i, s:i, s:i, s:s, s:i, s:i}", "max_shared_mem",
|
|
136
|
+
props.sharedMemPerBlock, "max_num_regs", props.regsPerBlock,
|
|
137
|
+
"multiprocessor_count", props.multiProcessorCount, "sm_clock_rate",
|
|
138
|
+
props.clockRate, "mem_clock_rate", props.memoryClockRate, "mem_bus_width",
|
|
139
|
+
props.memoryBusWidth, "arch", props.gcnArchName, "warpSize",
|
|
140
|
+
props.warpSize, "max_threads_per_sm", props.maxThreadsPerMultiProcessor);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static PyObject *loadBinary(PyObject *self, PyObject *args) {
|
|
144
|
+
const char *name;
|
|
145
|
+
const char *data;
|
|
146
|
+
Py_ssize_t data_size;
|
|
147
|
+
int shared;
|
|
148
|
+
int device;
|
|
149
|
+
if (!PyArg_ParseTuple(args, "ss#ii", &name, &data, &data_size, &shared,
|
|
150
|
+
&device)) {
|
|
151
|
+
return NULL;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// set HIP options
|
|
155
|
+
hipJitOption opt[] = {hipJitOptionErrorLogBufferSizeBytes,
|
|
156
|
+
hipJitOptionErrorLogBuffer,
|
|
157
|
+
hipJitOptionInfoLogBufferSizeBytes,
|
|
158
|
+
hipJitOptionInfoLogBuffer, hipJitOptionLogVerbose};
|
|
159
|
+
const unsigned int errbufsize = 8192;
|
|
160
|
+
const unsigned int logbufsize = 8192;
|
|
161
|
+
char _err[errbufsize];
|
|
162
|
+
char _log[logbufsize];
|
|
163
|
+
void *optval[] = {(void *)(uintptr_t)errbufsize, (void *)_err,
|
|
164
|
+
(void *)(uintptr_t)logbufsize, (void *)_log, (void *)1};
|
|
165
|
+
|
|
166
|
+
// launch HIP Binary
|
|
167
|
+
hipModule_t mod;
|
|
168
|
+
hipFunction_t fun;
|
|
169
|
+
HIP_CHECK(hipSymbolTable.hipModuleLoadDataEx(&mod, data, 5, opt, optval))
|
|
170
|
+
HIP_CHECK(hipSymbolTable.hipModuleGetFunction(&fun, mod, name));
|
|
171
|
+
|
|
172
|
+
// get allocated registers and spilled registers from the function
|
|
173
|
+
int n_regs = 0;
|
|
174
|
+
int n_spills = 0;
|
|
175
|
+
hipSymbolTable.hipFuncGetAttribute(&n_regs, HIP_FUNC_ATTRIBUTE_NUM_REGS, fun);
|
|
176
|
+
hipSymbolTable.hipFuncGetAttribute(&n_spills,
|
|
177
|
+
HIP_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES, fun);
|
|
178
|
+
n_spills /= 4;
|
|
179
|
+
if (PyErr_Occurred()) {
|
|
180
|
+
return NULL;
|
|
181
|
+
}
|
|
182
|
+
return Py_BuildValue("(KKii)", (uint64_t)mod, (uint64_t)fun, n_regs,
|
|
183
|
+
n_spills);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static PyMethodDef ModuleMethods[] = {
|
|
187
|
+
{"load_binary", loadBinary, METH_VARARGS,
|
|
188
|
+
"Load provided hsaco into HIP driver"},
|
|
189
|
+
{"get_device_properties", getDeviceProperties, METH_VARARGS,
|
|
190
|
+
"Get the properties for a given device"},
|
|
191
|
+
{NULL, NULL, 0, NULL} // sentinel
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
static struct PyModuleDef ModuleDef = {PyModuleDef_HEAD_INIT, "hip_utils",
|
|
195
|
+
NULL, // documentation
|
|
196
|
+
-1, // size
|
|
197
|
+
ModuleMethods};
|
|
198
|
+
|
|
199
|
+
PyMODINIT_FUNC PyInit_hip_utils(void) {
|
|
200
|
+
if (!initSymbolTable()) {
|
|
201
|
+
return NULL;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
PyObject *m = PyModule_Create(&ModuleDef);
|
|
205
|
+
if (m == NULL) {
|
|
206
|
+
return NULL;
|
|
207
|
+
}
|
|
208
|
+
PyModule_AddFunctions(m, ModuleMethods);
|
|
209
|
+
|
|
210
|
+
return m;
|
|
211
|
+
}
|