Skip to content

Conversation

@Padarn
Copy link
Contributor

@Padarn Padarn commented Jul 23, 2022

Description

This change adds support for kwargs in hooks. Currently, registered hooks do not receive, and cannot modify, the kwargs provided to the module forward.

The proposed way to address this is to add an annotation to the hook function so that it is possible to determine whether the hook should keep the previous behaviour, or instead also expect and return kwargs.

Issue

This change addresses the issue #35643 where alternative implementations
are also discussed

Testing

There is a test implemented for this functionality. Its a little basic, but shows the use of both forward and pre_forward hooks using this change.

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jul 23, 2022

🔗 Helpful links

❌ 19 New Failures

As of commit 0a19b0413a (more details on the Dr. CI page):

Expand to see more
  • 19/19 failures introduced in this PR

🕵️ 19 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages

See GitHub Actions build pull / linux-bionic-py3.7-clang9 / test (crossref, 2, 2, linux.2xlarge) (1/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T02:51:27.0874549Z RuntimeError: test_nn failed!
2022-07-23T02:51:26.3531094Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestModuleGlobalHooks-20220723024841.xml
2022-07-23T02:51:26.6009803Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNN-20220723024841.xml
2022-07-23T02:51:26.6722251Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNDeviceTypeCPU-20220723024841.xml
2022-07-23T02:51:26.6744878Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNInit-20220723024841.xml
2022-07-23T02:51:26.6756047Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestStateDictHooks-20220723024841.xml
2022-07-23T02:51:27.0859685Z Traceback (most recent call last):
2022-07-23T02:51:27.0860060Z   File "test/run_test.py", line 940, in <module>
2022-07-23T02:51:27.0871969Z     main()
2022-07-23T02:51:27.0872301Z   File "test/run_test.py", line 918, in main
2022-07-23T02:51:27.0874158Z     raise RuntimeError(err_message)
2022-07-23T02:51:27.0874549Z RuntimeError: test_nn failed!
2022-07-23T02:51:27.2990824Z 
2022-07-23T02:51:27.2991119Z real	22m0.095s
2022-07-23T02:51:27.2991423Z user	126m16.005s
2022-07-23T02:51:27.2991666Z sys	6m50.537s
2022-07-23T02:51:27.3029845Z ##[error]Process completed with exit code 1.
2022-07-23T02:51:27.3098048Z Prepare all required actions
2022-07-23T02:51:27.3098497Z Getting action download info
2022-07-23T02:51:27.4581963Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T02:51:27.4582184Z with:
2022-07-23T02:51:27.4582546Z   github-token: ***

See GitHub Actions build pull / linux-bionic-py3.7-clang9 / test (dynamo, 1, 2, linux.2xlarge) (2/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T04:39:53.1728699Z RuntimeError: test_modules failed!
2022-07-23T04:39:52.7411075Z 
2022-07-23T04:39:52.7411186Z FAILED (errors=90, skipped=208, expected failures=282)
2022-07-23T04:39:52.7411191Z 
2022-07-23T04:39:52.7411271Z Generating XML reports...
2022-07-23T04:39:52.8750678Z Generated XML report: test-reports/python-unittest/test_modules/TEST-TestModuleCPU-20220723043806.xml
2022-07-23T04:39:53.1724204Z Traceback (most recent call last):
2022-07-23T04:39:53.1724685Z   File "test/run_test.py", line 940, in <module>
2022-07-23T04:39:53.1726375Z     main()
2022-07-23T04:39:53.1726732Z   File "test/run_test.py", line 918, in main
2022-07-23T04:39:53.1727978Z     raise RuntimeError(err_message)
2022-07-23T04:39:53.1728699Z RuntimeError: test_modules failed!
2022-07-23T04:39:53.3926129Z 
2022-07-23T04:39:53.3926776Z real	130m25.903s
2022-07-23T04:39:53.3927051Z user	355m2.650s
2022-07-23T04:39:53.3927219Z sys	10m11.293s
2022-07-23T04:39:53.3959876Z ##[error]Process completed with exit code 1.
2022-07-23T04:39:53.4011356Z Prepare all required actions
2022-07-23T04:39:53.4011636Z Getting action download info
2022-07-23T04:39:53.6072824Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T04:39:53.6073042Z with:
2022-07-23T04:39:53.6073438Z   github-token: ***

See GitHub Actions build pull / linux-bionic-cuda11.6-py3.7-gcc7 / test (default, 3, 4, linux.4xlarge.nvidia.gpu) (3/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:29:42.2731631Z RuntimeError: test_quantization failed!
2022-07-23T03:29:41.9934826Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/lazy.py", line 178, in __init__
2022-07-23T03:29:41.9935349Z     self._initialize_hook = self.register_forward_pre_hook(self._infer_parameters)
2022-07-23T03:29:41.9935963Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1135, in register_forward_pre_hook
2022-07-23T03:29:41.9938618Z     hook.with_kwargs = with_kwargs
2022-07-23T03:29:41.9939592Z AttributeError: 'method' object has no attribute 'with_kwargs'
2022-07-23T03:29:42.2724718Z Traceback (most recent call last):
2022-07-23T03:29:42.2725452Z   File "test/run_test.py", line 940, in <module>
2022-07-23T03:29:42.2727632Z     main()
2022-07-23T03:29:42.2728221Z   File "test/run_test.py", line 918, in main
2022-07-23T03:29:42.2731027Z     raise RuntimeError(err_message)
2022-07-23T03:29:42.2731631Z RuntimeError: test_quantization failed!
2022-07-23T03:29:42.7577609Z 
2022-07-23T03:29:42.7577848Z real	31m22.481s
2022-07-23T03:29:42.7578164Z user	30m23.062s
2022-07-23T03:29:42.7578409Z sys	1m41.965s
2022-07-23T03:29:42.7626338Z ##[error]Process completed with exit code 1.
2022-07-23T03:29:42.7663193Z Prepare all required actions
2022-07-23T03:29:42.7663611Z Getting action download info
2022-07-23T03:29:42.9871796Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:29:42.9872097Z with:
2022-07-23T03:29:42.9872533Z   github-token: ***

See GitHub Actions build pull / linux-bionic-py3.7-clang9 / test (default, 2, 2, linux.2xlarge) (4/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T02:40:36.3051199Z RuntimeError: test_quantization failed!
2022-07-23T02:40:36.0693154Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/lazy.py", line 178, in __init__
2022-07-23T02:40:36.0693850Z     self._initialize_hook = self.register_forward_pre_hook(self._infer_parameters)
2022-07-23T02:40:36.0694424Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1135, in register_forward_pre_hook
2022-07-23T02:40:36.0695978Z     hook.with_kwargs = with_kwargs
2022-07-23T02:40:36.0696548Z AttributeError: 'method' object has no attribute 'with_kwargs'
2022-07-23T02:40:36.3046319Z Traceback (most recent call last):
2022-07-23T02:40:36.3046896Z   File "test/run_test.py", line 940, in <module>
2022-07-23T02:40:36.3048290Z     main()
2022-07-23T02:40:36.3048613Z   File "test/run_test.py", line 918, in main
2022-07-23T02:40:36.3050769Z     raise RuntimeError(err_message)
2022-07-23T02:40:36.3051199Z RuntimeError: test_quantization failed!
2022-07-23T02:40:36.5162862Z 
2022-07-23T02:40:36.5163170Z real	11m23.574s
2022-07-23T02:40:36.5163488Z user	73m6.615s
2022-07-23T02:40:36.5163793Z sys	3m28.826s
2022-07-23T02:40:36.5195866Z ##[error]Process completed with exit code 1.
2022-07-23T02:40:36.5241626Z Prepare all required actions
2022-07-23T02:40:36.5241940Z Getting action download info
2022-07-23T02:40:36.6652572Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T02:40:36.6652796Z with:
2022-07-23T02:40:36.6653126Z   github-token: ***

See GitHub Actions build pull / linux-bionic-cuda11.6-py3.7-gcc7 / test (distributed, 1, 2, linux.8xlarge.nvidia.gpu) (5/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T04:30:28.5275597Z RuntimeError: distributed/test_data_parallel failed!
2022-07-23T04:30:27.8263620Z FAILED (errors=1, skipped=1, expected failures=3)
2022-07-23T04:30:27.8263829Z 
2022-07-23T04:30:27.8263955Z Generating XML reports...
2022-07-23T04:30:27.8329342Z Generated XML report: test-reports/python-unittest/distributed.test_data_parallel/TEST-TestDataParallel-20220723043023.xml
2022-07-23T04:30:27.8348248Z Generated XML report: test-reports/python-unittest/distributed.test_data_parallel/TEST-TestDataParallelDeviceTypeCUDA-20220723043023.xml
2022-07-23T04:30:28.5269275Z Traceback (most recent call last):
2022-07-23T04:30:28.5269649Z   File "test/run_test.py", line 940, in <module>
2022-07-23T04:30:28.5272346Z     main()
2022-07-23T04:30:28.5272638Z   File "test/run_test.py", line 918, in main
2022-07-23T04:30:28.5275260Z     raise RuntimeError(err_message)
2022-07-23T04:30:28.5275597Z RuntimeError: distributed/test_data_parallel failed!
2022-07-23T04:30:29.3001320Z 
2022-07-23T04:30:29.3001682Z real	91m18.079s
2022-07-23T04:30:29.3001964Z user	138m44.901s
2022-07-23T04:30:29.3002208Z sys	102m25.861s
2022-07-23T04:30:29.3044835Z ##[error]Process completed with exit code 1.
2022-07-23T04:30:29.3083094Z Prepare all required actions
2022-07-23T04:30:29.3083516Z Getting action download info
2022-07-23T04:30:29.4899920Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T04:30:29.4900219Z with:
2022-07-23T04:30:29.4900656Z   github-token: ***

See GitHub Actions build pull / linux-focal-py3.7-clang7-asan / test (default, 3, 5, linux.2xlarge) (6/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:20:21.9217877Z RuntimeError: test_module_init failed!
2022-07-23T03:20:21.3077811Z 
2022-07-23T03:20:21.3077916Z FAILED (errors=26, expected failures=78)
2022-07-23T03:20:21.3078054Z 
2022-07-23T03:20:21.3078142Z Generating XML reports...
2022-07-23T03:20:21.4456651Z Generated XML report: test-reports/python-unittest/test_module_init/TEST-TestModuleInitCPU-20220723032013.xml
2022-07-23T03:20:21.9209137Z Traceback (most recent call last):
2022-07-23T03:20:21.9209426Z   File "test/run_test.py", line 940, in <module>
2022-07-23T03:20:21.9213497Z     main()
2022-07-23T03:20:21.9213729Z   File "test/run_test.py", line 918, in main
2022-07-23T03:20:21.9217555Z     raise RuntimeError(err_message)
2022-07-23T03:20:21.9217877Z RuntimeError: test_module_init failed!
2022-07-23T03:20:22.3923389Z 
2022-07-23T03:20:22.3923782Z real	71m26.927s
2022-07-23T03:20:22.3924096Z user	74m9.738s
2022-07-23T03:20:22.3924326Z sys	2m0.966s
2022-07-23T03:20:22.3962392Z ##[error]Process completed with exit code 1.
2022-07-23T03:20:22.3997382Z Prepare all required actions
2022-07-23T03:20:22.3997702Z Getting action download info
2022-07-23T03:20:22.5917137Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:20:22.5917366Z with:
2022-07-23T03:20:22.5917715Z   github-token: ***

See GitHub Actions build pull / linux-focal-py3.7-gcc7 / test (default, 2, 2, linux.2xlarge) (7/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T02:31:24.7267951Z RuntimeError: test_quantization failed!
2022-07-23T02:31:24.5048728Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/lazy.py", line 178, in __init__
2022-07-23T02:31:24.5049156Z     self._initialize_hook = self.register_forward_pre_hook(self._infer_parameters)
2022-07-23T02:31:24.5049617Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1135, in register_forward_pre_hook
2022-07-23T02:31:24.5051729Z     hook.with_kwargs = with_kwargs
2022-07-23T02:31:24.5052183Z AttributeError: 'method' object has no attribute 'with_kwargs'
2022-07-23T02:31:24.7262846Z Traceback (most recent call last):
2022-07-23T02:31:24.7263138Z   File "test/run_test.py", line 940, in <module>
2022-07-23T02:31:24.7265700Z     main()
2022-07-23T02:31:24.7265940Z   File "test/run_test.py", line 918, in main
2022-07-23T02:31:24.7267711Z     raise RuntimeError(err_message)
2022-07-23T02:31:24.7267951Z RuntimeError: test_quantization failed!
2022-07-23T02:31:24.9213619Z 
2022-07-23T02:31:24.9213886Z real	10m22.379s
2022-07-23T02:31:24.9214114Z user	65m29.504s
2022-07-23T02:31:24.9214274Z sys	0m28.811s
2022-07-23T02:31:24.9247281Z ##[error]Process completed with exit code 1.
2022-07-23T02:31:24.9282109Z Prepare all required actions
2022-07-23T02:31:24.9282417Z Getting action download info
2022-07-23T02:31:25.0702892Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T02:31:25.0703111Z with:
2022-07-23T02:31:25.0703433Z   github-token: ***

See GitHub Actions build pull / win-vs2019-cpu-py3 / test (default, 1, 2, windows.4xlarge) (8/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:06:41.7008596Z RuntimeError: test_quantization failed!
2022-07-23T03:06:41.4793193Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\nn\modules\lazy.py", line 178, in __init__
2022-07-23T03:06:41.4793587Z     self._initialize_hook = self.register_forward_pre_hook(self._infer_parameters)
2022-07-23T03:06:41.4794039Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\nn\modules\module.py", line 1135, in register_forward_pre_hook
2022-07-23T03:06:41.4794381Z     hook.with_kwargs = with_kwargs
2022-07-23T03:06:41.4794620Z AttributeError: 'method' object has no attribute 'with_kwargs'
2022-07-23T03:06:41.7007399Z Traceback (most recent call last):
2022-07-23T03:06:41.7007748Z   File "run_test.py", line 940, in <module>
2022-07-23T03:06:41.7007946Z     main()
2022-07-23T03:06:41.7008135Z   File "run_test.py", line 918, in main
2022-07-23T03:06:41.7008372Z     raise RuntimeError(err_message)
2022-07-23T03:06:41.7008596Z RuntimeError: test_quantization failed!
2022-07-23T03:06:41.9088146Z 
2022-07-23T03:06:41.9088547Z (base) C:\actions-runner\_work\pytorch\pytorch\test>if ERRORLEVEL 1 goto fail 
2022-07-23T03:06:41.9091002Z 
2022-07-23T03:06:41.9091323Z (base) C:\actions-runner\_work\pytorch\pytorch\test>exit /b 1 
2022-07-23T03:06:41.9147460Z ##[error]Process completed with exit code 1.
2022-07-23T03:06:41.9372333Z Prepare all required actions
2022-07-23T03:06:41.9372731Z Getting action download info
2022-07-23T03:06:42.0643951Z Download action repository 'nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a' (SHA:71062288b76e2b6214ebde0e673ce0de1755740a)
2022-07-23T03:06:42.2698926Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:06:42.2699137Z with:

See GitHub Actions build pull / linux-focal-py3.7-clang7-asan / test (default, 5, 5, linux.2xlarge) (9/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T02:08:35.2922795Z RuntimeError: test_quantization failed!
2022-07-23T02:08:34.8521524Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/lazy.py", line 178, in __init__
2022-07-23T02:08:34.8522144Z     self._initialize_hook = self.register_forward_pre_hook(self._infer_parameters)
2022-07-23T02:08:34.8522956Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1135, in register_forward_pre_hook
2022-07-23T02:08:34.8527174Z     hook.with_kwargs = with_kwargs
2022-07-23T02:08:34.8527687Z AttributeError: 'method' object has no attribute 'with_kwargs'
2022-07-23T02:08:35.2916362Z Traceback (most recent call last):
2022-07-23T02:08:35.2916651Z   File "test/run_test.py", line 940, in <module>
2022-07-23T02:08:35.2919333Z     main()
2022-07-23T02:08:35.2919669Z   File "test/run_test.py", line 918, in main
2022-07-23T02:08:35.2922555Z     raise RuntimeError(err_message)
2022-07-23T02:08:35.2922795Z RuntimeError: test_quantization failed!
2022-07-23T02:08:35.7510519Z 
2022-07-23T02:08:35.7510877Z real	0m7.665s
2022-07-23T02:08:35.7511266Z user	0m6.247s
2022-07-23T02:08:35.7511516Z sys	0m1.779s
2022-07-23T02:08:35.7540403Z ##[error]Process completed with exit code 1.
2022-07-23T02:08:35.7579374Z Prepare all required actions
2022-07-23T02:08:35.7579682Z Getting action download info
2022-07-23T02:08:35.9239749Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T02:08:35.9240054Z with:
2022-07-23T02:08:35.9240366Z   github-token: ***

See GitHub Actions build pull / linux-bionic-py3.7-clang9 / test (default, 1, 2, linux.2xlarge) (10/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:02:15.7152886Z RuntimeError: test_modules failed!
2022-07-23T03:02:15.2748497Z 
2022-07-23T03:02:15.2748620Z FAILED (errors=90, skipped=208, expected failures=282)
2022-07-23T03:02:15.2748626Z 
2022-07-23T03:02:15.2748714Z Generating XML reports...
2022-07-23T03:02:15.3366401Z Generated XML report: test-reports/python-unittest/test_modules/TEST-TestModuleCPU-20220723030036.xml
2022-07-23T03:02:15.7139429Z Traceback (most recent call last):
2022-07-23T03:02:15.7139709Z   File "test/run_test.py", line 940, in <module>
2022-07-23T03:02:15.7150456Z     main()
2022-07-23T03:02:15.7150860Z   File "test/run_test.py", line 918, in main
2022-07-23T03:02:15.7152545Z     raise RuntimeError(err_message)
2022-07-23T03:02:15.7152886Z RuntimeError: test_modules failed!
2022-07-23T03:02:15.9888865Z 
2022-07-23T03:02:15.9889260Z real	32m45.915s
2022-07-23T03:02:15.9889496Z user	125m39.480s
2022-07-23T03:02:15.9889872Z sys	6m35.166s
2022-07-23T03:02:15.9926388Z ##[error]Process completed with exit code 1.
2022-07-23T03:02:15.9989002Z Prepare all required actions
2022-07-23T03:02:15.9989319Z Getting action download info
2022-07-23T03:02:16.1505461Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:02:16.1505690Z with:
2022-07-23T03:02:16.1506125Z   github-token: ***

See GitHub Actions build pull / linux-bionic-cuda11.6-py3.7-gcc7 / test (default, 2, 4, linux.4xlarge.nvidia.gpu) (11/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:49:00.4096844Z RuntimeError: test_nn failed!
2022-07-23T03:48:59.2773180Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestModuleGlobalHooks-20220723034538.xml
2022-07-23T03:48:59.5035309Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNN-20220723034538.xml
2022-07-23T03:48:59.6849446Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNDeviceTypeCUDA-20220723034538.xml
2022-07-23T03:48:59.6881442Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNInit-20220723034538.xml
2022-07-23T03:48:59.6890414Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestStateDictHooks-20220723034538.xml
2022-07-23T03:49:00.4089741Z Traceback (most recent call last):
2022-07-23T03:49:00.4090139Z   File "test/run_test.py", line 940, in <module>
2022-07-23T03:49:00.4093726Z     main()
2022-07-23T03:49:00.4094020Z   File "test/run_test.py", line 918, in main
2022-07-23T03:49:00.4096554Z     raise RuntimeError(err_message)
2022-07-23T03:49:00.4096844Z RuntimeError: test_nn failed!
2022-07-23T03:49:01.2012576Z 
2022-07-23T03:49:01.2013246Z real	49m5.296s
2022-07-23T03:49:01.2013715Z user	52m9.314s
2022-07-23T03:49:01.2014007Z sys	2m13.986s
2022-07-23T03:49:01.2060692Z ##[error]Process completed with exit code 1.
2022-07-23T03:49:01.2098524Z Prepare all required actions
2022-07-23T03:49:01.2098935Z Getting action download info
2022-07-23T03:49:01.4189468Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:49:01.4189765Z with:
2022-07-23T03:49:01.4190192Z   github-token: ***

See GitHub Actions build pull / linux-focal-py3.7-gcc7 / test (default, 1, 2, linux.2xlarge) (12/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T02:44:46.7843310Z RuntimeError: test_modules failed!
2022-07-23T02:44:46.4456201Z 
2022-07-23T02:44:46.4456308Z FAILED (errors=90, skipped=208, expected failures=282)
2022-07-23T02:44:46.4456313Z 
2022-07-23T02:44:46.4456392Z Generating XML reports...
2022-07-23T02:44:46.5064473Z Generated XML report: test-reports/python-unittest/test_modules/TEST-TestModuleCPU-20220723024252.xml
2022-07-23T02:44:46.7838142Z Traceback (most recent call last):
2022-07-23T02:44:46.7838408Z   File "test/run_test.py", line 940, in <module>
2022-07-23T02:44:46.7840621Z     main()
2022-07-23T02:44:46.7840906Z   File "test/run_test.py", line 918, in main
2022-07-23T02:44:46.7843024Z     raise RuntimeError(err_message)
2022-07-23T02:44:46.7843310Z RuntimeError: test_modules failed!
2022-07-23T02:44:46.9756742Z 
2022-07-23T02:44:46.9757096Z real	23m17.381s
2022-07-23T02:44:46.9757460Z user	84m58.884s
2022-07-23T02:44:46.9757734Z sys	4m27.015s
2022-07-23T02:44:46.9789722Z ##[error]Process completed with exit code 1.
2022-07-23T02:44:46.9845809Z Prepare all required actions
2022-07-23T02:44:46.9846109Z Getting action download info
2022-07-23T02:44:47.1410855Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T02:44:47.1411070Z with:
2022-07-23T02:44:47.1411392Z   github-token: ***

See GitHub Actions build pull / linux-bionic-cuda11.6-py3.7-gcc7 / test (default, 4, 4, linux.4xlarge.nvidia.gpu) (13/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:53:33.9898931Z RuntimeError: test_module_init failed!
2022-07-23T03:53:33.5755071Z 
2022-07-23T03:53:33.5755219Z FAILED (errors=26, expected failures=78)
2022-07-23T03:53:33.5755410Z 
2022-07-23T03:53:33.5755538Z Generating XML reports...
2022-07-23T03:53:33.6126702Z Generated XML report: test-reports/python-unittest/test_module_init/TEST-TestModuleInitCUDA-20220723035329.xml
2022-07-23T03:53:33.9893068Z Traceback (most recent call last):
2022-07-23T03:53:33.9893556Z   File "test/run_test.py", line 940, in <module>
2022-07-23T03:53:33.9896888Z     main()
2022-07-23T03:53:33.9897351Z   File "test/run_test.py", line 918, in main
2022-07-23T03:53:33.9898469Z     raise RuntimeError(err_message)
2022-07-23T03:53:33.9898931Z RuntimeError: test_module_init failed!
2022-07-23T03:53:34.4861076Z 
2022-07-23T03:53:34.4861791Z real	55m20.006s
2022-07-23T03:53:34.4862098Z user	57m36.560s
2022-07-23T03:53:34.4862321Z sys	5m4.026s
2022-07-23T03:53:34.4909640Z ##[error]Process completed with exit code 1.
2022-07-23T03:53:34.4947188Z Prepare all required actions
2022-07-23T03:53:34.4947615Z Getting action download info
2022-07-23T03:53:34.6616861Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:53:34.6617167Z with:
2022-07-23T03:53:34.6617600Z   github-token: ***

See GitHub Actions build pull / linux-bionic-cuda11.6-py3.7-gcc7 / test (distributed, 2, 2, linux.8xlarge.nvidia.gpu) (14/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:28:38.8512621Z AssertionError: 1 unit test(s) failed:
2022-07-23T03:28:38.5721761Z 
2022-07-23T03:28:38.5721855Z OK
2022-07-23T03:28:38.5721989Z 
2022-07-23T03:28:38.5722118Z Generating XML reports...
2022-07-23T03:28:38.5754966Z Generated XML report: test-reports/python-unittest/distributed.test_c10d_nccl/TEST-TimeoutTest-20220723032833.xml
2022-07-23T03:28:38.8502774Z Traceback (most recent call last):
2022-07-23T03:28:38.8503473Z   File "distributed/test_c10d_nccl.py", line 2754, in <module>
2022-07-23T03:28:38.8510164Z     run_tests()
2022-07-23T03:28:38.8511077Z   File "/opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py", line 661, in run_tests
2022-07-23T03:28:38.8512292Z     len(failed_tests), '\n\t'.join(failed_tests))
2022-07-23T03:28:38.8512621Z AssertionError: 1 unit test(s) failed:
2022-07-23T03:28:38.8512986Z 	DistributedDataParallelTest.test_ddp_with_lazy_parameters
2022-07-23T03:28:39.0217645Z Traceback (most recent call last):
2022-07-23T03:28:39.0218003Z   File "test/run_test.py", line 940, in <module>
2022-07-23T03:28:39.0220801Z     main()
2022-07-23T03:28:39.0221092Z   File "test/run_test.py", line 918, in main
2022-07-23T03:28:39.0223760Z     raise RuntimeError(err_message)
2022-07-23T03:28:39.0224113Z RuntimeError: distributed/test_c10d_nccl failed!
2022-07-23T03:28:39.7770705Z 
2022-07-23T03:28:39.7771034Z real	29m32.671s
2022-07-23T03:28:39.7771329Z user	59m6.171s

See GitHub Actions build pull / win-vs2019-cpu-py3 / test (default, 2, 2, windows.4xlarge) (15/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:15:54.2796506Z RuntimeError: test_modules failed!
2022-07-23T03:15:53.9535396Z 
2022-07-23T03:15:53.9535535Z FAILED (errors=90, skipped=208, expected failures=282)
2022-07-23T03:15:53.9535543Z 
2022-07-23T03:15:53.9535628Z Generating XML reports...
2022-07-23T03:15:53.9535853Z Generated XML report: test-reports\python-unittest\test_modules\TEST-TestModuleCPU-20220723031337.xml
2022-07-23T03:15:54.2795321Z Traceback (most recent call last):
2022-07-23T03:15:54.2795670Z   File "run_test.py", line 940, in <module>
2022-07-23T03:15:54.2795854Z     main()
2022-07-23T03:15:54.2796067Z   File "run_test.py", line 918, in main
2022-07-23T03:15:54.2796304Z     raise RuntimeError(err_message)
2022-07-23T03:15:54.2796506Z RuntimeError: test_modules failed!
2022-07-23T03:15:54.4906691Z 
2022-07-23T03:15:54.4907059Z (base) C:\actions-runner\_work\pytorch\pytorch\test>if ERRORLEVEL 1 goto fail 
2022-07-23T03:15:54.4908861Z 
2022-07-23T03:15:54.4909087Z (base) C:\actions-runner\_work\pytorch\pytorch\test>exit /b 1 
2022-07-23T03:15:54.4967791Z ##[error]Process completed with exit code 1.
2022-07-23T03:15:54.5206463Z Prepare all required actions
2022-07-23T03:15:54.5206932Z Getting action download info
2022-07-23T03:15:54.6854695Z Download action repository 'nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a' (SHA:71062288b76e2b6214ebde0e673ce0de1755740a)
2022-07-23T03:15:54.9148105Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:15:54.9148404Z with:

See GitHub Actions build Lint / lintrunner (16/19)

Step: "Run lintrunner on all files" (full log | diagnosis details | 🔁 rerun)

2022-07-23T01:54:11.3737390Z ##[error]"Callable[..., Any]" has no attribute "with_kwargs"
2022-07-23T01:54:11.2240219Z   pythonLocation: /opt/hostedtoolcache/Python/3.8.13/x64
2022-07-23T01:54:11.2240520Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.13/x64/lib
2022-07-23T01:54:11.2240756Z ##[endgroup]
2022-07-23T01:54:11.3725443Z ##[error]Signature of "register_forward_pre_hook" incompatible with supertype "Module" 
2022-07-23T01:54:11.3727789Z ##[error]Signature of "register_forward_hook" incompatible with supertype "Module" 
2022-07-23T01:54:11.3729563Z ##[error]"Callable[..., None]" has no attribute "with_kwargs" 
2022-07-23T01:54:11.3731580Z ##[error]"Callable[..., None]" has no attribute "with_kwargs" 
2022-07-23T01:54:11.3733568Z ##[error]"Callable[..., Any]" has no attribute "with_kwargs" 
2022-07-23T01:54:11.3734865Z ##[error]Name "mod" is not defined 
2022-07-23T01:54:11.3736067Z ##[error]Name "args" is not defined 
2022-07-23T01:54:11.3737390Z ##[error]"Callable[..., Any]" has no attribute "with_kwargs" 
2022-07-23T01:54:11.3787183Z Post job cleanup.
2022-07-23T01:54:11.3820805Z Post job cleanup.
2022-07-23T01:54:11.4882945Z [command]/usr/bin/git version
2022-07-23T01:54:11.4936958Z git version 2.37.1
2022-07-23T01:54:11.4981124Z Temporarily overriding HOME='/home/runner/actions-runner/_work/_temp/d56d56c1-b430-4f8b-9bad-2b23dcf27851' before making global git config changes
2022-07-23T01:54:11.4981581Z Adding repository directory to the temporary git global config as a safe directory
2022-07-23T01:54:11.4990194Z [command]/usr/bin/git config --global --add safe.directory /home/runner/actions-runner/_work/pytorch/pytorch
2022-07-23T01:54:11.5037058Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2022-07-23T01:54:11.5081025Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2022-07-23T01:54:11.5362874Z Entering 'android/libs/fbjni'

See GitHub Actions build pull / linux-bionic-py3.7-clang9 / test (crossref, 1, 2, linux.2xlarge) (17/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T02:45:48.4312419Z RuntimeError: test_quantization failed!
2022-07-23T02:45:48.1533251Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/lazy.py", line 178, in __init__
2022-07-23T02:45:48.1533663Z     self._initialize_hook = self.register_forward_pre_hook(self._infer_parameters)
2022-07-23T02:45:48.1534205Z   File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1135, in register_forward_pre_hook
2022-07-23T02:45:48.1534504Z     hook.with_kwargs = with_kwargs
2022-07-23T02:45:48.1535082Z AttributeError: 'method' object has no attribute 'with_kwargs'
2022-07-23T02:45:48.4307459Z Traceback (most recent call last):
2022-07-23T02:45:48.4307758Z   File "test/run_test.py", line 940, in <module>
2022-07-23T02:45:48.4310135Z     main()
2022-07-23T02:45:48.4310350Z   File "test/run_test.py", line 918, in main
2022-07-23T02:45:48.4312179Z     raise RuntimeError(err_message)
2022-07-23T02:45:48.4312419Z RuntimeError: test_quantization failed!
2022-07-23T02:45:48.6627616Z 
2022-07-23T02:45:48.6627833Z real	16m5.797s
2022-07-23T02:45:48.6628079Z user	109m25.325s
2022-07-23T02:45:48.6628248Z sys	4m46.786s
2022-07-23T02:45:48.6662737Z ##[error]Process completed with exit code 1.
2022-07-23T02:45:48.6720362Z Prepare all required actions
2022-07-23T02:45:48.6720661Z Getting action download info
2022-07-23T02:45:48.8363966Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T02:45:48.8364201Z with:
2022-07-23T02:45:48.8364547Z   github-token: ***

See GitHub Actions build pull / linux-bionic-py3.7-clang9 / test (dynamo, 2, 2, linux.2xlarge) (18/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T03:12:13.7726977Z RuntimeError: test_nn failed!
2022-07-23T03:12:11.3562604Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestModuleGlobalHooks-20220723030444.xml
2022-07-23T03:12:11.9377574Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNN-20220723030444.xml
2022-07-23T03:12:12.0066180Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNDeviceTypeCPU-20220723030444.xml
2022-07-23T03:12:12.0087271Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNInit-20220723030444.xml
2022-07-23T03:12:12.0093348Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestStateDictHooks-20220723030444.xml
2022-07-23T03:12:13.7701951Z Traceback (most recent call last):
2022-07-23T03:12:13.7702429Z   File "test/run_test.py", line 940, in <module>
2022-07-23T03:12:13.7724618Z     main()
2022-07-23T03:12:13.7724827Z   File "test/run_test.py", line 918, in main
2022-07-23T03:12:13.7726760Z     raise RuntimeError(err_message)
2022-07-23T03:12:13.7726977Z RuntimeError: test_nn failed!
2022-07-23T03:12:14.0084267Z 
2022-07-23T03:12:14.0084619Z real	42m49.457s
2022-07-23T03:12:14.0084821Z user	205m26.581s
2022-07-23T03:12:14.0084991Z sys	11m30.029s
2022-07-23T03:12:14.0119739Z ##[error]Process completed with exit code 1.
2022-07-23T03:12:14.0172589Z Prepare all required actions
2022-07-23T03:12:14.0172885Z Getting action download info
2022-07-23T03:12:14.1748280Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T03:12:14.1748513Z with:
2022-07-23T03:12:14.1748844Z   github-token: ***

See GitHub Actions build pull / linux-focal-py3.7-clang7-asan / test (default, 4, 5, linux.2xlarge) (19/19)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-07-23T02:41:50.4389444Z RuntimeError: test_nn failed!
2022-07-23T02:41:49.2641305Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestModuleGlobalHooks-20220723023355.xml
2022-07-23T02:41:49.5647829Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNN-20220723023355.xml
2022-07-23T02:41:49.6557634Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNDeviceTypeCPU-20220723023355.xml
2022-07-23T02:41:49.6590969Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestNNInit-20220723023355.xml
2022-07-23T02:41:49.6598436Z Generated XML report: test-reports/python-unittest/test_nn/TEST-TestStateDictHooks-20220723023355.xml
2022-07-23T02:41:50.4382146Z Traceback (most recent call last):
2022-07-23T02:41:50.4382626Z   File "test/run_test.py", line 940, in <module>
2022-07-23T02:41:50.4385755Z     main()
2022-07-23T02:41:50.4386132Z   File "test/run_test.py", line 918, in main
2022-07-23T02:41:50.4389046Z     raise RuntimeError(err_message)
2022-07-23T02:41:50.4389444Z RuntimeError: test_nn failed!
2022-07-23T02:41:50.9606638Z 
2022-07-23T02:41:50.9606967Z real	33m19.627s
2022-07-23T02:41:50.9607339Z user	60m34.144s
2022-07-23T02:41:50.9607778Z sys	2m28.679s
2022-07-23T02:41:50.9649161Z ##[error]Process completed with exit code 1.
2022-07-23T02:41:50.9719793Z Prepare all required actions
2022-07-23T02:41:50.9720106Z Getting action download info
2022-07-23T02:41:51.1225169Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-07-23T02:41:51.1225405Z with:
2022-07-23T02:41:51.1225752Z   github-token: ***

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@ezyang ezyang added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 24, 2022
@github-actions
Copy link
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions bot added the Stale label Sep 22, 2022
@facebook-github-bot
Copy link
Contributor

/easycla

As part of the transition to the PyTorch Foundation, this project now requires contributions be covered under the new CLA. See #85559 for additional details.

This comment will trigger a new check of this PR. If you are already covered, you will simply see a new "EasyCLA" check that passes. If you are not covered, a bot will leave a new comment with a link to sign.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 4, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Padarn / name: Padarn Wilson (0a19b0413aa1766769a2264fd92782db12ca8311)

@awgu
Copy link
Collaborator

awgu commented Oct 28, 2022

Hi @Padarn! Some of us are very interested in the change in this PR and would like this landed in the next week.

We were wondering if you had to bandwidth to try to finish it. We would probably want unit tests, to fix the lint errors, and to add the kwargs support for all hooks. If you do not have bandwidth, then we can try to revive the PR ourselves and tag you as a reviewer.

@mrshenli
Copy link
Contributor

+1 for this feature

@Padarn
Copy link
Contributor Author

Padarn commented Oct 29, 2022

Hi @awgu, yes I'm happy to finish it up! I was really just waiting for some feedback (as noted #35643) before I added docs/tests.

If no problems with the proposed implementation I'll do that.

@awgu
Copy link
Collaborator

awgu commented Oct 29, 2022

Hi @awgu, yes I'm happy to finish it up! I was really just waiting for some feedback (as noted #35643) before I added docs/tests.

If no problems with the proposed implementation I'll do that.

I will let @albanD comment on whether he is content with the exact approach to add an with_kwargs attribute on the hook, but I think the general approach to have two code paths differentiated by some flag is fine.

I think you can go ahead and finish it up because any change to the exact logic to differentiate the two code paths should not be too hard to replace.

@Padarn
Copy link
Contributor Author

Padarn commented Oct 29, 2022 via email

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 30, 2022

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/82042

Note: Links to docs will display an error until the docs builds have been completed.

❌ 24 Failures

As of commit 7549f48:

The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@Padarn
Copy link
Contributor Author

Padarn commented Oct 30, 2022

I've updated with a test and some cleanup of the docs.

The MyPy lint is complaining because I'm setting a property on the module that doesn't exist. Does anyone have a suggestion for a nicer way to do that?

I'm also wondering if we should find a way to make this compatible with register_module_buffer_registration_hook which it (and the new prepend argument) is not.

@Padarn Padarn changed the title [Draft] Add kwarg support to nn.Module hooks Add kwarg support to nn.Module hooks Oct 31, 2022
mrshenli added a commit that referenced this pull request Nov 21, 2022
… to take kwargs"


closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042, this PR adds a `with_kwargs`
argument to `register_forward_pre_hook` and `register_forward_hook`
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hood, the hook is wrapped into `_ForwardHook`
and `_ForwardPreHook` types to avoid backward compatibility issues.

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 21, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042, this PR adds a `with_kwargs`
argument to `register_forward_pre_hook` and `register_forward_hook`
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hood, the hook is wrapped into `_ForwardHook`
and `_ForwardPreHook` types to avoid backward compatibility issues.

cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 Xia-Weiwen leslie-fang-intel albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 21, 2022
closes #35643

This PR is mostly copied from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042, this PR adds a `with_kwargs`
argument to `register_forward_pre_hook` and `register_forward_hook`
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hood, the hook is wrapped into `_ForwardHook`
and `_ForwardPreHook` types to avoid backward compatibility issues.

ghstack-source-id: 9332b4f
Pull Request resolved: #89389
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks @Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

ghstack-source-id: 3a4a013
Pull Request resolved: #89389
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
… to take kwargs"

closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

cc albanD mruberry jbschlosser walterddr kshitij12345 saketh-are

[ghstack-poisoned]
mrshenli added a commit that referenced this pull request Nov 22, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks @Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

ghstack-source-id: 1f40df4
Pull Request resolved: #89389
pytorchmergebot pushed a commit that referenced this pull request Nov 23, 2022
closes #35643

This PR is mostly borrowed from #82042. Thanks @Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

Pull Request resolved: #89389
Approved by: https://github.com/soulitzer
kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
)

closes pytorch#35643

This PR is mostly borrowed from pytorch#82042. Thanks @Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in pytorch#82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

Pull Request resolved: pytorch#89389
Approved by: https://github.com/soulitzer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed open source Stale triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants