Commit 70582e0
committed
[mlir-tensorrt] Integrate internal changes
--- [compiler] Add cuda.get_program_device op
Introduce `cuda.get_program_device` as a pure/speculatable way to map
a program logical device id (i32) to a CUDA device ordinal (i32).
GitOrigin-RevId: 00512cc5a9e9c61023e1d9de734b2383da369bcf
--- [compiler] Refactor device management and stream creation utilities
This commit introduces a new device management model to support
multi-device SPMD and MPMD programs and refactors stream creation to
use reusable utility functions. The primary motivation is to enable
more flexible device assignment where programs can be assigned to
specific CUDA ordinals via logical device IDs, laying the groundwork
for better multi-device support.
GitOrigin-RevId: 447b72743e64f394671f866fcdfdb0d6f0f3d579
---[compiler|executor] Refactor plugin call stream handling
This change refactors how CUDA streams are handled for plugin calls in
the executor dialect. Previously, when no stream was provided to a
CallPluginOp, the lowering would create and use a global CUDA stream
(stream0). This approach had several issues:
1. It tightly coupled the executor dialect to CUDA-specific stream
creation
2. It required maintaining global stream state across compilation
3. It made the stream handling implicit and harder to reason about
The new approach uses null streams (nullptr) when no explicit stream
is provided. This is the standard CUDA convention where a null stream
represents the default stream. The changes include:
- Modified `executor.call_plugin` op to accept any type for the stream
operand (not just `!executor.ptr<host>`), allowing frontend dialects
to pass their own stream representations (e.g. `!cuda.stream`)
- Updated the assembly format to print the stream type for clarity
- Removed `getGlobalCudaStream` helper method from
ConvertToExecutorPattern
- Changed CallPluginConversionPattern to create a null pointer
(inttoptr 0) when no stream is provided instead of creating a global
stream
- Updated StablehloToPlan conversion to use
`cuda::getOrCreateDefaultStream0` to explicitly create CUDA streams
when converting TVM FFI custom calls
- Added CUDADialect dependency to StablehloToPlan pass and CMakeLists
This makes stream handling more explicit and flexible, allowing
different frontend dialects to manage their own stream creation while
falling back to null streams (CUDA default stream) when appropriate.
GitOrigin-RevId: 764238bc58308d5d284f8e32da91c7e5f90fdf0c1 parent ef65735 commit 70582e0
File tree
71 files changed
+774
-433
lines changed- mlir-tensorrt
- common/include/mlir-tensorrt-common/Utils
- compiler
- include/mlir-tensorrt
- Conversion
- Dialect
- CUDA
- IR
- Utils
- Plan/Transforms
- StablehloExt/Transforms
- lib
- Compiler
- Extensions/KernelGenExtension
- InputPipelines
- Conversion
- CUDAToExecutor
- CUDAToLLVM
- HostToEmitC
- KernelToCUDA
- MemRefToCUDA
- StablehloToPlan
- TensorRTToTensorRTRuntime
- Dialect
- CUDA
- Utils
- Plan/Transforms
- StablehloExt/Transforms
- Transforms/ExecuteConstantFoldableSubgraphs
- test
- Backend
- Host
- Kernel
- TensorRT
- Compiler
- InputPipelines/Stablehlo
- KernelGenExtension
- Conversion
- CUDAToExecutor
- CUDAToLLVM
- HostToEmitC
- KernelToCUDA
- MemRefToCUDA
- StablehloToPlan
- TensorRTToTensorRTRuntime
- Dialect/CUDA
- IntegrationTests/Check
- Transforms/OutlineTensorRTOps
- executor
- include/mlir-executor
- Conversion
- Executor/IR
- Runtime/API
- lib
- CAPI/Runtime
- Conversion
- Runtime
- API
- Backend
- C
- Lua
- Modules
- CUDA
- NCCL
- StandaloneCPP
- Target/Lua
- Tools
- test
- Conversion
- Unit/Runtime/LuaRuntime
- integrations/PJRT/lib
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
71 files changed
+774
-433
lines changedLines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
96 | 113 | | |
97 | 114 | | |
98 | 115 | | |
| |||
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
330 | 335 | | |
331 | 336 | | |
332 | 337 | | |
333 | 338 | | |
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
109 | 114 | | |
110 | 115 | | |
111 | 116 | | |
| |||
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
129 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
130 | 137 | | |
131 | 138 | | |
132 | 139 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | 217 | | |
222 | 218 | | |
223 | 219 | | |
| |||
Lines changed: 11 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
0 commit comments