fix: drain CUDA errors between hyperopt trials to prevent cascade
If a trial corrupts GPU state (CUDA_ERROR_ILLEGAL_ADDRESS from extreme training), the inter-trial sync now drains the error instead of propagating it — preventing all subsequent trials from failing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2656,9 +2656,14 @@ impl HyperparameterOptimizable for DQNTrainer {
|
||||
// Synchronize the trial device's stream to ensure all async frees complete.
|
||||
// With forked streams sharing the same context, free_async returns memory
|
||||
// to the context's pool — available for the next trial's allocations.
|
||||
// If sync fails (CUDA_ERROR_ILLEGAL_ADDRESS from corrupted trial), drain
|
||||
// the error and continue — the next trial creates a fresh stream.
|
||||
if let MlDevice::Cuda { stream, .. } = &trial_device {
|
||||
stream.synchronize()
|
||||
.map_err(|e| MLError::TrainingError(format!("CUDA sync between trials: {e}")))?;
|
||||
if let Err(e) = stream.synchronize() {
|
||||
tracing::error!("CUDA sync between trials failed (draining): {e}");
|
||||
// Drain context-level error to prevent cascade to next trial
|
||||
let _ = stream.context().check_err();
|
||||
}
|
||||
}
|
||||
info!("Resource cleanup complete");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user