You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SHAP and Captum throw confusing errors. We can add an error rethrowing module. The dictionary that maps original to clear messages will be stored inside each explainer.
Library
Original
New
SHAP
RuntimeError: Output 0 of BackwardHookFunctionBackward is a view and is being modified inplace. This view was created inside a custom Function (or because an input was returned as-is) and the autograd logic to handle view+inplace would override the custom backward associated with the custom Function, leading to incorrect gradients. This behavior is forbidden. You can fix this by cloning the output of the custom Function.
DeepExplainer can fail on PyTorch models that use SiLU activations (for example EfficientNet variants) due to autograd/in-place limitations. Use alternatives like GradientExplainer.
The shared infrastructure that this issue's error-rethrow layer will sit on top of has landed:
raitap.utils.diagnostics.Diagnostic — typed origin record (subsystem, file, line, third_party_lib). Reused for both warnings and (future) errors.
resolve_diagnostic_from_frames(file, line) — walks the live call stack to classify the actual raitap subsystem and detect a wrapped third-party library (captum, shap, foolbox, torchattacks). Allowlisted subsystems prevent CI-path false matches; early-exit once both pieces resolved.
is_dev_install() / docs_url(diagnostic) — audience detection (cloned repo vs installed wheel; site-packages + dist-packages, case-insensitive) and subsystem-driven docs URL mapping.
raitap.utils.warnings.suppress_warning(...) — adapter-scoped runtime warning silencing (module= filter so unrelated UserWarnings aren't accidentally hidden). Captum's Input Tensor … required_grads already wired up as the smoke test.
raitap.utils.warnings.raitap_warn(msg, *, subsystem=..., third_party_lib=...) — explicit-origin variant of warnings.warn for call sites where the logical owner differs from the file location (e.g. a robustness warning emitted from run/pipeline.py).
RaitapRichHandler consumes the Diagnostic and renders audience-appropriate panel headers: dev mode shows ▲ Warning · Subsystem · path:line; installed mode shows ▲ Warning · Subsystem · View docs (OSC 8 link, underline, via Captum chip for third-party). Narrow terminals truncate the title with … instead of hard-cutting mid-word.
To do (this issue)
Build the error-rethrow layer on top of the diagnostic plumbing above:
New module raitap.utils.errors (sibling of utils/warnings.py):
resolve_diagnostic_from_traceback(tb) — populates a Diagnostic from an exception's __traceback__ instead of a live frame walk (errors propagate; the warn-time frame walk doesn't apply).
Base raitap exception class with a diagnostic: Diagnostic field so the rich handler / final crash panel can render the same Subsystem · View docs affordance for raised errors.
wrap_exception(exc, *, subsystem=..., third_party_lib=...) helper or context manager so adapter call sites can rethrow third-party errors with our metadata attached.
Per-explainer / per-assessor message dictionary: {re.Pattern: replacement_text} stored on each adapter class. The wrap helper looks up the original exception's message against the dict and substitutes the user-facing copy when there's a match (table above is the seed dataset — extend as we hit confusing errors in practice).
Wire into the captum + shap adapters first (where the noisiest errors live), then foolbox / torchattacks.
Update the failure panel rendering in RaitapRichHandler (or print_failure_panel in utils/console.py) to surface the rewrapped message + diagnostic chips instead of the raw TypeError: ... line.
Tests: per-adapter dictionary lookups, traceback-driven Diagnostic resolution, end-to-end rethrow keeping __cause__ so the original traceback stays accessible for debugging.
Out of scope
Suppressing errors (only rewrapping). Adapters that legitimately need to swallow library noise should use suppress_warning for warnings or fix the underlying issue for errors.
SHAP and Captum throw confusing errors. We can add an error rethrowing module. The dictionary that maps original to clear messages will be stored inside each explainer.
RuntimeError: Output 0 of BackwardHookFunctionBackward is a view and is being modified inplace. This view was created inside a custom Function (or because an input was returned as-is) and the autograd logic to handle view+inplace would override the custom backward associated with the custom Function, leading to incorrect gradients. This behavior is forbidden. You can fix this by cloning the output of the custom Function.DeepExplainer can fail on PyTorch models that use SiLU activations (for example EfficientNet variants) due to autograd/in-place limitations. Use alternatives like GradientExplainer.Status
Done (PR #124 — diagnostic infrastructure)
The shared infrastructure that this issue's error-rethrow layer will sit on top of has landed:
raitap.utils.diagnostics.Diagnostic— typed origin record (subsystem,file,line,third_party_lib). Reused for both warnings and (future) errors.resolve_diagnostic_from_frames(file, line)— walks the live call stack to classify the actual raitap subsystem and detect a wrapped third-party library (captum, shap, foolbox, torchattacks). Allowlisted subsystems prevent CI-path false matches; early-exit once both pieces resolved.is_dev_install()/docs_url(diagnostic)— audience detection (cloned repo vs installed wheel; site-packages + dist-packages, case-insensitive) and subsystem-driven docs URL mapping.raitap.utils.warnings.suppress_warning(...)— adapter-scoped runtime warning silencing (module=filter so unrelated UserWarnings aren't accidentally hidden). Captum'sInput Tensor … required_gradsalready wired up as the smoke test.raitap.utils.warnings.raitap_warn(msg, *, subsystem=..., third_party_lib=...)— explicit-origin variant ofwarnings.warnfor call sites where the logical owner differs from the file location (e.g. a robustness warning emitted fromrun/pipeline.py).RaitapRichHandlerconsumes theDiagnosticand renders audience-appropriate panel headers: dev mode shows▲ Warning · Subsystem · path:line; installed mode shows▲ Warning · Subsystem · View docs(OSC 8 link, underline,via Captumchip for third-party). Narrow terminals truncate the title with…instead of hard-cutting mid-word.To do (this issue)
Build the error-rethrow layer on top of the diagnostic plumbing above:
raitap.utils.errors(sibling ofutils/warnings.py):resolve_diagnostic_from_traceback(tb)— populates aDiagnosticfrom an exception's__traceback__instead of a live frame walk (errors propagate; the warn-time frame walk doesn't apply).diagnostic: Diagnosticfield so the rich handler / final crash panel can render the sameSubsystem · View docsaffordance for raised errors.wrap_exception(exc, *, subsystem=..., third_party_lib=...)helper or context manager so adapter call sites can rethrow third-party errors with our metadata attached.{re.Pattern: replacement_text}stored on each adapter class. The wrap helper looks up the original exception's message against the dict and substitutes the user-facing copy when there's a match (table above is the seed dataset — extend as we hit confusing errors in practice).RaitapRichHandler(orprint_failure_panelinutils/console.py) to surface the rewrapped message + diagnostic chips instead of the rawTypeError: ...line.Diagnosticresolution, end-to-end rethrow keeping__cause__so the original traceback stays accessible for debugging.Out of scope
suppress_warningfor warnings or fix the underlying issue for errors.