Skip to content

Avoid std::tie and returning value constructions in qconv_unpack.cpp - #169207

Closed
cyyever wants to merge 1 commit into
pytorch:mainfrom
cyyever:std_tie33
Closed

cyyever wants to merge 1 commit into
pytorch:mainfrom
cyyever:std_tie33

Conversation

@cyyever

@cyyever cyyever commented Nov 28, 2025 •

Copy link
Copy Markdown
Collaborator

This PR avoids returning value construction in qconv_unpack.cpp.

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel

@pytorch-bot

pytorch-bot Bot commented Nov 28, 2025 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures, 1 Unrelated Failure

As of commit 965f445 with merge base 3bf5f6f (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@pytorch-bot pytorch-bot Bot added the release notes: quantization release notes category label Nov 28, 2025
@cyyever
cyyever requested a review from Skylion007 November 29, 2025 23:28
@cyyever cyyever changed the title Avoid std::tie Avoid std::tie and returning value construction qconv_unpack.cpp Nov 29, 2025
@cyyever cyyever changed the title Avoid std::tie and returning value construction qconv_unpack.cpp Avoid std::tie and returning value constructions in qconv_unpack.cpp Nov 29, 2025
@cyyever

cyyever commented Nov 30, 2025

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 30, 2025
@pytorchmergebot

Copy link
Copy Markdown
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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / win-vs2022-cpu-py3 / build

Details for Dev Infra team Raised by workflow job

@cyyever

cyyever commented Dec 1, 2025

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "Unrelated failures"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

@huydhn

huydhn commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

@pytorchbot revert -m 'I think this breaks some quantization tests, maybe they were wrongly skipped on CI' -c ghfirst

All of them are conv1d tests.

======================================================================
ERROR: test_dynamic_conv1d (caffe2.test.quantization.core.test_quantized_module.TestDynamicQuantizedModule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/testing/_internal/common_quantized.py", line 171, in test_fn
    qfunction(*args, **kwargs)
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 1539, in test_dynamic_conv1d
    self._test_qconv_impl(q_mod, dq_mod, dim, dtype, bias)
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 1442, in _test_qconv_impl
    Y_q_ref = quantized_module(X_q)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1778, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1789, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/ao/nn/quantized/modules/conv.py", line 466, in forward
    return ops.quantized.conv1d(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/_ops.py", line 1258, in __call__
    return self._op(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: required rank 4 tensor to use channels_last format

======================================================================
ERROR: test_dynamic_convtranspose1d (caffe2.test.quantization.core.test_quantized_module.TestDynamicQuantizedModule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/testing/_internal/common_quantized.py", line 171, in test_fn
    qfunction(*args, **kwargs)
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 1571, in test_dynamic_convtranspose1d
    self._test_qconv_impl(q_mod, dq_mod, dim, dtype, bias)
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 1442, in _test_qconv_impl
    Y_q_ref = quantized_module(X_q)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1778, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1789, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/ao/nn/quantized/modules/conv.py", line 988, in forward
    return torch.ops.quantized.conv_transpose1d(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/_ops.py", line 1258, in __call__
    return self._op(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: required rank 4 tensor to use channels_last format

======================================================================
ERROR: test_conv1d_api (caffe2.test.quantization.core.test_quantized_module.TestStaticQuantizedModule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/testing/_internal/common_quantized.py", line 171, in test_fn
    qfunction(*args, **kwargs)
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 477, in test_conv1d_api
    self._test_conv_api_impl(
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 319, in _test_conv_api_impl
    Y_act = qconv_module(*example_input_q)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1778, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1789, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/ao/nn/quantized/modules/conv.py", line 466, in forward
    return ops.quantized.conv1d(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/_ops.py", line 1258, in __call__
    return self._op(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: required rank 4 tensor to use channels_last format

======================================================================
ERROR: test_conv1d_relu_api (caffe2.test.quantization.core.test_quantized_module.TestStaticQuantizedModule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/testing/_internal/common_quantized.py", line 171, in test_fn
    qfunction(*args, **kwargs)
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 531, in test_conv1d_relu_api
    self._test_conv_api_impl(
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/caffe2/test/quantization/core/test_quantized_module.py", line 319, in _test_conv_api_impl
    Y_act = qconv_module(*example_input_q)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1778, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/nn/modules/module.py", line 1789, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/ao/nn/intrinsic/quantized/modules/conv_relu.py", line 74, in forward
    return torch.ops.quantized.conv1d_relu(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/re_cwd/buck-out/v2/gen/fbcode/890c3e2fa31c5320/caffe2/test/quantization/__test_quantization__/test_quantization#link-tree/torch/_ops.py", line 1258, in __call__
    return self._op(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: required rank 4 tensor to use channels_last format

----------------------------------------------------------------------
Ran 4 tests in 1.247s

FAILED (errors=4)

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Dec 1, 2025
…ack.cpp (#169207)"

This reverts commit d503895.

Reverted #169207 on behalf of https://github.com/huydhn due to I think this breaks some quantization tests, maybe they were wrongly skipped on CI ([comment](#169207 (comment)))
@cyyever cyyever reopened this Dec 4, 2025
@cyyever

cyyever commented Dec 4, 2025 •

Copy link
Copy Markdown
Collaborator Author

@huydhn Interestingly because the FBGEMM case modifies original tensor before this PR. Nevertheless, let's avoid in-place OPs in all three cases.

@cyyever

cyyever commented Dec 7, 2025

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "Apply Claude sugguestion"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

umechand-amd pushed a commit to ROCm/pytorch that referenced this pull request Dec 8, 2025
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
…ack.cpp (#169207)"

This reverts commit d503895.

Reverted #169207 on behalf of https://github.com/huydhn due to I think this breaks some quantization tests, maybe they were wrongly skipped on CI ([comment](#169207 (comment)))
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
…ack.cpp (#169207)"

This reverts commit bb30341.

Reverted #169207 on behalf of https://github.com/huydhn due to Sorry to keep reverting this, but the issue is still there ([comment](#169207 (comment)))
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
@huydhn

huydhn commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

@pytorchbot revert -m 'Sorry for revert this change (again), but there are some new failures showing up and the blast radius is large so I need to revert' -c ghfirst

Here is an example stack trace.

======================================================================
ERROR: test_conv_transpose_1d (quantization.fx.test_quantize_fx.TestQuantizeFxOps)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/quantization/fx/test_quantize_fx.py", line 8897, in test_conv_transpose_1d
    self._test_conv_transpose_impl(
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/quantization/fx/test_quantize_fx.py", line 8878, in _test_conv_transpose_impl
    result_dict = self.checkGraphModeFxOp(
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/torch/testing/_internal/common_quantization.py", line 1312, in checkGraphModeFxOp
    qgraph_copy = copy.deepcopy(qgraph)
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/fbcode/platform010/lib/python3.12/copy.py", line 143, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/torch/fx/graph_module.py", line 1005, in __deepcopy__
    fake_mod = _CodeOnlyModule(copy.deepcopy(self.__dict__, memo))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/fbcode/platform010/lib/python3.12/copy.py", line 136, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/local/fbcode/platform010/lib/python3.12/copy.py", line 221, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/fbcode/platform010/lib/python3.12/copy.py", line 136, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/local/fbcode/platform010/lib/python3.12/copy.py", line 221, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/fbcode/platform010/lib/python3.12/copy.py", line 143, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/torch/ao/nn/quantized/modules/conv.py", line 237, in __deepcopy__
    state = self.__getstate__()
            ^^^^^^^^^^^^^^^^^^^
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/torch/ao/nn/quantized/modules/conv.py", line 168, in __getstate__
    (w, b) = self._weight_bias()
             ^^^^^^^^^^^^^^^^^^^
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/torch/ao/nn/quantized/modules/conv.py", line 972, in _weight_bias
    w, b = torch.ops.quantized.conv_transpose1d_unpack(self._packed_params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/sandcastle/boxes/trunk-hg-full-fbsource/buck-out/v2/gen/fbcode/4e7c31b385bb05ac/caffe2/test/__quantization_fx__/quantization_fx#link-tree/torch/_ops.py", line 1209, in __call__
    return self._op(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Didn't find engine for operation quantized::conv1d_unpack QNNPACK
----------------------------------------------------------------------
Ran 1 test in 0.402s
FAILED (errors=1)

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Dec 10, 2025
…ack.cpp (#169207)"

This reverts commit 0aeec0a.

Reverted #169207 on behalf of https://github.com/huydhn due to Sorry for revert this change (again), but there are some new failures showing up and the blast radius is large so I need to revert ([comment](#169207 (comment)))
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@cyyever your PR has been successfully reverted.

skpark-rh pushed a commit to skpark-rh/pytorch that referenced this pull request Dec 10, 2025
…ack.cpp (pytorch#169207)"

This reverts commit 0aeec0a.

Reverted pytorch#169207 on behalf of https://github.com/huydhn due to Sorry for revert this change (again), but there are some new failures showing up and the blast radius is large so I need to revert ([comment](pytorch#169207 (comment)))
@github-actions github-actions Bot added the Stale label Feb 8, 2026
@github-actions github-actions Bot closed this Mar 10, 2026
@cyyever cyyever reopened this Apr 20, 2026
@pytorch pytorch deleted a comment from github-actions Bot Apr 20, 2026
cyyever added a commit to cyyever/pytorch that referenced this pull request Apr 20, 2026
@github-actions github-actions Bot closed this May 20, 2026
@cyyever
cyyever deleted the std_tie33 branch July 3, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/quantization-periodic ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: quantization release notes category Reverted Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants