Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rllib] Better exceptions with traceback in TorchPolicy #17690

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions rllib/policy/torch_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,10 @@ def _worker(shard_idx, model, sample_batch, device):
results[shard_idx] = (all_grads, grad_info)
except Exception as e:
with lock:
results[shard_idx] = ValueError(
results[shard_idx] = (ValueError(
e.args[0] + "\n" +
"In tower {} on device {}".format(shard_idx, device))
"In tower {} on device {}".format(shard_idx, device)),
e)

# Single device (GPU) or fake-GPU case (serialize for better
# debugging).
Expand All @@ -1001,8 +1002,8 @@ def _worker(shard_idx, model, sample_batch, device):
_worker(shard_idx, model, sample_batch, device)
# Raise errors right away for better debugging.
last_result = results[len(results) - 1]
if isinstance(last_result, ValueError):
raise last_result
if isinstance(last_result[0], ValueError):
raise last_result[0] from last_result[1]
# Multi device (GPU) case: Parallelize via threads.
else:
threads = [
Expand All @@ -1022,8 +1023,8 @@ def _worker(shard_idx, model, sample_batch, device):
outputs = []
for shard_idx in range(len(sample_batches)):
output = results[shard_idx]
if isinstance(output, Exception):
raise output
if isinstance(output[0], Exception):
raise output[0] from output[1]
outputs.append(results[shard_idx])
return outputs

Expand Down