Repository navigation
Commit fcf50da
committed
CUDA backend: add a PTE device-id remap tool under backends/cuda/scripts
A CUDA program records the devices from its target_device compile
spec in its planned memory table, in tensor placement info, and in
each delegate's target_device compile spec itself. All three must
agree, so a program exported with an explicit non-zero target_device
(cuda:3, say) does not load on a machine whose GPUs have other
indices, and the loader has no way to move it.
scripts/remap_pte_devices.py rewrites all three places in the file
with one mapping, dense by default (3, 5, 7 become 0, 1, 2, keeping
their order, with a warning unless the result lands entirely on
cuda:0) or explicit (--mapping 3=0,5=0,7=0 collapses everything
onto cuda:0). The output is an ordinary PTE, so the runtime needs
no remapping support of its own. The companion .ptd is untouched:
tensor data carries no device ids. A mapping that does not cover a
recorded device is refused, so a file is never rewritten only in
part.
The tool starts a new backends/cuda/scripts directory for standalone
CUDA backend tools, alongside the library code. Its CPU-only tests
join pytest.ini testpaths and a Buck python_unittest, so serializer
and schema changes run them without a GPU.
Test Plan:
- backends/cuda/tests/test_remap_pte_devices.py (also registered as
a Buck python_unittest): 22 tests covering collection from all
three places across multiple execution plans, dense and explicit
mappings, coverage and validation errors, bare/uppercase/non-CUDA/
malformed target_device specs, shared compile specs, serialize
round trips with named data, identity-remap byte equality, failed-write
atomicity, the not-entirely-cuda:0 warning, an exported program
(DeviceAwarePartitioner, cuda:3) remapped to equal a native cuda:0
export, and the CLI dry-run, input-error and write paths. All pass
locally.1 parent 679e49e commit fcf50da
8 files changed
Lines changed: 947 additions & 0 deletions
File tree
- backends/cuda
- scripts
- tests
- examples/cuda
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
167 | 195 | | |
168 | 196 | | |
169 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 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 | + | |
0 commit comments