|
7 | 7 | #include <algorithm> |
8 | 8 | #include <cmath> |
9 | 9 | #include <cstdio> |
10 | | -#include <set> |
11 | 10 |
|
12 | 11 | namespace dflash::common { |
13 | 12 |
|
@@ -110,61 +109,4 @@ void free_layer_split_snapshot_backends( |
110 | 109 | snapshot_backends.clear(); |
111 | 110 | } |
112 | 111 |
|
113 | | -std::string validate_device_placement( |
114 | | - const DevicePlacement & dp, |
115 | | - int device_count) |
116 | | -{ |
117 | | - const bool validate_device_count = device_count >= 0; |
118 | | - if (validate_device_count && device_count == 0) { |
119 | | - return "no GPU devices available"; |
120 | | - } |
121 | | - |
122 | | - if (dp.gpu < 0 || |
123 | | - (validate_device_count && dp.gpu >= device_count)) { |
124 | | - return "primary gpu " + std::to_string(dp.gpu) + " out of range" + |
125 | | - (validate_device_count |
126 | | - ? " [0, " + std::to_string(device_count) + ")" |
127 | | - : ""); |
128 | | - } |
129 | | - |
130 | | - if (!dp.layer_split_gpus.empty()) { |
131 | | - if (dp.layer_split_gpus.size() < 2) { |
132 | | - return "layer_split_gpus must have at least 2 entries"; |
133 | | - } |
134 | | - |
135 | | - std::set<int> seen; |
136 | | - for (int g : dp.layer_split_gpus) { |
137 | | - if (g < 0 || |
138 | | - (validate_device_count && g >= device_count)) { |
139 | | - return "layer_split gpu " + std::to_string(g) + |
140 | | - " out of range" + |
141 | | - (validate_device_count |
142 | | - ? " [0, " + std::to_string(device_count) + ")" |
143 | | - : ""); |
144 | | - } |
145 | | - if (!seen.insert(g).second) { |
146 | | - return "duplicate gpu " + std::to_string(g) + " in layer_split_gpus"; |
147 | | - } |
148 | | - } |
149 | | - |
150 | | - if (!dp.layer_split_weights.empty() && |
151 | | - dp.layer_split_weights.size() != dp.layer_split_gpus.size()) { |
152 | | - return "layer_split_weights size (" + |
153 | | - std::to_string(dp.layer_split_weights.size()) + |
154 | | - ") != gpu count (" + |
155 | | - std::to_string(dp.layer_split_gpus.size()) + ")"; |
156 | | - } |
157 | | - |
158 | | - for (double w : dp.layer_split_weights) { |
159 | | - if (w <= 0.0 || !std::isfinite(w)) { |
160 | | - return "layer_split_weights must be positive finite values"; |
161 | | - } |
162 | | - } |
163 | | - } |
164 | | - |
165 | | - if (dp.max_ctx <= 0) return "max_ctx must be positive"; |
166 | | - |
167 | | - return {}; // ok |
168 | | -} |
169 | | - |
170 | 112 | } // namespace dflash::common |
0 commit comments