Commit 3543414
Initial version of async attribution with torch.futures (#1295)
Summary:
Pull Request resolved: #1295
Currently Captum doesn't support async forward functions. Ads R&P team would like this feature in order to replace their custom variant (D56655643) of Feature Ablation with Captum and maintain similar performance.
PyTorch introduce future concepts ([link](https://pytorch.org/docs/stable/futures.html)) so we can adopt it for feature_ablation.py as the first step.
Details:
- Initial evaluation returns a future, save it.
- Each evaluation for each feature for each input will returns an attribution result (plus corresponding weight if applicable), save all those result separately since futures cannot be added up directly.
- When all futures above are done. we can add up the evaluation result to the final outcome as one Tensor per input.
- Since common._run_forward is used by other attribution methods, need to do some type hacking over there. But if users attempt to use those methods async, they will end up in failure before Captum support async for those methods.
TODO: Extend FeatureAttributor to support `torch.futures`
Reviewed By: vivekmig
Differential Revision: D56764316
fbshipit-source-id: 33661a76380dc009f4c9c60323b3c584e5152cda1 parent 3125f59 commit 3543414
File tree
11 files changed
+401
-115
lines changed- captum
- _utils
- attr
- _core
- layer
- _utils
- insights/attr_vis
- metrics/_core
- tests/attr
11 files changed
+401
-115
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
514 | 516 | | |
515 | 517 | | |
516 | 518 | | |
517 | | - | |
| 519 | + | |
518 | 520 | | |
519 | 521 | | |
520 | 522 | | |
| |||
532 | 534 | | |
533 | 535 | | |
534 | 536 | | |
| 537 | + | |
| 538 | + | |
535 | 539 | | |
536 | 540 | | |
537 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
297 | 301 | | |
298 | 302 | | |
299 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
300 | 308 | | |
301 | 309 | | |
302 | 310 | | |
| |||
0 commit comments