torch-ddp 0.2.5 → 0.3.0
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.
- checksums.yaml +4 -4
- data/ext/torch_ddp/distributed.cpp +27 -5
- data/lib/torch/ddp/version.rb +1 -1
- data/lib/torch/ddp_ext.so +0 -0
- data/lib/torch/distributed.rb +4 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f9b645358a4641e4276ff48adb382c869feb024882d84c4835a39025bda6e62
|
|
4
|
+
data.tar.gz: 8f141183e503f72f0ec1622209e4ca17dcf8611471f68a45e34e0e2c146e4631
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe63d5d9cbc27128b15166363c6a1ae84f342a33c66211e43f6464b9fc58a2a70e497d053561bdf176826307ef089a616fd102db2dd8da135b1ac4e8ee9b781c
|
|
7
|
+
data.tar.gz: 733d6befc6151f55452b3834d2b8c4e174184adda5e8cacc99bc510b65576b26f6e721454d7e88d6309ff2a39290488cc75926f5e137c4ce697ccc0dd53e8827
|
|
@@ -54,22 +54,44 @@ struct StoreWrapper {
|
|
|
54
54
|
|
|
55
55
|
struct ProcessGroupWrapper {
|
|
56
56
|
ProcessGroupWrapper() = default;
|
|
57
|
-
explicit ProcessGroupWrapper(ProcessGroupPtr pg)
|
|
57
|
+
explicit ProcessGroupWrapper(ProcessGroupPtr pg)
|
|
58
|
+
: pg_(std::move(pg)), preserve_on_destroy_(pg_ && pg_->getBackendName() == "nccl") {}
|
|
59
|
+
|
|
60
|
+
~ProcessGroupWrapper() {
|
|
61
|
+
if (preserve_on_destroy_) {
|
|
62
|
+
pg_.release();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
58
65
|
|
|
59
66
|
ProcessGroupPtr pg_;
|
|
67
|
+
bool preserve_on_destroy_ = false;
|
|
60
68
|
};
|
|
61
69
|
|
|
62
70
|
ProcessGroupPtr default_process_group;
|
|
63
71
|
std::once_flag default_pg_cleanup_once;
|
|
64
72
|
|
|
65
73
|
void shutdown_default_process_group() {
|
|
66
|
-
if (default_process_group) {
|
|
74
|
+
if (!default_process_group) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
auto process_group = std::move(default_process_group);
|
|
79
|
+
if (process_group->getBackendName() == "nccl") {
|
|
67
80
|
try {
|
|
68
|
-
|
|
81
|
+
process_group->abort();
|
|
69
82
|
} catch (...) {
|
|
70
|
-
// best effort;
|
|
83
|
+
// best effort; avoid throwing from Ruby/C++ exit handlers
|
|
71
84
|
}
|
|
72
|
-
|
|
85
|
+
// LibTorch 2.13 may double-free NCCL resources from the intrusive_ptr
|
|
86
|
+
// destructor after abort; leave this final owning reference leaked.
|
|
87
|
+
process_group.release();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
process_group->shutdown();
|
|
93
|
+
} catch (...) {
|
|
94
|
+
// best effort; the local intrusive_ptr still releases the Gloo group
|
|
73
95
|
}
|
|
74
96
|
}
|
|
75
97
|
|
data/lib/torch/ddp/version.rb
CHANGED
data/lib/torch/ddp_ext.so
CHANGED
|
Binary file
|
data/lib/torch/distributed.rb
CHANGED
|
@@ -62,12 +62,10 @@ module Torch
|
|
|
62
62
|
|
|
63
63
|
timeout_ms = (timeout * 1000).to_i
|
|
64
64
|
bound_device_id = device_id.nil? ? -1 : Integer(device_id)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Torch::CUDA.set_device(bound_device_id) if device_count.nil? || bound_device_id < device_count
|
|
70
|
-
end
|
|
65
|
+
# The native extension selects the NCCL device after creating the process group.
|
|
66
|
+
# Calling a Ruby compatibility cudaSetDevice before construction triggers a
|
|
67
|
+
# LibTorch 2.13/CUDA teardown double free.
|
|
68
|
+
|
|
71
69
|
pg = _init_process_group(backend, store, rank, world_size, timeout_ms, bound_device_id)
|
|
72
70
|
warmup_process_group(pg, backend)
|
|
73
71
|
end
|