Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 154411,7 "name": "",8 "username": "Shubhankar",9 "avatar_template": "/letter_avatar_proxy/v4/letter/s/b9bd4f/{size}.png",10 "created_at": "2019-12-22T18:48:12.342Z",11 "cooked": "<p>If you create a dataparallel model as shown <a href=\"https://pytorch.org/tutorials/beginner/saving_loading_models.html#saving-torch-nn-dataparallel-models\" rel=\"nofollow noopener\">here</a> and then save it as shown <a href=\"https://pytorch.org/tutorials/beginner/saving_loading_models.html#saving-torch-nn-dataparallel-models\" rel=\"nofollow noopener\">here</a>. Are you required to do <code>nn.DataParallel(model)</code> again to load the model and continue training?</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 3,15 "updated_at": "2019-12-22T18:48:53.126Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 22,20 "reads": 9,21 "readers_count": 8,22 "score": 111.8,23 "yours": false,24 "topic_id": 64770,25 "topic_slug": "if-you-save-a-dataparallel-model-do-i-have-to-again-run-nn-dataparallel-after-loading-it-back",26 "display_username": "",27 "primary_group_name": null,28 "flair_name": null,29 "flair_url": null,30 "flair_bg_color": null,31 "flair_color": null,32 "flair_group_id": null,33 "badges_granted": [],34 "version": 1,35 "can_edit": false,36 "can_delete": false,37 "can_recover": false,38 "can_see_hidden_post": false,39 "can_wiki": false,40 "link_counts": [41 {42 "url": "https://pytorch.org/tutorials/beginner/saving_loading_models.html#saving-torch-nn-dataparallel-models",43 "internal": false,44 "reflection": false,45 "title": "Saving and Loading Models โ PyTorch Tutorials 1.3.1 documentation",46 "clicks": 947 }48 ],49 "read": true,50 "user_title": "",51 "bookmarked": false,52 "actions_summary": [],53 "moderator": false,54 "admin": false,55 "staff": false,56 "user_id": 24042,57 "hidden": false,58 "trust_level": 1,59 "deleted_at": null,60 "user_deleted": false,61 "edit_reason": null,62 "can_view_edit_history": true,63 "wiki": false,64 "post_url": "/t/if-you-save-a-dataparallel-model-do-i-have-to-again-run-nn-dataparallel-after-loading-it-back/64770/1",65 "can_accept_answer": false,66 "can_unaccept_answer": false,67 "accepted_answer": false,68 "topic_accepted_answer": null,69 "can_vote": false70 },71 {72 "id": 154476,73 "name": "",74 "username": "ptrblck",75 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",76 "created_at": "2019-12-23T07:06:03.145Z",77 "cooked": "<p>No. If you store the <code>state_dict</code> from the model directly or <code>model.modules</code> in case you are using <code>nn.DataParallel</code>, you should be able to reload it into the model again.</p>",78 "post_number": 2,79 "post_type": 1,80 "posts_count": 3,81 "updated_at": "2020-02-01T04:09:20.753Z",82 "reply_count": 1,83 "reply_to_post_number": null,84 "quote_count": 0,85 "incoming_link_count": 2,86 "reads": 7,87 "readers_count": 6,88 "score": 16.4,89 "yours": false,90 "topic_id": 64770,91 "topic_slug": "if-you-save-a-dataparallel-model-do-i-have-to-again-run-nn-dataparallel-after-loading-it-back",92 "display_username": "",93 "primary_group_name": null,94 "flair_name": null,95 "flair_url": null,96 "flair_bg_color": null,97 "flair_color": null,98 "flair_group_id": null,99 "badges_granted": [],100 "version": 1,101 "can_edit": false,102 "can_delete": false,103 "can_recover": false,104 "can_see_hidden_post": false,105 "can_wiki": false,106 "read": true,107 "user_title": "",108 "bookmarked": false,109 "actions_summary": [],110 "moderator": true,111 "admin": true,112 "staff": true,113 "user_id": 3534,114 "hidden": false,115 "trust_level": 2,116 "deleted_at": null,117 "user_deleted": false,118 "edit_reason": null,119 "can_view_edit_history": true,120 "wiki": false,121 "post_url": "/t/if-you-save-a-dataparallel-model-do-i-have-to-again-run-nn-dataparallel-after-loading-it-back/64770/2",122 "can_accept_answer": false,123 "can_unaccept_answer": false,124 "accepted_answer": false,125 "topic_accepted_answer": null126 },127 {128 "id": 162508,129 "name": "",130 "username": "Shubhankar",131 "avatar_template": "/letter_avatar_proxy/v4/letter/s/b9bd4f/{size}.png",132 "created_at": "2020-02-01T04:12:33.608Z",133 "cooked": "<p>I think you will have to do <code>nn.DataParallel</code> since you will do <code>model.module.load_state_dict(checkpoint['model_state_dict'])</code> and for the model to have module you need <code>model = nn.DataParallel(model)</code></p>",134 "post_number": 3,135 "post_type": 1,136 "posts_count": 3,137 "updated_at": "2020-02-01T04:12:33.608Z",138 "reply_count": 0,139 "reply_to_post_number": 2,140 "quote_count": 0,141 "incoming_link_count": 3,142 "reads": 6,143 "readers_count": 5,144 "score": 16.2,145 "yours": false,146 "topic_id": 64770,147 "topic_slug": "if-you-save-a-dataparallel-model-do-i-have-to-again-run-nn-dataparallel-after-loading-it-back",148 "display_username": "",149 "primary_group_name": null,150 "flair_name": null,151 "flair_url": null,152 "flair_bg_color": null,153 "flair_color": null,154 "flair_group_id": null,155 "badges_granted": [],156 "version": 1,157 "can_edit": false,158 "can_delete": false,159 "can_recover": false,160 "can_see_hidden_post": false,161 "can_wiki": false,162 "read": true,163 "user_title": "",164 "reply_to_user": {165 "id": 3534,166 "username": "ptrblck",167 "name": "",168 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"169 },170 "bookmarked": false,171 "actions_summary": [],172 "moderator": false,173 "admin": false,174 "staff": false,175 "user_id": 24042,176 "hidden": false,177 "trust_level": 1,178 "deleted_at": null,179 "user_deleted": false,180 "edit_reason": null,181 "can_view_edit_history": true,182 "wiki": false,183 "post_url": "/t/if-you-save-a-dataparallel-model-do-i-have-to-again-run-nn-dataparallel-after-loading-it-back/64770/3",184 "can_accept_answer": false,185 "can_unaccept_answer": false,186 "accepted_answer": false,187 "topic_accepted_answer": null188 }189 ],190 "stream": [191 154411,192 154476,193 162508194 ]195 },196 "timeline_lookup": [197 [198 1,199 2134200 ],201 [202 3,203 2094204 ]205 ],206 "suggested_topics": [207 {208 "fancy_title": "Get int8 onnx format model",209 "id": 213636,210 "title": "Get int8 onnx format model",211 "slug": "get-int8-onnx-format-model",212 "posts_count": 3,213 "reply_count": 1,214 "highest_post_number": 3,215 "image_url": null,216 "created_at": "2024-11-30T14:00:20.834Z",217 "last_posted_at": "2024-12-02T05:43:39.388Z",218 "bumped": true,219 "bumped_at": "2024-12-02T05:43:39.388Z",220 "archetype": "regular",221 "unseen": false,222 "pinned": false,223 "unpinned": null,224 "visible": true,225 "closed": false,226 "archived": false,227 "bookmarked": null,228 "liked": null,229 "tags_descriptions": {},230 "like_count": 1,231 "views": 227,232 "category_id": 1,233 "featured_link": null,234 "has_accepted_answer": false,235 "posters": [236 {237 "extras": "latest single",238 "description": "Original Poster, Most Recent Poster",239 "user": {240 "id": 80928,241 "username": "xiangyun",242 "name": "",243 "avatar_template": "/letter_avatar_proxy/v4/letter/x/a4c791/{size}.png",244 "trust_level": 1245 }246 }247 ]248 },249 {250 "fancy_title": "Process Pool freezes",251 "id": 214981,252 "title": "Process Pool freezes",253 "slug": "process-pool-freezes",254 "posts_count": 1,255 "reply_count": 0,256 "highest_post_number": 1,257 "image_url": null,258 "created_at": "2025-01-04T22:52:42.533Z",259 "last_posted_at": "2025-01-04T22:52:42.574Z",260 "bumped": true,261 "bumped_at": "2025-01-04T22:52:42.574Z",262 "archetype": "regular",263 "unseen": false,264 "pinned": false,265 "unpinned": null,266 "visible": true,267 "closed": false,268 "archived": false,269 "bookmarked": null,270 "liked": null,271 "tags_descriptions": {},272 "like_count": 0,273 "views": 106,274 "category_id": 1,275 "featured_link": null,276 "has_accepted_answer": false,277 "posters": [278 {279 "extras": "latest single",280 "description": "Original Poster, Most Recent Poster",281 "user": {282 "id": 81433,283 "username": "ACitronella",284 "name": "",285 "avatar_template": "/letter_avatar_proxy/v4/letter/a/9fc29f/{size}.png",286 "trust_level": 1287 }288 }289 ]290 },291 {292 "fancy_title": "Cannot use Pytorch on A100-PCIE-40GB x 8",293 "id": 217645,294 "title": "Cannot use Pytorch on A100-PCIE-40GB x 8",295 "slug": "cannot-use-pytorch-on-a100-pcie-40gb-x-8",296 "posts_count": 2,297 "reply_count": 0,298 "highest_post_number": 2,299 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/7/9/795937cc6ed7ddfa911f1f34276df3bca234f2d9.png",300 "created_at": "2025-03-10T06:21:24.417Z",301 "last_posted_at": "2025-03-10T13:04:08.711Z",302 "bumped": true,303 "bumped_at": "2025-03-10T13:04:08.711Z",304 "archetype": "regular",305 "unseen": false,306 "pinned": false,307 "unpinned": null,308 "visible": true,309 "closed": false,310 "archived": false,311 "bookmarked": null,312 "liked": null,313 "tags_descriptions": {},314 "like_count": 1,315 "views": 40,316 "category_id": 1,317 "featured_link": null,318 "has_accepted_answer": false,319 "posters": [320 {321 "extras": null,322 "description": "Original Poster",323 "user": {324 "id": 83166,325 "username": "George_Polya",326 "name": "George Polya",327 "avatar_template": "/user_avatar/discuss.pytorch.org/george_polya/{size}/76064_2.png",328 "trust_level": 1329 }330 },331 {332 "extras": "latest",333 "description": "Most Recent Poster",334 "user": {335 "id": 3534,336 "username": "ptrblck",337 "name": "",338 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",339 "admin": true,340 "moderator": true,341 "trust_level": 2342 }343 }344 ]345 },346 {347 "fancy_title": "Avoid caching for parametrization",348 "id": 217737,349 "title": "Avoid caching for parametrization",350 "slug": "avoid-caching-for-parametrization",351 "posts_count": 1,352 "reply_count": 0,353 "highest_post_number": 1,354 "image_url": null,355 "created_at": "2025-03-12T09:48:21.626Z",356 "last_posted_at": "2025-03-12T09:48:21.666Z",357 "bumped": true,358 "bumped_at": "2025-03-12T09:48:21.666Z",359 "archetype": "regular",360 "unseen": false,361 "pinned": false,362 "unpinned": null,363 "visible": true,364 "closed": false,365 "archived": false,366 "bookmarked": null,367 "liked": null,368 "tags_descriptions": {},369 "like_count": 0,370 "views": 52,371 "category_id": 1,372 "featured_link": null,373 "has_accepted_answer": false,374 "posters": [375 {376 "extras": "latest single",377 "description": "Original Poster, Most Recent Poster",378 "user": {379 "id": 83213,380 "username": "Franckma",381 "name": "",382 "avatar_template": "/letter_avatar_proxy/v4/letter/f/ccd318/{size}.png",383 "trust_level": 1384 }385 }386 ]387 },388 {389 "fancy_title": "Is it possible to speedup the value assignment process in cuda tensor?",390 "id": 213154,391 "title": "Is it possible to speedup the value assignment process in cuda tensor?",392 "slug": "is-it-possible-to-speedup-the-value-assignment-process-in-cuda-tensor",393 "posts_count": 4,394 "reply_count": 2,395 "highest_post_number": 4,396 "image_url": null,397 "created_at": "2024-11-19T12:26:42.350Z",398 "last_posted_at": "2024-12-02T05:14:02.978Z",399 "bumped": true,400 "bumped_at": "2024-12-02T05:14:02.978Z",401 "archetype": "regular",402 "unseen": false,403 "pinned": false,404 "unpinned": null,405 "visible": true,406 "closed": false,407 "archived": false,408 "bookmarked": null,409 "liked": null,410 "tags_descriptions": {},411 "like_count": 0,412 "views": 214,413 "category_id": 1,414 "featured_link": null,415 "has_accepted_answer": false,416 "posters": [417 {418 "extras": "latest",419 "description": "Original Poster, Most Recent Poster",420 "user": {421 "id": 53919,422 "username": "zizhao.mo",423 "name": "z",424 "avatar_template": "/letter_avatar_proxy/v4/letter/z/0ea827/{size}.png",425 "trust_level": 1426 }427 },428 {429 "extras": null,430 "description": "Frequent Poster",431 "user": {432 "id": 3534,433 "username": "ptrblck",434 "name": "",435 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",436 "admin": true,437 "moderator": true,438 "trust_level": 2439 }440 }441 ]442 }443 ],444 "tags_descriptions": {},445 "fancy_title": "If you save a dataparallel model do I have to again run nn.DataParallel after loading it back?",446 "id": 64770,447 "title": "If you save a dataparallel model do I have to again run nn.DataParallel after loading it back?",448 "posts_count": 3,449 "created_at": "2019-12-22T18:48:12.273Z",450 "views": 339,451 "reply_count": 1,452 "like_count": 0,453 "last_posted_at": "2020-02-01T04:12:33.608Z",454 "visible": true,455 "closed": false,456 "archived": false,457 "has_summary": false,458 "archetype": "regular",459 "slug": "if-you-save-a-dataparallel-model-do-i-have-to-again-run-nn-dataparallel-after-loading-it-back",460 "category_id": 1,461 "word_count": 118,462 "deleted_at": null,463 "user_id": 24042,464 "featured_link": null,465 "pinned_globally": false,466 "pinned_at": null,467 "pinned_until": null,468 "image_url": null,469 "slow_mode_seconds": 0,470 "draft": null,471 "draft_key": "topic_64770",472 "draft_sequence": null,473 "unpinned": null,474 "pinned": false,475 "current_post_number": 1,476 "highest_post_number": 3,477 "deleted_by": null,478 "actions_summary": [479 {480 "id": 4,481 "count": 0,482 "hidden": false,483 "can_act": false484 },485 {486 "id": 8,487 "count": 0,488 "hidden": false,489 "can_act": false490 },491 {492 "id": 10,493 "count": 0,494 "hidden": false,495 "can_act": false496 },497 {498 "id": 7,499 "count": 0,500 "hidden": false,501 "can_act": false502 }503 ],504 "chunk_size": 20,505 "bookmarked": false,506 "topic_timer": null,507 "message_bus_last_id": 0,508 "participant_count": 2,509 "show_read_indicator": false,510 "thumbnails": null,511 "slow_mode_enabled_until": null,512 "can_vote": false,513 "vote_count": 0,514 "user_voted": false,515 "discourse_zendesk_plugin_zendesk_id": null,516 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",517 "details": {518 "can_edit": false,519 "notification_level": 1,520 "participants": [521 {522 "id": 24042,523 "username": "Shubhankar",524 "name": "",525 "avatar_template": "/letter_avatar_proxy/v4/letter/s/b9bd4f/{size}.png",526 "post_count": 2,527 "primary_group_name": null,528 "flair_name": null,529 "flair_url": null,530 "flair_color": null,531 "flair_bg_color": null,532 "flair_group_id": null,533 "trust_level": 1534 },535 {536 "id": 3534,537 "username": "ptrblck",538 "name": "",539 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",540 "post_count": 1,541 "primary_group_name": null,542 "flair_name": null,543 "flair_url": null,544 "flair_color": null,545 "flair_bg_color": null,546 "flair_group_id": null,547 "admin": true,548 "moderator": true,549 "trust_level": 2550 }551 ],552 "created_by": {553 "id": 24042,554 "username": "Shubhankar",555 "name": "",556 "avatar_template": "/letter_avatar_proxy/v4/letter/s/b9bd4f/{size}.png"557 },558 "last_poster": {559 "id": 24042,560 "username": "Shubhankar",561 "name": "",562 "avatar_template": "/letter_avatar_proxy/v4/letter/s/b9bd4f/{size}.png"563 },564 "links": [565 {566 "url": "https://pytorch.org/tutorials/beginner/saving_loading_models.html#saving-torch-nn-dataparallel-models",567 "title": "Saving and Loading Models โ PyTorch Tutorials 1.3.1 documentation",568 "internal": false,569 "attachment": false,570 "reflection": false,571 "clicks": 9,572 "user_id": 24042,573 "domain": "pytorch.org",574 "root_domain": "pytorch.org"575 }576 ]577 },578 "bookmarks": []579 },580 {581 "post_stream": {582 "posts": [583 {584 "id": 44182,585 "name": "Quan Vuong",586 "username": "Quan_Vuong",587 "avatar_template": "/letter_avatar_proxy/v4/letter/q/bc79bd/{size}.png",588 "created_at": "2018-04-29T18:04:53.855Z",589 "cooked": "<p>Assume we have a batch of data. Given each data point in the batch, I would like to get the norm of the gradient of the output of the network w.r.t the network parameters.</p>\n<p>A naive solution is to perform multiple forward and backward passes (one pass for one data point), but this is pretty slow. Is there a better solution?</p>\n<p>A better solution seems possible, but I donโt see any mention of it in Pytorch documentation.</p>\n<p><a href=\"https://arxiv.org/abs/1510.01799\" class=\"onebox\" target=\"_blank\" rel=\"nofollow noopener\">https://arxiv.org/abs/1510.01799</a></p>",590 "post_number": 1,591 "post_type": 1,592 "posts_count": 6,593 "updated_at": "2018-04-29T18:04:53.855Z",594 "reply_count": 0,595 "reply_to_post_number": null,596 "quote_count": 0,597 "incoming_link_count": 1122,598 "reads": 106,599 "readers_count": 105,600 "score": 5656.2,601 "yours": false,602 "topic_id": 17204,603 "topic_slug": "efficient-per-example-gradient-computations",604 "display_username": "Quan Vuong",605 "primary_group_name": null,606 "flair_name": null,607 "flair_url": null,608 "flair_bg_color": null,609 "flair_color": null,610 "flair_group_id": null,611 "badges_granted": [],612 "version": 1,613 "can_edit": false,614 "can_delete": false,615 "can_recover": false,616 "can_see_hidden_post": false,617 "can_wiki": false,618 "link_counts": [619 {620 "url": "https://arxiv.org/abs/1510.01799",621 "internal": false,622 "reflection": false,623 "title": "[1510.01799] Efficient Per-Example Gradient Computations",624 "clicks": 112625 }626 ],627 "read": true,628 "user_title": null,629 "bookmarked": false,630 "actions_summary": [631 {632 "id": 2,633 "count": 2634 }635 ],636 "moderator": false,637 "admin": false,638 "staff": false,639 "user_id": 2318,640 "hidden": false,641 "trust_level": 1,642 "deleted_at": null,643 "user_deleted": false,644 "edit_reason": null,645 "can_view_edit_history": true,646 "wiki": false,647 "post_url": "/t/efficient-per-example-gradient-computations/17204/1",648 "can_accept_answer": false,649 "can_unaccept_answer": false,650 "accepted_answer": false,651 "topic_accepted_answer": null,652 "can_vote": false653 },654 {655 "id": 103853,656 "name": "Irene Li",657 "username": "Irene_Li",658 "avatar_template": "/user_avatar/discuss.pytorch.org/irene_li/{size}/10681_2.png",659 "created_at": "2019-04-04T18:46:58.299Z",660 "cooked": "<p>Hi,</p>\n<blockquote>\n<p>A naive solution is to perform multiple forward and backward passes (one pass for one data point), but this is pretty slow.</p>\n</blockquote>\n<p>Do you mean to feed the data points within a for-loop one by one? I donโt think this will be right because PyTorch is doing accumulation on the gradients.</p>\n<p>Thanks.</p>",661 "post_number": 2,662 "post_type": 1,663 "posts_count": 6,664 "updated_at": "2019-04-04T18:46:58.299Z",665 "reply_count": 0,666 "reply_to_post_number": null,667 "quote_count": 0,668 "incoming_link_count": 51,669 "reads": 86,670 "readers_count": 85,671 "score": 272.2,672 "yours": false,673 "topic_id": 17204,674 "topic_slug": "efficient-per-example-gradient-computations",675 "display_username": "Irene Li",676 "primary_group_name": null,677 "flair_name": null,678 "flair_url": null,679 "flair_bg_color": null,680 "flair_color": null,681 "flair_group_id": null,682 "badges_granted": [],683 "version": 1,684 "can_edit": false,685 "can_delete": false,686 "can_recover": false,687 "can_see_hidden_post": false,688 "can_wiki": false,689 "read": true,690 "user_title": null,691 "bookmarked": false,692 "actions_summary": [],693 "moderator": false,694 "admin": false,695 "staff": false,696 "user_id": 17303,697 "hidden": false,698 "trust_level": 1,699 "deleted_at": null,700 "user_deleted": false,701 "edit_reason": null,702 "can_view_edit_history": true,703 "wiki": false,704 "post_url": "/t/efficient-per-example-gradient-computations/17204/2",705 "can_accept_answer": false,706 "can_unaccept_answer": false,707 "accepted_answer": false,708 "topic_accepted_answer": null709 },710 {711 "id": 137179,712 "name": "Yaroslav Bulatov",713 "username": "Yaroslav_Bulatov",714 "avatar_template": "/user_avatar/discuss.pytorch.org/yaroslav_bulatov/{size}/7017_2.png",715 "created_at": "2019-09-27T20:46:35.648Z",716 "cooked": "<p>If you just have conv2d + linear layers, you could do this using single backward pass using something like this โ <a href=\"https://github.com/cybertronai/autograd-hacks/blob/master/autograd_hacks.py#L167\" rel=\"nofollow noopener\">https://github.com/cybertronai/autograd-hacks/blob/master/autograd_hacks.py#L167</a></p>\n<p>For norms squared, replace โgrad1=einsumโ line with <code>torch.sum(B*B, dim=1)*torch.sum(A*A, dim=1)</code></p>",717 "post_number": 3,718 "post_type": 1,719 "posts_count": 6,720 "updated_at": "2019-10-08T00:48:52.845Z",721 "reply_count": 0,722 "reply_to_post_number": null,723 "quote_count": 0,724 "incoming_link_count": 24,725 "reads": 71,726 "readers_count": 70,727 "score": 164.2,728 "yours": false,729 "topic_id": 17204,730 "topic_slug": "efficient-per-example-gradient-computations",731 "display_username": "Yaroslav Bulatov",732 "primary_group_name": null,733 "flair_name": null,734 "flair_url": null,735 "flair_bg_color": null,736 "flair_color": null,737 "flair_group_id": null,738 "badges_granted": [],739 "version": 2,740 "can_edit": false,741 "can_delete": false,742 "can_recover": false,743 "can_see_hidden_post": false,744 "can_wiki": false,745 "link_counts": [746 {747 "url": "https://github.com/cybertronai/autograd-hacks/blob/master/autograd_hacks.py#L167",748 "internal": false,749 "reflection": false,750 "title": "autograd-hacks/autograd_hacks.py at master ยท cybertronai/autograd-hacks ยท GitHub",751 "clicks": 116752 },753 {754 "url": "https://discuss.pytorch.org/t/compute-squared-gradient/61090/3",755 "internal": true,756 "reflection": true,757 "title": "Compute squared gradient",758 "clicks": 7759 }760 ],761 "read": true,762 "user_title": null,763 "bookmarked": false,764 "actions_summary": [765 {766 "id": 2,767 "count": 2768 }769 ],770 "moderator": false,771 "admin": false,772 "staff": false,773 "user_id": 11965,774 "hidden": false,775 "trust_level": 2,776 "deleted_at": null,777 "user_deleted": false,778 "edit_reason": null,779 "can_view_edit_history": true,780 "wiki": false,781 "post_url": "/t/efficient-per-example-gradient-computations/17204/3",782 "can_accept_answer": false,783 "can_unaccept_answer": false,784 "accepted_answer": false,785 "topic_accepted_answer": null786 },787 {788 "id": 160523,789 "name": "Edward Z Yang",790 "username": "ezyang",791 "avatar_template": "/user_avatar/discuss.pytorch.org/ezyang/{size}/486_2.png",792 "created_at": "2020-01-23T17:46:32.000Z",793 "cooked": "<p>You can do per example gradients using torch.autograd.grad. The key trick is to manually broadcast the weights yourself, and then differentiate with respect to the broadcasted weight. Hereโs a very simple example on a model that is just a Linear:</p>\n<pre><code class=\"lang-auto\">import torch\n\ntorch.manual_seed(0)\n\nB = 4\nN = 2\nM = 3\n\ninput = torch.randn(B, 1, N)\nweights = torch.randn(N, M, requires_grad=True)\n\nbroadcasted_weights = weights.expand(B, N, M)\noutput = torch.bmm(input, broadcasted_weights)\nloss = output.sum()\n\nprint(torch.autograd.grad(loss, broadcasted_weights))\n</code></pre>\n<p>I donโt know if you can conveniently do this with torch.nn modules, might be worth thinking about how to expose this in the API.</p>",794 "post_number": 4,795 "post_type": 1,796 "posts_count": 6,797 "updated_at": "2020-01-23T17:46:32.000Z",798 "reply_count": 1,799 "reply_to_post_number": null,800 "quote_count": 0,801 "incoming_link_count": 26,802 "reads": 60,803 "readers_count": 59,804 "score": 271.0,805 "yours": false,806 "topic_id": 17204,807 "topic_slug": "efficient-per-example-gradient-computations",808 "display_username": "Edward Z Yang",809 "primary_group_name": null,810 "flair_name": null,811 "flair_url": null,812 "flair_bg_color": null,813 "flair_color": null,814 "flair_group_id": null,815 "badges_granted": [],816 "version": 1,817 "can_edit": false,818 "can_delete": false,819 "can_recover": false,820 "can_see_hidden_post": false,821 "can_wiki": false,822 "read": true,823 "user_title": null,824 "bookmarked": false,825 "actions_summary": [826 {827 "id": 2,828 "count": 2829 }830 ],831 "moderator": true,832 "admin": false,833 "staff": true,834 "user_id": 999,835 "hidden": false,836 "trust_level": 3,837 "deleted_at": null,838 "user_deleted": false,839 "edit_reason": null,840 "can_view_edit_history": true,841 "wiki": false,842 "post_url": "/t/efficient-per-example-gradient-computations/17204/4",843 "can_accept_answer": false,844 "can_unaccept_answer": false,845 "accepted_answer": false,846 "topic_accepted_answer": null847 },848 {849 "id": 160530,850 "name": "Edward Z Yang",851 "username": "ezyang",852 "avatar_template": "/user_avatar/discuss.pytorch.org/ezyang/{size}/486_2.png",853 "created_at": "2020-01-23T18:21:44.555Z",854 "cooked": "<p>Note this doesnโt work if you have operations in your network that implicitly broadcast, but donโt support taking broadcasted input. Convolution is an example of this.</p>",855 "post_number": 5,856 "post_type": 1,857 "posts_count": 6,858 "updated_at": "2020-01-23T18:21:44.555Z",859 "reply_count": 0,860 "reply_to_post_number": null,861 "quote_count": 0,862 "incoming_link_count": 10,863 "reads": 58,864 "readers_count": 57,865 "score": 76.6,866 "yours": false,867 "topic_id": 17204,868 "topic_slug": "efficient-per-example-gradient-computations",869 "display_username": "Edward Z Yang",870 "primary_group_name": null,871 "flair_name": null,872 "flair_url": null,873 "flair_bg_color": null,874 "flair_color": null,875 "flair_group_id": null,876 "badges_granted": [],877 "version": 1,878 "can_edit": false,879 "can_delete": false,880 "can_recover": false,881 "can_see_hidden_post": false,882 "can_wiki": false,883 "read": true,884 "user_title": null,885 "bookmarked": false,886 "actions_summary": [887 {888 "id": 2,889 "count": 1890 }891 ],892 "moderator": true,893 "admin": false,894 "staff": true,895 "user_id": 999,896 "hidden": false,897 "trust_level": 3,898 "deleted_at": null,899 "user_deleted": false,900 "edit_reason": null,901 "can_view_edit_history": true,902 "wiki": false,903 "post_url": "/t/efficient-per-example-gradient-computations/17204/5",904 "can_accept_answer": false,905 "can_unaccept_answer": false,906 "accepted_answer": false,907 "topic_accepted_answer": null908 },909 {910 "id": 162507,911 "name": "Yaroslav Bulatov",912 "username": "Yaroslav_Bulatov",913 "avatar_template": "/user_avatar/discuss.pytorch.org/yaroslav_bulatov/{size}/7017_2.png",914 "created_at": "2020-02-01T03:32:37.361Z",915 "cooked": "<p>Simple API would be a helper function that takes an nn.Module and returns a version that implements the trick above. IE, model = batch_expand(model, N)</p>\n<p>Autograd memory usage in new model has to be reasonable, otherwise thereโs no benefit over original model and batch-size=1.</p>\n<p>This seems to be the case in the example above (colab measurement <a href=\"https://colab.research.google.com/drive/1Lp1Y_ZGhi7FsPQajavpmqHWHICoRYctA#scrollTo=LsNjgyy7kVFj\" rel=\"nofollow noopener\">forum - replication memory - simplified</a>)</p>",916 "post_number": 7,917 "post_type": 1,918 "posts_count": 6,919 "updated_at": "2020-02-01T03:32:37.361Z",920 "reply_count": 0,921 "reply_to_post_number": 4,922 "quote_count": 0,923 "incoming_link_count": 8,924 "reads": 51,925 "readers_count": 50,926 "score": 65.2,927 "yours": false,928 "topic_id": 17204,929 "topic_slug": "efficient-per-example-gradient-computations",930 "display_username": "Yaroslav Bulatov",931 "primary_group_name": null,932 "flair_name": null,933 "flair_url": null,934 "flair_bg_color": null,935 "flair_color": null,936 "flair_group_id": null,937 "badges_granted": [],938 "version": 1,939 "can_edit": false,940 "can_delete": false,941 "can_recover": false,942 "can_see_hidden_post": false,943 "can_wiki": false,944 "link_counts": [945 {946 "url": "https://colab.research.google.com/drive/1Lp1Y_ZGhi7FsPQajavpmqHWHICoRYctA#scrollTo=LsNjgyy7kVFj",947 "internal": false,948 "reflection": false,949 "clicks": 27950 }951 ],952 "read": true,953 "user_title": null,954 "reply_to_user": {955 "id": 999,956 "username": "ezyang",957 "name": "Edward Z Yang",958 "avatar_template": "/user_avatar/discuss.pytorch.org/ezyang/{size}/486_2.png"959 },960 "bookmarked": false,961 "actions_summary": [962 {963 "id": 2,964 "count": 1965 }966 ],967 "moderator": false,968 "admin": false,969 "staff": false,970 "user_id": 11965,971 "hidden": false,972 "trust_level": 2,973 "deleted_at": null,974 "user_deleted": false,975 "edit_reason": null,976 "can_view_edit_history": true,977 "wiki": false,978 "post_url": "/t/efficient-per-example-gradient-computations/17204/7",979 "can_accept_answer": false,980 "can_unaccept_answer": false,981 "accepted_answer": false,982 "topic_accepted_answer": null983 }984 ],985 "stream": [986 44182,987 103853,988 137179,989 160523,990 160530,991 162507992 ]993 },994 "timeline_lookup": [995 [996 1,997 2736998 ],999 [1000 2,1001 23961002 ],1003 [1004 3,1005 22201006 ],1007 [1008 4,1009 21021010 ],1011 [1012 6,1013 20941014 ]1015 ],1016 "suggested_topics": [1017 {1018 "fancy_title": "Gradient computation with PyTorch autograd with 1th and 2th order derivatives does not work",1019 "id": 216580,1020 "title": "Gradient computation with PyTorch autograd with 1th and 2th order derivatives does not work",1021 "slug": "gradient-computation-with-pytorch-autograd-with-1th-and-2th-order-derivatives-does-not-work",1022 "posts_count": 2,1023 "reply_count": 0,1024 "highest_post_number": 2,1025 "image_url": null,1026 "created_at": "2025-02-12T13:12:01.888Z",1027 "last_posted_at": "2025-02-15T01:35:32.749Z",1028 "bumped": true,1029 "bumped_at": "2025-02-15T01:35:32.749Z",1030 "archetype": "regular",1031 "unseen": false,1032 "pinned": false,1033 "unpinned": null,1034 "visible": true,1035 "closed": false,1036 "archived": false,1037 "bookmarked": null,1038 "liked": null,1039 "tags_descriptions": {},1040 "like_count": 1,1041 "views": 67,1042 "category_id": 7,1043 "featured_link": null,1044 "has_accepted_answer": true,1045 "posters": [1046 {1047 "extras": null,1048 "description": "Original Poster",1049 "user": {1050 "id": 82645,1051 "username": "woutr",1052 "name": "",1053 "avatar_template": "/letter_avatar_proxy/v4/letter/w/6f9a4e/{size}.png",1054 "trust_level": 11055 }1056 },1057 {1058 "extras": "latest",1059 "description": "Most Recent Poster, Accepted Answer",1060 "user": {1061 "id": 18088,1062 "username": "KFrank",1063 "name": "K. Frank",1064 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",1065 "trust_level": 21066 }1067 }1068 ]1069 },1070 {1071 "fancy_title": "Where can I find the backward function of torch.nn.functional.interpolate function?",1072 "id": 213447,1073 "title": "Where can I find the backward function of torch.nn.functional.interpolate function?",1074 "slug": "where-can-i-find-the-backward-function-of-torch-nn-functional-interpolate-function",1075 "posts_count": 6,1076 "reply_count": 4,1077 "highest_post_number": 7,1078 "image_url": null,1079 "created_at": "2024-11-26T07:45:06.369Z",1080 "last_posted_at": "2024-11-29T14:20:26.725Z",1081 "bumped": true,1082 "bumped_at": "2024-11-29T14:20:26.725Z",1083 "archetype": "regular",1084 "unseen": false,1085 "pinned": false,1086 "unpinned": null,1087 "visible": true,1088 "closed": false,1089 "archived": false,1090 "bookmarked": null,1091 "liked": null,1092 "tags_descriptions": {},1093 "like_count": 0,1094 "views": 77,1095 "category_id": 7,1096 "featured_link": null,1097 "has_accepted_answer": false,1098 "posters": [1099 {1100 "extras": null,1101 "description": "Original Poster",1102 "user": {1103 "id": 80910,1104 "username": "hao_xi",1105 "name": "hao xi",1106 "avatar_template": "/user_avatar/discuss.pytorch.org/hao_xi/{size}/73993_2.png",1107 "trust_level": 11108 }1109 },1110 {1111 "extras": null,1112 "description": "Frequent Poster",1113 "user": {1114 "id": 81138,1115 "username": "ruby05guy",1116 "name": null,1117 "avatar_template": "/letter_avatar_proxy/v4/letter/r/c57346/{size}.png",1118 "trust_level": 01119 }1120 },1121 {1122 "extras": "latest",1123 "description": "Most Recent Poster",1124 "user": {1125 "id": 3534,1126 "username": "ptrblck",1127 "name": "",1128 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1129 "admin": true,1130 "moderator": true,1131 "trust_level": 21132 }1133 }1134 ]1135 },1136 {1137 "fancy_title": "Second order derivative with torch.autograd.function",1138 "id": 213752,1139 "title": "Second order derivative with torch.autograd.function",1140 "slug": "second-order-derivative-with-torch-autograd-function",1141 "posts_count": 2,1142 "reply_count": 0,1143 "highest_post_number": 2,1144 "image_url": null,1145 "created_at": "2024-12-03T16:14:45.025Z",1146 "last_posted_at": "2024-12-03T22:09:09.293Z",1147 "bumped": true,1148 "bumped_at": "2024-12-03T22:09:09.293Z",1149 "archetype": "regular",1150 "unseen": false,1151 "pinned": false,1152 "unpinned": null,1153 "visible": true,1154 "closed": false,1155 "archived": false,1156 "bookmarked": null,1157 "liked": null,1158 "tags_descriptions": {},1159 "like_count": 0,1160 "views": 229,1161 "category_id": 7,1162 "featured_link": null,1163 "has_accepted_answer": false,1164 "posters": [1165 {1166 "extras": null,1167 "description": "Original Poster",1168 "user": {1169 "id": 63171,1170 "username": "bpfrd",1171 "name": "bpfrd",1172 "avatar_template": "/user_avatar/discuss.pytorch.org/bpfrd/{size}/57126_2.png",1173 "trust_level": 11174 }1175 },1176 {1177 "extras": "latest",1178 "description": "Most Recent Poster",1179 "user": {1180 "id": 34294,1181 "username": "AlphaBetaGamma96",1182 "name": "",1183 "avatar_template": "/letter_avatar_proxy/v4/letter/a/3da27b/{size}.png",1184 "trust_level": 21185 }1186 }1187 ]1188 },1189 {1190 "fancy_title": "How to represent the jacobian of a function where the domain field is from a cartesian product",1191 "id": 213028,1192 "title": "How to represent the jacobian of a function where the domain field is from a cartesian product",1193 "slug": "how-to-represent-the-jacobian-of-a-function-where-the-domain-field-is-from-a-cartesian-product",1194 "posts_count": 2,1195 "reply_count": 0,1196 "highest_post_number": 2,1197 "image_url": null,1198 "created_at": "2024-11-15T21:43:56.315Z",1199 "last_posted_at": "2024-11-16T23:26:57.852Z",1200 "bumped": true,