|
33 | 33 | 'MonitorError', |
34 | 34 | 'MathError', |
35 | 35 | 'JaxTracerError', |
36 | | - 'ConcretizationTypeError', |
37 | 36 | 'GPUOperatorNotFound', |
38 | 37 | 'SharedArgError', |
39 | 38 | ] |
@@ -128,120 +127,6 @@ class MathError(BrainPyError): |
128 | 127 | __module__ = 'brainpy' |
129 | 128 |
|
130 | 129 |
|
131 | | -class MPACheckpointingRequiredError(BrainPyError): |
132 | | - """To optimally save and restore a multiprocess array (GDA or jax Array outputted from pjit), use GlobalAsyncCheckpointManager. |
133 | | -
|
134 | | - You can create an GlobalAsyncCheckpointManager at top-level and pass it as |
135 | | - argument:: |
136 | | -
|
137 | | - from jax.experimental.gda_serialization import serialization as gdas |
138 | | - gda_manager = gdas.GlobalAsyncCheckpointManager() |
139 | | - brainpy.checkpoints.save(..., gda_manager=gda_manager) |
140 | | - """ |
141 | | - __module__ = 'brainpy' |
142 | | - |
143 | | - def __init__(self, path, step): |
144 | | - super().__init__( |
145 | | - f'Checkpoint failed at step: "{step}" and path: "{path}": Target ' |
146 | | - 'contains a multiprocess array should be saved/restored with a ' |
147 | | - 'GlobalAsyncCheckpointManager.') |
148 | | - |
149 | | - |
150 | | -class MPARestoreTargetRequiredError(BrainPyError): |
151 | | - """Provide a valid target when restoring a checkpoint with a multiprocess array. |
152 | | -
|
153 | | - Multiprocess arrays need a sharding (global meshes and partition specs) to be |
154 | | - initialized. Therefore, to restore a checkpoint that contains a multiprocess |
155 | | - array, make sure the ``target`` you passed contains valid multiprocess arrays |
156 | | - at the corresponding tree structure location. If you cannot provide a full |
157 | | - valid ``target``, consider ``allow_partial_mpa_restoration=True``. |
158 | | - """ |
159 | | - __module__ = 'brainpy' |
160 | | - |
161 | | - def __init__(self, path, step, key=None): |
162 | | - error_msg = ( |
163 | | - f'Restore checkpoint failed at step: "{step}" and path: "{path}": ' |
164 | | - 'Checkpoints containing a multiprocess array need to be restored with ' |
165 | | - 'a target with pre-created arrays. If you cannot provide a full valid ' |
166 | | - 'target, consider ``allow_partial_mpa_restoration=True``. ') |
167 | | - if key: |
168 | | - error_msg += f'This error fired when trying to restore array at {key}.' |
169 | | - super().__init__(error_msg) |
170 | | - |
171 | | - |
172 | | -class MPARestoreDataCorruptedError(BrainPyError): |
173 | | - """A multiprocess array stored in Google Cloud Storage doesn't contain a "commit_success.txt" file, which should be written at the end of the save. |
174 | | -
|
175 | | - Failure of finding it could indicate a corruption of your saved GDA data. |
176 | | - """ |
177 | | - __module__ = 'brainpy' |
178 | | - |
179 | | - def __init__(self, step, path): |
180 | | - super().__init__( |
181 | | - f'Restore checkpoint failed at step: "{step}" on multiprocess array at ' |
182 | | - f' "{path}": No "commit_success.txt" found on this "_gda" directory. ' |
183 | | - 'Was its save halted before completion?') |
184 | | - |
185 | | - |
186 | | -class MPARestoreTypeNotMatchError(BrainPyError): |
187 | | - """Make sure the multiprocess array type you use matches your configuration in jax.config.jax_array. |
188 | | -
|
189 | | - If you turned `jax.config.jax_array` on, you should use |
190 | | - `jax.experimental.array.Array` everywhere, instead of using |
191 | | - `GlobalDeviceArray`. Otherwise, avoid using jax.experimental.array |
192 | | - to restore your checkpoint. |
193 | | - """ |
194 | | - __module__ = 'brainpy' |
195 | | - |
196 | | - def __init__(self, step, gda_path): |
197 | | - super().__init__( |
198 | | - f'Restore checkpoint failed at step: "{step}" on multiprocess array at ' |
199 | | - f' "{gda_path}": The array type provided by the target does not match ' |
200 | | - 'the JAX global configuration, namely the jax.config.jax_array.') |
201 | | - |
202 | | - |
203 | | -class AlreadyExistsError(BrainPyError): |
204 | | - """Attempting to overwrite a file via copy. |
205 | | -
|
206 | | - You can pass ``overwrite=True`` to disable this behavior and overwrite |
207 | | - existing files in. |
208 | | - """ |
209 | | - __module__ = 'brainpy' |
210 | | - |
211 | | - def __init__(self, path): |
212 | | - super().__init__(f'Trying overwrite an existing file: "{path}".') |
213 | | - |
214 | | - |
215 | | -class InvalidCheckpointError(BrainPyError): |
216 | | - """A checkpoint cannot be stored in a directory that already has |
217 | | -
|
218 | | - a checkpoint at the current or a later step. |
219 | | -
|
220 | | - You can pass ``overwrite=True`` to disable this behavior and |
221 | | - overwrite existing checkpoints in the target directory. |
222 | | - """ |
223 | | - __module__ = 'brainpy' |
224 | | - |
225 | | - def __init__(self, path, step): |
226 | | - super().__init__( |
227 | | - f'Trying to save an outdated checkpoint at step: "{step}" and path: "{path}".' |
228 | | - ) |
229 | | - |
230 | | - |
231 | | -class InvalidCheckpointPath(BrainPyError): |
232 | | - """A checkpoint cannot be stored in a directory that already has |
233 | | -
|
234 | | - a checkpoint at the current or a later step. |
235 | | -
|
236 | | - You can pass ``overwrite=True`` to disable this behavior and |
237 | | - overwrite existing checkpoints in the target directory. |
238 | | - """ |
239 | | - __module__ = 'brainpy' |
240 | | - |
241 | | - def __init__(self, path): |
242 | | - super().__init__(f'Invalid checkpoint at "{path}".') |
243 | | - |
244 | | - |
245 | 130 | class JaxTracerError(MathError): |
246 | 131 | __module__ = 'brainpy' |
247 | 132 |
|
@@ -271,22 +156,6 @@ def __init__(self, variables=None): |
271 | 156 | super(JaxTracerError, self).__init__(msg) |
272 | 157 |
|
273 | 158 |
|
274 | | -class ConcretizationTypeError(Exception): |
275 | | - __module__ = 'brainpy' |
276 | | - |
277 | | - def __init__(self): |
278 | | - super(ConcretizationTypeError, self).__init__( |
279 | | - 'This problem may be caused by several ways:\n' |
280 | | - '1. Your if-else conditional statement relies on instances of brainpy.math.Variable. \n' |
281 | | - '2. Your if-else conditional statement relies on functional arguments which do not ' |
282 | | - 'set in "static_argnames" when applying JIT compilation. More details please see ' |
283 | | - 'https://jax.readthedocs.io/en/latest/errors.html#jax.errors.ConcretizationTypeError\n' |
284 | | - '3. The static variables which set in the "static_argnames" are provided ' |
285 | | - 'as arguments, not keyword arguments, like "jit_f(v1, v2)" [<- wrong]. ' |
286 | | - 'Please write it as "jit_f(static_k1=v1, static_k2=v2)" [<- right].' |
287 | | - ) |
288 | | - |
289 | | - |
290 | 159 | class GPUOperatorNotFound(Exception): |
291 | 160 | __module__ = 'brainpy' |
292 | 161 |
|
|
0 commit comments