Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPS] Fix embedding backward with scalar index #82809

Closed
wants to merge 1 commit into from

Conversation

qqaatw
Copy link
Collaborator

@qqaatw qqaatw commented Aug 4, 2022

Description

Previously the embedding backward always expands -1 dim to indices, resulting in the following error when the indices is a scalar:

 error: Rank of data array must equal number of outer dimensions in indices array + rank of slice to update, 2 != 1 + 0
-:8:10: note: see current operation: %5 = "mps.scatter_nd"(%0, %arg1, %4) {batch_dims = 0 : ui32, mode = 0 : i32} : (tensor<10x5xf16>, 

Now makes it conditional.

Reproducer:

def repro():
    w = torch.tensor([[-2.6465,  2.5859,  0.4688,  1.7949,  3.2676],
        [-3.1641,  8.9375,  5.7578, -2.9453, -6.5469],
        [ 2.0469,  1.3516, -8.7344,  6.0000,  1.3906],
        [ 6.5781,  7.8438,  6.9766,  3.2891, -5.1172],
        [-7.9414,  7.7344,  4.1875,  2.8574,  2.9531],
        [-0.4844, -5.6328, -6.8359, -4.5156,  3.7891],
        [ 4.9375,  6.6094,  6.7031,  0.6719, -6.4219],
        [ 7.0469,  8.2031,  4.4453,  1.7129, -2.4688],
        [ 1.2207, -3.3750, -2.4531,  7.4062, -6.0469],
        [-8.9688,  2.2656,  2.4160, -1.0176,  8.4531]], dtype=torch.float32, requires_grad=True)
    x = torch.tensor(5)
    out = torch.nn.functional.embedding(x, w)
    out.sum().backward()

    w_mps = w.detach().clone().to("mps").requires_grad_()
    x_mps = x.to("mps")
    out = torch.nn.functional.embedding(x_mps, w_mps)
    out.sum().backward() # error

Issue

Testing

cc @kulinseth @albanD @malfet @DenisVieriu97 @razarmehr @abhudev

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Aug 4, 2022

🔗 Helpful links

❌ 8 New Failures, 9 Pending

As of commit 2410db0 (more details on the Dr. CI page):

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

🕵️ 8 new failures recognized by patterns

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

See GitHub Actions build trunk / win-vs2019-cuda11.6-py3 / test (default, 3, 5, windows.8xlarge.nvidia.gpu) (1/8)

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

2022-08-04T13:22:02.8144766Z FAIL [0.010s]: test_lcm_cuda_int64 (__main__.TestBinaryUfuncsCUDA)
2022-08-04T13:22:02.8142234Z     return fn(self, *args, **kwargs)
2022-08-04T13:22:02.8142413Z   File "test_binary_ufuncs.py", line 2841, in test_lcm
2022-08-04T13:22:02.8142590Z     self.assertEqual(actual, expected, exact_dtype=False)
2022-08-04T13:22:02.8142959Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\testing\_internal\common_utils.py", line 2357, in assertEqual
2022-08-04T13:22:02.8143049Z     assert_equal(
2022-08-04T13:22:02.8143398Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\testing\_comparison.py", line 1093, in assert_equal
2022-08-04T13:22:02.8143529Z     raise error_metas[0].to_error(msg)
2022-08-04T13:22:02.8143781Z AssertionError: Object comparison failed: tensor([0, 0, 0], device='cuda:0', dtype=torch.int32) != array([0, 0, 0])
2022-08-04T13:22:02.8144419Z 
2022-08-04T13:22:02.8144584Z ======================================================================
2022-08-04T13:22:02.8144766Z FAIL [0.010s]: test_lcm_cuda_int64 (__main__.TestBinaryUfuncsCUDA)
2022-08-04T13:22:02.8144954Z ----------------------------------------------------------------------
2022-08-04T13:22:02.8145078Z Traceback (most recent call last):
2022-08-04T13:22:02.8145498Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\testing\_internal\common_device_type.py", line 377, in instantiated_test
2022-08-04T13:22:02.8145628Z     result = test(self, **param_kwargs)
2022-08-04T13:22:02.8145996Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\testing\_internal\common_device_type.py", line 1010, in only_fn
2022-08-04T13:22:02.8146118Z     return fn(self, *args, **kwargs)
2022-08-04T13:22:02.8146298Z   File "test_binary_ufuncs.py", line 2841, in test_lcm
2022-08-04T13:22:02.8146460Z     self.assertEqual(actual, expected, exact_dtype=False)
2022-08-04T13:22:02.8146838Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\testing\_internal\common_utils.py", line 2357, in assertEqual
2022-08-04T13:22:02.8146928Z     assert_equal(

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

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

2022-08-04T10:31:10.0450631Z AssertionError: Th...functional.prelu on device type cpu are incorrect!
2022-08-04T10:31:10.0439119Z [gw3] [  1%] FAILED test_ops.py::TestCommonCPU::test_dtypes__refs_nn_functional_prelu_cpu 
2022-08-04T10:31:10.0439324Z 
2022-08-04T10:31:10.0439448Z ================================== FAILURES ===================================
2022-08-04T10:31:10.0439775Z ___________ TestCommonCPU.test_dtypes__refs_nn_functional_prelu_cpu ___________
2022-08-04T10:31:10.0440096Z [gw3] win32 -- Python 3.8.13 C:\Jenkins\Miniconda3\python.exe
2022-08-04T10:31:10.0440362Z Traceback (most recent call last):
2022-08-04T10:31:10.0449214Z   File "C:\actions-runner\_work\pytorch\pytorch\test\test_ops.py", line 1227, in test_dtypes
2022-08-04T10:31:10.0449644Z     self.fail(msg)
2022-08-04T10:31:10.0449963Z   File "C:\Jenkins\Miniconda3\lib\unittest\case.py", line 753, in fail
2022-08-04T10:31:10.0450270Z     raise self.failureException(msg)
2022-08-04T10:31:10.0450631Z AssertionError: The supported dtypes for _refs.nn.functional.prelu on device type cpu are incorrect!
2022-08-04T10:31:10.0451087Z The following dtypes did not work in forward but are listed by the OpInfo: {torch.bfloat16, torch.float32, torch.float64}.
2022-08-04T10:31:10.0451328Z 
2022-08-04T10:31:10.0451593Z - generated xml file: C:\actions-runner\_work\pytorch\pytorch\test\test-reports\python-pytest\test_ops\test_ops.xml -
2022-08-04T10:31:10.0452011Z =========================== short test summary info ===========================
2022-08-04T10:31:10.0452337Z FAILED test_ops.py::TestCommonCPU::test_dtypes__refs_nn_functional_prelu_cpu
2022-08-04T10:31:10.0452658Z !!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!
2022-08-04T10:31:10.0452957Z !!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!
2022-08-04T10:31:10.0453293Z ======= 1 failed, 236 passed, 7 skipped, 42 warnings, 2 rerun in 21.92s =======
2022-08-04T10:31:10.6878246Z Traceback (most recent call last):
2022-08-04T10:31:10.6878629Z   File "run_test.py", line 974, in <module>

See GitHub Actions build trunk / win-vs2019-cuda11.6-py3 / test (default, 1, 5, windows.8xlarge.nvidia.gpu) (3/8)

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

2022-08-04T13:10:46.1809900Z AssertionError: Th...unctional.prelu on device type cuda are incorrect!
2022-08-04T13:10:46.1787996Z 
2022-08-04T13:10:46.1788605Z For more information about alternatives visit: ('https://numba.pydata.org/numba-doc/latest/cuda/overview.html', '#cudatoolkit-lookup')�[0m
2022-08-04T13:10:46.1789548Z   warnings.warn(errors.NumbaWarning(msg))
2022-08-04T13:10:46.1790309Z __________ TestCommonCUDA.test_dtypes__refs_nn_functional_prelu_cuda __________
2022-08-04T13:10:46.1791083Z [gw1] win32 -- Python 3.8.13 C:\Jenkins\Miniconda3\python.exe
2022-08-04T13:10:46.1791691Z Traceback (most recent call last):
2022-08-04T13:10:46.1806822Z   File "C:\actions-runner\_work\pytorch\pytorch\test\test_ops.py", line 1227, in test_dtypes
2022-08-04T13:10:46.1807669Z     self.fail(msg)
2022-08-04T13:10:46.1808381Z   File "C:\Jenkins\Miniconda3\lib\unittest\case.py", line 753, in fail
2022-08-04T13:10:46.1809082Z     raise self.failureException(msg)
2022-08-04T13:10:46.1809900Z AssertionError: The supported dtypes for _refs.nn.functional.prelu on device type cuda are incorrect!
2022-08-04T13:10:46.1810509Z The following dtypes did not work in forward but are listed by the OpInfo: {torch.float64, torch.float32, torch.float16}.
2022-08-04T13:10:46.1810803Z 
2022-08-04T13:10:46.1811118Z - generated xml file: C:\actions-runner\_work\pytorch\pytorch\test\test-reports\python-pytest\test_ops\test_ops.xml -
2022-08-04T13:10:46.1811577Z =========================== short test summary info ===========================
2022-08-04T13:10:46.1811988Z FAILED test_ops.py::TestCommonCUDA::test_dtypes__refs_nn_functional_prelu_cuda
2022-08-04T13:10:46.1812384Z !!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!
2022-08-04T13:10:46.1813390Z !!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!
2022-08-04T13:10:46.1813833Z = 1 failed, 201 passed, 5 skipped, 62 warnings, 2 rerun in 113.40s (0:01:53) ==
2022-08-04T13:10:47.0789250Z Traceback (most recent call last):
2022-08-04T13:10:47.0789715Z   File "run_test.py", line 974, in <module>

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

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

2022-08-04T10:39:19.3221762Z RuntimeError: test_ops_gradients failed!
2022-08-04T10:39:18.8752742Z =========================== short test summary info ===========================
2022-08-04T10:39:18.8753077Z FAILED test_ops_gradients.py::TestGradientsCPU::test_fn_fwgrad_bwgrad_nn_functional_prelu_cpu_float64
2022-08-04T10:39:18.8753394Z !!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!
2022-08-04T10:39:18.8753680Z !!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!
2022-08-04T10:39:18.8753981Z = 1 failed, 320 passed, 1000 skipped, 7 xfailed, 49 warnings, 2 rerun in 49.87s =
2022-08-04T10:39:19.3220505Z Traceback (most recent call last):
2022-08-04T10:39:19.3220868Z   File "run_test.py", line 974, in <module>
2022-08-04T10:39:19.3221085Z     main()
2022-08-04T10:39:19.3221298Z   File "run_test.py", line 952, in main
2022-08-04T10:39:19.3221530Z     raise RuntimeError(err_message)
2022-08-04T10:39:19.3221762Z RuntimeError: test_ops_gradients failed!
2022-08-04T10:39:19.5211187Z 
2022-08-04T10:39:19.5211713Z (base) C:\actions-runner\_work\pytorch\pytorch\test>if ERRORLEVEL 1 goto fail 
2022-08-04T10:39:19.5213355Z 
2022-08-04T10:39:19.5213579Z (base) C:\actions-runner\_work\pytorch\pytorch\test>exit /b 1 
2022-08-04T10:39:19.5265646Z ##[error]Process completed with exit code 1.
2022-08-04T10:39:19.5396305Z Prepare all required actions
2022-08-04T10:39:19.5396831Z Getting action download info
2022-08-04T10:39:19.6947659Z Download action repository 'nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a' (SHA:71062288b76e2b6214ebde0e673ce0de1755740a)
2022-08-04T10:39:20.0390345Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-08-04T10:39:20.0390559Z with:

See GitHub Actions build trunk / win-vs2019-cuda11.6-py3 / test (default, 4, 5, windows.8xlarge.nvidia.gpu) (5/8)

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

2022-08-04T13:45:50.1984400Z RuntimeError: test_decomp failed!
2022-08-04T13:45:48.3416237Z 
2022-08-04T13:45:48.3418829Z FAILED (errors=6, skipped=261, expected failures=34)
2022-08-04T13:45:48.3419213Z 
2022-08-04T13:45:48.3419347Z Generating XML reports...
2022-08-04T13:45:48.3419781Z Generated XML report: test-reports\python-unittest\test_decomp\TEST-TestDecompCUDA-20220804130947.xml
2022-08-04T13:45:50.1980290Z Traceback (most recent call last):
2022-08-04T13:45:50.1980755Z   File "run_test.py", line 974, in <module>
2022-08-04T13:45:50.1981115Z     main()
2022-08-04T13:45:50.1981583Z   File "run_test.py", line 952, in main
2022-08-04T13:45:50.1982034Z     raise RuntimeError(err_message)
2022-08-04T13:45:50.1984400Z RuntimeError: test_decomp failed!
2022-08-04T13:45:50.5758326Z 
2022-08-04T13:45:50.5759012Z (base) C:\actions-runner\_work\pytorch\pytorch\test>if ERRORLEVEL 1 goto fail 
2022-08-04T13:45:50.5762234Z 
2022-08-04T13:45:50.5762707Z (base) C:\actions-runner\_work\pytorch\pytorch\test>exit /b 1 
2022-08-04T13:45:50.5832477Z ##[error]Process completed with exit code 1.
2022-08-04T13:45:50.6123560Z Prepare all required actions
2022-08-04T13:45:50.6124181Z Getting action download info
2022-08-04T13:45:50.7962878Z Download action repository 'nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a' (SHA:71062288b76e2b6214ebde0e673ce0de1755740a)
2022-08-04T13:45:51.0016830Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-08-04T13:45:51.0017108Z with:

See GitHub Actions build trunk / win-vs2019-cuda11.6-py3 / test (default, 5, 5, windows.8xlarge.nvidia.gpu) (6/8)

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

2022-08-04T13:27:12.8344315Z RuntimeError: test_jit_cuda_fuser failed!
2022-08-04T13:27:03.6474477Z Generating XML reports...
2022-08-04T13:27:03.6474911Z Generated XML report: test-reports\python-unittest\test_jit_cuda_fuser\TEST-TestCudaFuser-20220804130417.xml
2022-08-04T13:27:03.6475543Z Generated XML report: test-reports\python-unittest\test_jit_cuda_fuser\TEST-TestEnableDisableCudaFuser-20220804130417.xml
2022-08-04T13:27:03.6476200Z Generated XML report: test-reports\python-unittest\test_jit_cuda_fuser\TEST-jit.test_fuser_common.TestFuserCommon-20220804130417.xml
2022-08-04T13:27:03.6476841Z Generated XML report: test-reports\python-unittest\test_jit_cuda_fuser\TEST-TestCudaFuserOpInfoCUDA-20220804130417.xml
2022-08-04T13:27:12.8342634Z Traceback (most recent call last):
2022-08-04T13:27:12.8343128Z   File "run_test.py", line 974, in <module>
2022-08-04T13:27:12.8343396Z     main()
2022-08-04T13:27:12.8343687Z   File "run_test.py", line 952, in main
2022-08-04T13:27:12.8344007Z     raise RuntimeError(err_message)
2022-08-04T13:27:12.8344315Z RuntimeError: test_jit_cuda_fuser failed!
2022-08-04T13:27:13.2466255Z 
2022-08-04T13:27:13.2467147Z (base) C:\actions-runner\_work\pytorch\pytorch\test>if ERRORLEVEL 1 goto fail 
2022-08-04T13:27:13.2471010Z 
2022-08-04T13:27:13.2471672Z (base) C:\actions-runner\_work\pytorch\pytorch\test>exit /b 1 
2022-08-04T13:27:13.2542198Z ##[error]Process completed with exit code 1.
2022-08-04T13:27:13.2800954Z Prepare all required actions
2022-08-04T13:27:13.2801604Z Getting action download info
2022-08-04T13:27:13.4524999Z Download action repository 'nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a' (SHA:71062288b76e2b6214ebde0e673ce0de1755740a)
2022-08-04T13:27:13.7470415Z ##[group]Run ./.github/actions/get-workflow-job-id
2022-08-04T13:27:13.7470695Z with:

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

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

2022-08-04T10:45:43.3947292Z RuntimeError: C:\a...rk\pytorch\pytorch\functorch\test\test_ops failed!
2022-08-04T10:45:42.7587408Z 
2022-08-04T10:45:42.7587558Z FAILED (errors=10, skipped=1620, expected failures=304)
2022-08-04T10:45:42.7587719Z 
2022-08-04T10:45:42.7587817Z Generating XML reports...
2022-08-04T10:45:42.7588207Z Generated XML report: test-reports\python-unittest\functorch\test\test_ops\TEST-TestOperatorsCPU-20220804103238.xml
2022-08-04T10:45:43.3945893Z Traceback (most recent call last):
2022-08-04T10:45:43.3946261Z   File "run_test.py", line 974, in <module>
2022-08-04T10:45:43.3946464Z     main()
2022-08-04T10:45:43.3946695Z   File "run_test.py", line 952, in main
2022-08-04T10:45:43.3946949Z     raise RuntimeError(err_message)
2022-08-04T10:45:43.3947292Z RuntimeError: C:\actions-runner\_work\pytorch\pytorch\functorch\test\test_ops failed!
2022-08-04T10:45:43.6643613Z 
2022-08-04T10:45:43.6643965Z (base) C:\actions-runner\_work\pytorch\pytorch\test>popd
2022-08-04T10:45:43.6649441Z 
2022-08-04T10:45:43.6649712Z (base) C:\actions-runner\_work\pytorch\pytorch>if ERRORLEVEL 1 goto fail 
2022-08-04T10:45:43.6651930Z 
2022-08-04T10:45:43.6652482Z (base) C:\actions-runner\_work\pytorch\pytorch>exit /b 1 
2022-08-04T10:45:43.6711075Z ##[error]Process completed with exit code 1.
2022-08-04T10:45:43.6863854Z Prepare all required actions
2022-08-04T10:45:43.6864421Z Getting action download info
2022-08-04T10:45:43.8575586Z Download action repository 'nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a' (SHA:71062288b76e2b6214ebde0e673ce0de1755740a)

See GitHub Actions build trunk / win-vs2019-cuda11.6-py3 / test (functorch, 1, 1, windows.8xlarge.nvidia.gpu) (8/8)

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

2022-08-04T13:37:40.8244724Z RuntimeError: C:\a...rk\pytorch\pytorch\functorch\test\test_ops failed!
2022-08-04T13:37:39.1490259Z 
2022-08-04T13:37:39.1492285Z FAILED (errors=10, skipped=1596, expected failures=306)
2022-08-04T13:37:39.1492656Z 
2022-08-04T13:37:39.1493076Z Generating XML reports...
2022-08-04T13:37:39.1493608Z Generated XML report: test-reports\python-unittest\functorch\test\test_ops\TEST-TestOperatorsCUDA-20220804131133.xml
2022-08-04T13:37:40.8242652Z Traceback (most recent call last):
2022-08-04T13:37:40.8243301Z   File "run_test.py", line 974, in <module>
2022-08-04T13:37:40.8243727Z     main()
2022-08-04T13:37:40.8244024Z   File "run_test.py", line 952, in main
2022-08-04T13:37:40.8244337Z     raise RuntimeError(err_message)
2022-08-04T13:37:40.8244724Z RuntimeError: C:\actions-runner\_work\pytorch\pytorch\functorch\test\test_ops failed!
2022-08-04T13:37:41.2029207Z 
2022-08-04T13:37:41.2030017Z (base) C:\actions-runner\_work\pytorch\pytorch\test>popd
2022-08-04T13:37:41.2035628Z 
2022-08-04T13:37:41.2036101Z (base) C:\actions-runner\_work\pytorch\pytorch>if ERRORLEVEL 1 goto fail 
2022-08-04T13:37:41.2039814Z 
2022-08-04T13:37:41.2040150Z (base) C:\actions-runner\_work\pytorch\pytorch>exit /b 1 
2022-08-04T13:37:41.2109388Z ##[error]Process completed with exit code 1.
2022-08-04T13:37:41.2466034Z Prepare all required actions
2022-08-04T13:37:41.2466656Z Getting action download info
2022-08-04T13:37:41.6002547Z Download action repository 'nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a' (SHA:71062288b76e2b6214ebde0e673ce0de1755740a)

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.

@qqaatw
Copy link
Collaborator Author

qqaatw commented Aug 4, 2022

@pytorchbot label "ciflow/trunk" "module: mps"

@pytorch-bot pytorch-bot bot added ciflow/trunk Trigger trunk jobs on your pull request module: mps Related to Apple Metal Performance Shaders framework labels Aug 4, 2022
@qqaatw qqaatw marked this pull request as ready for review August 4, 2022 12:19
@qqaatw qqaatw requested a review from kulinseth as a code owner August 4, 2022 12:19
@qqaatw qqaatw changed the title [MPS] Fix embedding scalar index backward [MPS] Fix embedding backward with scalar index Aug 4, 2022
@dagitses dagitses added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Aug 5, 2022
@qqaatw
Copy link
Collaborator Author

qqaatw commented Aug 19, 2022

@kulinseth @albanD can you please take a look?

@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: qqaatw / name: Li-Huai (Allan) Lin (2410db0)

@qqaatw
Copy link
Collaborator Author

qqaatw commented Oct 26, 2022

/easycla

@qqaatw
Copy link
Collaborator Author

qqaatw commented Oct 26, 2022

@pytorchbot rebase

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 26, 2022

You don't have permissions to rebase this PR, only people with write permissions may rebase PRs.

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 26, 2022

🔗 Helpful Links

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

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

✅ No Failures

As of commit 8da9071:
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot pytorch-bot bot added ciflow/mps Run MPS tests (subset of trunk) release notes: mps Release notes category labels Nov 4, 2022
@malfet
Copy link
Contributor

malfet commented Nov 4, 2022

Cancelled rebase, looks good to me

@malfet
Copy link
Contributor

malfet commented Nov 4, 2022

@pytorchbot merge - f "MPS tests are green"

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 4, 2022

❌ 🤖 pytorchbot command failed:

@pytorchbot: error: unrecognized arguments: - f MPS tests are green

usage: @pytorchbot [-h] {merge,revert,rebase,label} ...

Try @pytorchbot --help for more info.

@qqaatw
Copy link
Collaborator Author

qqaatw commented Nov 4, 2022

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Nov 5, 2022
### Description
Previously the embedding backward always expands `-1` dim to indices, resulting in the following error when the indices is a scalar:

```
 error: Rank of data array must equal number of outer dimensions in indices array + rank of slice to update, 2 != 1 + 0
-:8:10: note: see current operation: %5 = "mps.scatter_nd"(%0, %arg1, %4) {batch_dims = 0 : ui32, mode = 0 : i32} : (tensor<10x5xf16>,
```

Now makes it conditional.

Reproducer:

```python
def repro():
    w = torch.tensor([[-2.6465,  2.5859,  0.4688,  1.7949,  3.2676],
        [-3.1641,  8.9375,  5.7578, -2.9453, -6.5469],
        [ 2.0469,  1.3516, -8.7344,  6.0000,  1.3906],
        [ 6.5781,  7.8438,  6.9766,  3.2891, -5.1172],
        [-7.9414,  7.7344,  4.1875,  2.8574,  2.9531],
        [-0.4844, -5.6328, -6.8359, -4.5156,  3.7891],
        [ 4.9375,  6.6094,  6.7031,  0.6719, -6.4219],
        [ 7.0469,  8.2031,  4.4453,  1.7129, -2.4688],
        [ 1.2207, -3.3750, -2.4531,  7.4062, -6.0469],
        [-8.9688,  2.2656,  2.4160, -1.0176,  8.4531]], dtype=torch.float32, requires_grad=True)
    x = torch.tensor(5)
    out = torch.nn.functional.embedding(x, w)
    out.sum().backward()

    w_mps = w.detach().clone().to("mps").requires_grad_()
    x_mps = x.to("mps")
    out = torch.nn.functional.embedding(x_mps, w_mps)
    out.sum().backward() # error
```

### Issue
<!-- Link to Issue ticket or RFP -->

### Testing
<!-- How did you test your change? -->

Pull Request resolved: pytorch#82809
Approved by: https://github.com/malfet
kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
### Description
Previously the embedding backward always expands `-1` dim to indices, resulting in the following error when the indices is a scalar:

```
 error: Rank of data array must equal number of outer dimensions in indices array + rank of slice to update, 2 != 1 + 0
-:8:10: note: see current operation: %5 = "mps.scatter_nd"(%0, %arg1, %4) {batch_dims = 0 : ui32, mode = 0 : i32} : (tensor<10x5xf16>,
```

Now makes it conditional.

Reproducer:

```python
def repro():
    w = torch.tensor([[-2.6465,  2.5859,  0.4688,  1.7949,  3.2676],
        [-3.1641,  8.9375,  5.7578, -2.9453, -6.5469],
        [ 2.0469,  1.3516, -8.7344,  6.0000,  1.3906],
        [ 6.5781,  7.8438,  6.9766,  3.2891, -5.1172],
        [-7.9414,  7.7344,  4.1875,  2.8574,  2.9531],
        [-0.4844, -5.6328, -6.8359, -4.5156,  3.7891],
        [ 4.9375,  6.6094,  6.7031,  0.6719, -6.4219],
        [ 7.0469,  8.2031,  4.4453,  1.7129, -2.4688],
        [ 1.2207, -3.3750, -2.4531,  7.4062, -6.0469],
        [-8.9688,  2.2656,  2.4160, -1.0176,  8.4531]], dtype=torch.float32, requires_grad=True)
    x = torch.tensor(5)
    out = torch.nn.functional.embedding(x, w)
    out.sum().backward()

    w_mps = w.detach().clone().to("mps").requires_grad_()
    x_mps = x.to("mps")
    out = torch.nn.functional.embedding(x_mps, w_mps)
    out.sum().backward() # error
```

### Issue
<!-- Link to Issue ticket or RFP -->

### Testing
<!-- How did you test your change? -->

Pull Request resolved: pytorch#82809
Approved by: https://github.com/malfet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/mps Run MPS tests (subset of trunk) ciflow/trunk Trigger trunk jobs on your pull request cla signed Merged module: mps Related to Apple Metal Performance Shaders framework open source release notes: mps Release notes category 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.

None yet

7 participants