pytorch - 💡(How to fix) Fix Build failure with libstdc++ 11 after #184309: `unordered_set | views::filter` not constrainable in _log_node_miss

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

torch/csrc/dynamo/python_compiled_autograd.cpp:421:39: error: invalid operands to binary expression ('const std::unordered_settorch::dynamo::autograd::CacheKey' and '_Partial<_Filter, (lambda at .../python_compiled_autograd.cpp:422:28)>') auto matching_sizes = cached_keys | ~~~~~~~~~~~ ^ .../include/c++/11/ranges:774:7: note: candidate template ignored: constraints not satisfied operator|(_Range&& __r, _Self&& __self) .../include/c++/11/ranges:772:5: note: because '__adaptor_invocable< _Partial<_Filter, lambda>, const std::unordered_set<CacheKey>&>' evaluated to false .../include/c++/11/bits/ranges_base.h:588:12: note: because 'std::ranges::ref_view<const std::unordered_set<CacheKey>>' does not satisfy 'range' 5 errors generated.

Root Cause

Error output

torch/csrc/dynamo/python_compiled_autograd.cpp:421:39: error: invalid operands to binary expression
  ('const std::unordered_set<torch::dynamo::autograd::CacheKey>' and
   '_Partial<_Filter, (lambda at .../python_compiled_autograd.cpp:422:28)>')
  auto matching_sizes = cached_keys |
                        ~~~~~~~~~~~ ^
.../include/c++/11/ranges:774:7: note: candidate template ignored: constraints not satisfied
  operator|(_Range&& __r, _Self&& __self)
.../include/c++/11/ranges:772:5: note: because '__adaptor_invocable<
  _Partial<_Filter, lambda>, const std::unordered_set<CacheKey>&>' evaluated to false
.../include/c++/11/bits/ranges_base.h:588:12: note: because
  'std::ranges::ref_view<const std::unordered_set<CacheKey>>' does not satisfy 'range'
5 errors generated.

Code Example

auto matching_sizes = cached_keys |
    std::views::filter(<const CacheKey& k|&> {
      return k.node_type == node_type;
    }) |
    std::views::transform(&CacheKey::key_size);

---

torch/csrc/dynamo/python_compiled_autograd.cpp:421:39: error: invalid operands to binary expression
  ('const std::unordered_set<torch::dynamo::autograd::CacheKey>' and
   '_Partial<_Filter, (lambda at .../python_compiled_autograd.cpp:422:28)>')
  auto matching_sizes = cached_keys |
                        ~~~~~~~~~~~ ^
.../include/c++/11/ranges:774:7: note: candidate template ignored: constraints not satisfied
  operator|(_Range&& __r, _Self&& __self)
.../include/c++/11/ranges:772:5: note: because '__adaptor_invocable<
  _Partial<_Filter, lambda>, const std::unordered_set<CacheKey>&>' evaluated to false
.../include/c++/11/bits/ranges_base.h:588:12: note: because
  'std::ranges::ref_view<const std::unordered_set<CacheKey>>' does not satisfy 'range'
5 errors generated.
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

After #184309 ("Replace ostringstream with fmt::format in python_compiled_autograd.cpp"), torch/csrc/dynamo/python_compiled_autograd.cpp fails to compile with libstdc++ 11.x (GCC 11 / clang+libstdc++11 toolchains).

The new code in _log_node_miss pipes a const std::unordered_set<CacheKey>& through std::views::filter:

auto matching_sizes = cached_keys |
    std::views::filter(<const CacheKey& k|&> {
      return k.node_type == node_type;
    }) |
    std::views::transform(&CacheKey::key_size);

libstdc++ 11's __adaptor_invocable SFINAE does not accept const std::unordered_set<T>& as a viewable range when piped through views::filter. This was improved in libstdc++ 13+; libc++ and MSVC STL both work fine. The PR's CI presumably ran on a newer toolchain, so this regression slipped through.

Error output

torch/csrc/dynamo/python_compiled_autograd.cpp:421:39: error: invalid operands to binary expression
  ('const std::unordered_set<torch::dynamo::autograd::CacheKey>' and
   '_Partial<_Filter, (lambda at .../python_compiled_autograd.cpp:422:28)>')
  auto matching_sizes = cached_keys |
                        ~~~~~~~~~~~ ^
.../include/c++/11/ranges:774:7: note: candidate template ignored: constraints not satisfied
  operator|(_Range&& __r, _Self&& __self)
.../include/c++/11/ranges:772:5: note: because '__adaptor_invocable<
  _Partial<_Filter, lambda>, const std::unordered_set<CacheKey>&>' evaluated to false
.../include/c++/11/bits/ranges_base.h:588:12: note: because
  'std::ranges::ref_view<const std::unordered_set<CacheKey>>' does not satisfy 'range'
5 errors generated.
  • Note: Tried to construct a minimal standalone repro on godbolt with gcc 11.4 + -std=c++20 but it did not trigger.

Versions

curl doesn't seem to work

cc @malfet @chauhang @penguinwu @xmfan @aditvenk

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix Build failure with libstdc++ 11 after #184309: `unordered_set | views::filter` not constrainable in _log_node_miss