{"action":"created","comment":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/209111595","pull_request_review_id":145064871,"id":209111595,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTExMTU5NQ==","diff_hunk":"@@ -418,9 +433,56 @@ def test_variable_sharing(self):\n                            requires_grad=requires_grad)\n             self._test_autograd_sharing(var)\n \n+    def test_leaf_variable_sharing(self):\n+        devices = ['cpu']\n+        if torch.cuda.is_available() and not NO_MULTIPROCESSING_SPAWN and TEST_CUDA_IPC:\n+            devices.append('cuda')\n+        for device in devices:\n+            for requires_grad in [True, False]:\n+                var = Variable(torch.arange(1., 26, device=device).view(5, 5), requires_grad=requires_grad)","path":"test/test_multiprocessing.py","position":98,"original_position":98,"commit_id":"a6213c30d8f34a62e2a1d1cdf8e4dcf5d1f6e3ad","original_commit_id":"a6213c30d8f34a62e2a1d1cdf8e4dcf5d1f6e3ad","user":{"login":"colesbury","id":655866,"node_id":"MDQ6VXNlcjY1NTg2Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/655866?v=4","gravatar_id":"","url":"https://api.github.com/users/colesbury","html_url":"https://github.com/colesbury","followers_url":"https://api.github.com/users/colesbury/followers","following_url":"https://api.github.com/users/colesbury/following{/other_user}","gists_url":"https://api.github.com/users/colesbury/gists{/gist_id}","starred_url":"https://api.github.com/users/colesbury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colesbury/subscriptions","organizations_url":"https://api.github.com/users/colesbury/orgs","repos_url":"https://api.github.com/users/colesbury/repos","events_url":"https://api.github.com/users/colesbury/events{/privacy}","received_events_url":"https://api.github.com/users/colesbury/received_events","type":"User","site_admin":false},"body":"Avoid using Variable in new code. (Use `torch.arange(1., 26, device=device).view(5, 5).requires_grad_(requires_grad)` instead)","created_at":"2018-08-09T23:46:25Z","updated_at":"2018-08-09T23:47:17Z","html_url":"https://github.com/pytorch/pytorch/pull/10220#discussion_r209111595","pull_request_url":"https://api.github.com/repos/pytorch/pytorch/pulls/10220","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/209111595"},"html":{"href":"https://github.com/pytorch/pytorch/pull/10220#discussion_r209111595"},"pull_request":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10220"}}},"pull_request":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/10220","id":206134719,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2MTM0NzE5","html_url":"https://github.com/pytorch/pytorch/pull/10220","diff_url":"https://github.com/pytorch/pytorch/pull/10220.diff","patch_url":"https://github.com/pytorch/pytorch/pull/10220.patch","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/10220","number":10220,"state":"open","locked":false,"title":"Correctly share CUDA Parameters.","user":{"login":"ezyang","id":13564,"node_id":"MDQ6VXNlcjEzNTY0","avatar_url":"https://avatars0.githubusercontent.com/u/13564?v=4","gravatar_id":"","url":"https://api.github.com/users/ezyang","html_url":"https://github.com/ezyang","followers_url":"https://api.github.com/users/ezyang/followers","following_url":"https://api.github.com/users/ezyang/following{/other_user}","gists_url":"https://api.github.com/users/ezyang/gists{/gist_id}","starred_url":"https://api.github.com/users/ezyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezyang/subscriptions","organizations_url":"https://api.github.com/users/ezyang/orgs","repos_url":"https://api.github.com/users/ezyang/repos","events_url":"https://api.github.com/users/ezyang/events{/privacy}","received_events_url":"https://api.github.com/users/ezyang/received_events","type":"User","site_admin":false},"body":"```\r\n    Correctly share CUDA Parameters, requires_grad and hooks.\r\n    \r\n    Previously, the following was true:\r\n    \r\n    - If you put a Parameter for a CUDA tensor\r\n      in multiprocessing queue (or otherwise tried to transfer it),\r\n      this failed, saying that we cannot pickle CUDA storage.\r\n      This is issue #9996.\r\n    \r\n    - If you put a leaf Tensor that requires_grad=True through the\r\n      multiprocessing queue, it would come out the other end as\r\n      requires_grad=False (It should have come out the other end\r\n      as requires_grad=True).  Similarly, backwards hooks were\r\n      lost.\r\n    \r\n    - If you put a non-leaf Tensor that requires_grad=True through\r\n      the multiprocessing queue, it would come out the other end\r\n      as requires_grad=False.\r\n    \r\n    The root cause for the first issue was that implementation of\r\n    reductions for Parameter used the superclass implementation\r\n    (tensor) in __reduce_ex__, but this always picks up the\r\n    non-ForkingPickler reduction, which doesn't work with CUDA tensors.\r\n    So, we registered a new ForkingPickler specifically for Parameter,\r\n    and adjusted the code to correctly rewrap a Tensor in a Parameter\r\n    if it was originally a parameter.\r\n        \r\n    While working on this, we realized that requires_grad and backwards\r\n    hooks would not be preserved in the ForkingPickler reduction\r\n    implementation.  We fixed the reducer to save these parameters.\r\n    However, Adam Paszke pointed out that we shouldn't allow sending\r\n    requires_grad=True, non-leaf Tensors over a multiprocessing\r\n    queue, since we don't actually support autograd over process\r\n    boundar.  We now throw an error in this case; this may cause\r\n    previously working code to fail, but this is easy enough to fix;\r\n    just detach() the tensor before sending it.  The error message says\r\n    so.\r\n    \r\n    Fixes #9996.\r\n```","created_at":"2018-08-03T20:45:47Z","updated_at":"2018-08-09T23:47:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"88dc6fe35c45249d9c3d63ab5191512d5509c2a1","assignee":null,"assignees":[],"requested_reviewers":[{"login":"zdevito","id":370202,"node_id":"MDQ6VXNlcjM3MDIwMg==","avatar_url":"https://avatars0.githubusercontent.com/u/370202?v=4","gravatar_id":"","url":"https://api.github.com/users/zdevito","html_url":"https://github.com/zdevito","followers_url":"https://api.github.com/users/zdevito/followers","following_url":"https://api.github.com/users/zdevito/following{/other_user}","gists_url":"https://api.github.com/users/zdevito/gists{/gist_id}","starred_url":"https://api.github.com/users/zdevito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zdevito/subscriptions","organizations_url":"https://api.github.com/users/zdevito/orgs","repos_url":"https://api.github.com/users/zdevito/repos","events_url":"https://api.github.com/users/zdevito/events{/privacy}","received_events_url":"https://api.github.com/users/zdevito/received_events","type":"User","site_admin":false},{"login":"soumith","id":1310570,"node_id":"MDQ6VXNlcjEzMTA1NzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1310570?v=4","gravatar_id":"","url":"https://api.github.com/users/soumith","html_url":"https://github.com/soumith","followers_url":"https://api.github.com/users/soumith/followers","following_url":"https://api.github.com/users/soumith/following{/other_user}","gists_url":"https://api.github.com/users/soumith/gists{/gist_id}","starred_url":"https://api.github.com/users/soumith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soumith/subscriptions","organizations_url":"https://api.github.com/users/soumith/orgs","repos_url":"https://api.github.com/users/soumith/repos","events_url":"https://api.github.com/users/soumith/events{/privacy}","received_events_url":"https://api.github.com/users/soumith/received_events","type":"User","site_admin":false},{"login":"gchanan","id":3768583,"node_id":"MDQ6VXNlcjM3Njg1ODM=","avatar_url":"https://avatars2.githubusercontent.com/u/3768583?v=4","gravatar_id":"","url":"https://api.github.com/users/gchanan","html_url":"https://github.com/gchanan","followers_url":"https://api.github.com/users/gchanan/followers","following_url":"https://api.github.com/users/gchanan/following{/other_user}","gists_url":"https://api.github.com/users/gchanan/gists{/gist_id}","starred_url":"https://api.github.com/users/gchanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gchanan/subscriptions","organizations_url":"https://api.github.com/users/gchanan/orgs","repos_url":"https://api.github.com/users/gchanan/repos","events_url":"https://api.github.com/users/gchanan/events{/privacy}","received_events_url":"https://api.github.com/users/gchanan/received_events","type":"User","site_admin":false},{"login":"apaszke","id":4583066,"node_id":"MDQ6VXNlcjQ1ODMwNjY=","avatar_url":"https://avatars3.githubusercontent.com/u/4583066?v=4","gravatar_id":"","url":"https://api.github.com/users/apaszke","html_url":"https://github.com/apaszke","followers_url":"https://api.github.com/users/apaszke/followers","following_url":"https://api.github.com/users/apaszke/following{/other_user}","gists_url":"https://api.github.com/users/apaszke/gists{/gist_id}","starred_url":"https://api.github.com/users/apaszke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apaszke/subscriptions","organizations_url":"https://api.github.com/users/apaszke/orgs","repos_url":"https://api.github.com/users/apaszke/repos","events_url":"https://api.github.com/users/apaszke/events{/privacy}","received_events_url":"https://api.github.com/users/apaszke/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pytorch/pytorch/pulls/10220/commits","review_comments_url":"https://api.github.com/repos/pytorch/pytorch/pulls/10220/comments","review_comment_url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/10220/comments","statuses_url":"https://api.github.com/repos/pytorch/pytorch/statuses/a6213c30d8f34a62e2a1d1cdf8e4dcf5d1f6e3ad","head":{"label":"ezyang:pr/fix-cuda-parameter-sharing","ref":"pr/fix-cuda-parameter-sharing","sha":"a6213c30d8f34a62e2a1d1cdf8e4dcf5d1f6e3ad","user":{"login":"ezyang","id":13564,"node_id":"MDQ6VXNlcjEzNTY0","avatar_url":"https://avatars0.githubusercontent.com/u/13564?v=4","gravatar_id":"","url":"https://api.github.com/users/ezyang","html_url":"https://github.com/ezyang","followers_url":"https://api.github.com/users/ezyang/followers","following_url":"https://api.github.com/users/ezyang/following{/other_user}","gists_url":"https://api.github.com/users/ezyang/gists{/gist_id}","starred_url":"https://api.github.com/users/ezyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezyang/subscriptions","organizations_url":"https://api.github.com/users/ezyang/orgs","repos_url":"https://api.github.com/users/ezyang/repos","events_url":"https://api.github.com/users/ezyang/events{/privacy}","received_events_url":"https://api.github.com/users/ezyang/received_events","type":"User","site_admin":false},"repo":{"id":101798885,"node_id":"MDEwOlJlcG9zaXRvcnkxMDE3OTg4ODU=","name":"pytorch","full_name":"ezyang/pytorch","owner":{"login":"ezyang","id":13564,"node_id":"MDQ6VXNlcjEzNTY0","avatar_url":"https://avatars0.githubusercontent.com/u/13564?v=4","gravatar_id":"","url":"https://api.github.com/users/ezyang","html_url":"https://github.com/ezyang","followers_url":"https://api.github.com/users/ezyang/followers","following_url":"https://api.github.com/users/ezyang/following{/other_user}","gists_url":"https://api.github.com/users/ezyang/gists{/gist_id}","starred_url":"https://api.github.com/users/ezyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezyang/subscriptions","organizations_url":"https://api.github.com/users/ezyang/orgs","repos_url":"https://api.github.com/users/ezyang/repos","events_url":"https://api.github.com/users/ezyang/events{/privacy}","received_events_url":"https://api.github.com/users/ezyang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ezyang/pytorch","description":"Tensors and Dynamic neural networks in Python  with strong GPU acceleration","fork":true,"url":"https://api.github.com/repos/ezyang/pytorch","forks_url":"https://api.github.com/repos/ezyang/pytorch/forks","keys_url":"https://api.github.com/repos/ezyang/pytorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezyang/pytorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezyang/pytorch/teams","hooks_url":"https://api.github.com/repos/ezyang/pytorch/hooks","issue_events_url":"https://api.github.com/repos/ezyang/pytorch/issues/events{/number}","events_url":"https://api.github.com/repos/ezyang/pytorch/events","assignees_url":"https://api.github.com/repos/ezyang/pytorch/assignees{/user}","branches_url":"https://api.github.com/repos/ezyang/pytorch/branches{/branch}","tags_url":"https://api.github.com/repos/ezyang/pytorch/tags","blobs_url":"https://api.github.com/repos/ezyang/pytorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezyang/pytorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezyang/pytorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezyang/pytorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezyang/pytorch/statuses/{sha}","languages_url":"https://api.github.com/repos/ezyang/pytorch/languages","stargazers_url":"https://api.github.com/repos/ezyang/pytorch/stargazers","contributors_url":"https://api.github.com/repos/ezyang/pytorch/contributors","subscribers_url":"https://api.github.com/repos/ezyang/pytorch/subscribers","subscription_url":"https://api.github.com/repos/ezyang/pytorch/subscription","commits_url":"https://api.github.com/repos/ezyang/pytorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezyang/pytorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezyang/pytorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezyang/pytorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezyang/pytorch/contents/{+path}","compare_url":"https://api.github.com/repos/ezyang/pytorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezyang/pytorch/merges","archive_url":"https://api.github.com/repos/ezyang/pytorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezyang/pytorch/downloads","issues_url":"https://api.github.com/repos/ezyang/pytorch/issues{/number}","pulls_url":"https://api.github.com/repos/ezyang/pytorch/pulls{/number}","milestones_url":"https://api.github.com/repos/ezyang/pytorch/milestones{/number}","notifications_url":"https://api.github.com/repos/ezyang/pytorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezyang/pytorch/labels{/name}","releases_url":"https://api.github.com/repos/ezyang/pytorch/releases{/id}","deployments_url":"https://api.github.com/repos/ezyang/pytorch/deployments","created_at":"2017-08-29T19:28:39Z","updated_at":"2018-07-02T18:14:07Z","pushed_at":"2018-08-07T22:01:36Z","git_url":"git://github.com/ezyang/pytorch.git","ssh_url":"git@github.com:ezyang/pytorch.git","clone_url":"https://github.com/ezyang/pytorch.git","svn_url":"https://github.com/ezyang/pytorch","homepage":"http://pytorch.org","size":68307,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"pytorch:master","ref":"master","sha":"6ac35b35d12b65851f3269b838dc36d64e97237b","user":{"login":"pytorch","id":21003710,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMDAzNzEw","avatar_url":"https://avatars3.githubusercontent.com/u/21003710?v=4","gravatar_id":"","url":"https://api.github.com/users/pytorch","html_url":"https://github.com/pytorch","followers_url":"https://api.github.com/users/pytorch/followers","following_url":"https://api.github.com/users/pytorch/following{/other_user}","gists_url":"https://api.github.com/users/pytorch/gists{/gist_id}","starred_url":"https://api.github.com/users/pytorch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytorch/subscriptions","organizations_url":"https://api.github.com/users/pytorch/orgs","repos_url":"https://api.github.com/users/pytorch/repos","events_url":"https://api.github.com/users/pytorch/events{/privacy}","received_events_url":"https://api.github.com/users/pytorch/received_events","type":"Organization","site_admin":false},"repo":{"id":65600975,"node_id":"MDEwOlJlcG9zaXRvcnk2NTYwMDk3NQ==","name":"pytorch","full_name":"pytorch/pytorch","owner":{"login":"pytorch","id":21003710,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMDAzNzEw","avatar_url":"https://avatars3.githubusercontent.com/u/21003710?v=4","gravatar_id":"","url":"https://api.github.com/users/pytorch","html_url":"https://github.com/pytorch","followers_url":"https://api.github.com/users/pytorch/followers","following_url":"https://api.github.com/users/pytorch/following{/other_user}","gists_url":"https://api.github.com/users/pytorch/gists{/gist_id}","starred_url":"https://api.github.com/users/pytorch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytorch/subscriptions","organizations_url":"https://api.github.com/users/pytorch/orgs","repos_url":"https://api.github.com/users/pytorch/repos","events_url":"https://api.github.com/users/pytorch/events{/privacy}","received_events_url":"https://api.github.com/users/pytorch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pytorch/pytorch","description":"Tensors and Dynamic neural networks in Python  with strong GPU acceleration","fork":false,"url":"https://api.github.com/repos/pytorch/pytorch","forks_url":"https://api.github.com/repos/pytorch/pytorch/forks","keys_url":"https://api.github.com/repos/pytorch/pytorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pytorch/pytorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pytorch/pytorch/teams","hooks_url":"https://api.github.com/repos/pytorch/pytorch/hooks","issue_events_url":"https://api.github.com/repos/pytorch/pytorch/issues/events{/number}","events_url":"https://api.github.com/repos/pytorch/pytorch/events","assignees_url":"https://api.github.com/repos/pytorch/pytorch/assignees{/user}","branches_url":"https://api.github.com/repos/pytorch/pytorch/branches{/branch}","tags_url":"https://api.github.com/repos/pytorch/pytorch/tags","blobs_url":"https://api.github.com/repos/pytorch/pytorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pytorch/pytorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pytorch/pytorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/pytorch/pytorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pytorch/pytorch/statuses/{sha}","languages_url":"https://api.github.com/repos/pytorch/pytorch/languages","stargazers_url":"https://api.github.com/repos/pytorch/pytorch/stargazers","contributors_url":"https://api.github.com/repos/pytorch/pytorch/contributors","subscribers_url":"https://api.github.com/repos/pytorch/pytorch/subscribers","subscription_url":"https://api.github.com/repos/pytorch/pytorch/subscription","commits_url":"https://api.github.com/repos/pytorch/pytorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/pytorch/pytorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/pytorch/pytorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/pytorch/pytorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/pytorch/pytorch/contents/{+path}","compare_url":"https://api.github.com/repos/pytorch/pytorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pytorch/pytorch/merges","archive_url":"https://api.github.com/repos/pytorch/pytorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pytorch/pytorch/downloads","issues_url":"https://api.github.com/repos/pytorch/pytorch/issues{/number}","pulls_url":"https://api.github.com/repos/pytorch/pytorch/pulls{/number}","milestones_url":"https://api.github.com/repos/pytorch/pytorch/milestones{/number}","notifications_url":"https://api.github.com/repos/pytorch/pytorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pytorch/pytorch/labels{/name}","releases_url":"https://api.github.com/repos/pytorch/pytorch/releases{/id}","deployments_url":"https://api.github.com/repos/pytorch/pytorch/deployments","created_at":"2016-08-13T05:26:41Z","updated_at":"2018-08-09T23:37:52Z","pushed_at":"2018-08-09T23:41:13Z","git_url":"git://github.com/pytorch/pytorch.git","ssh_url":"git@github.com:pytorch/pytorch.git","clone_url":"https://github.com/pytorch/pytorch.git","svn_url":"https://github.com/pytorch/pytorch","homepage":"http://pytorch.org","size":67310,"stargazers_count":17739,"watchers_count":17739,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4181,"mirror_url":null,"archived":false,"open_issues_count":1603,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4181,"open_issues":1603,"watchers":17739,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10220"},"html":{"href":"https://github.com/pytorch/pytorch/pull/10220"},"issue":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/10220"},"comments":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/10220/comments"},"review_comments":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10220/comments"},"review_comment":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10220/commits"},"statuses":{"href":"https://api.github.com/repos/pytorch/pytorch/statuses/a6213c30d8f34a62e2a1d1cdf8e4dcf5d1f6e3ad"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"colesbury"}}