Skip to content

build: Update C++ standard from c++17 to c++20 - #525

Merged
mc-nv merged 5 commits into
mainfrom
mchornyi/TRI-1877/TRI-1855-std-20
Sep 11, 2026
Merged

build: Update C++ standard from c++17 to c++20#525
mc-nv merged 5 commits into
mainfrom
mchornyi/TRI-1877/TRI-1855-std-20

Conversation

@mc-nv

@mc-nv mc-nv commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What does the PR do?

  • Upstream PyTorch raised ATen's minimum required C++ standard from 17 to 20 ([12/12] Enforce C++20 minimum in header guards (#178150) pytorch/pytorch#178150), breaking the pytorch_backend build.
  • Bumps this repo's C++ standard default from 17 to 20 for consistency across the Triton stack.
  • Also fixes a genuine C++20 compile break surfaced by the bump: explicit this capture in a lambda in src/backend_model.cc (implicit capture via [=] is deprecated in C++20, and this repo builds with -Werror=deprecated).

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

Check the conventional commit type box here and add the label to the github PR.

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • test

Related PRs:

Where should the reviewer start?

  • CMakeLists.txt - src/backend_model.cc

Test plan:

  • CI Pipeline ID: 67062220

Caveats:

This repo's own build broke under C++20 (see the fix commit) — the deprecated-lambda-capture error was found and fixed as part of this same change, not a separate follow-up.

Background

Part of a coordinated C++17->C++20 bump across ~18 Triton component repos (TRI-1877), triggered by upstream PyTorch's ATen.h now requiring C++20.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Resolves: TRI-1877

Upstream PyTorch raised ATen's minimum required C++ standard from 17
to 20 (pytorch/pytorch#178150), which broke the pytorch_backend build.
Align this repo's TRITON_MIN_CXX_STANDARD/CMAKE_CXX_STANDARD default
with that floor for consistency across the stack.

TRI-1877
C++20 deprecates implicit capture of 'this' via a bare '[=]' default
capture (CWG2211); with -Werror=deprecated this now fails the build
after the C++17->20 bump. List 'this' explicitly alongside the
existing by-value default and '&instance_mu' reference capture.

TRI-1877
@mc-nv mc-nv self-assigned this Sep 9, 2026
@mc-nv mc-nv added build Build system or external dependencies (build: PRs) fix Bug fix (fix: PRs) labels Sep 9, 2026
This was referenced Sep 9, 2026
Same class of bug just fixed in tensorrt_backend's semaphore.h and
filesystem.h: a project header sharing a name with a C++ standard
library header, combined with a project include directory preceding
the system include path, risks a future internal #include <memory>
from libstdc++ silently resolving to this project's own header. Not
currently triggering a build failure (core built successfully with
TRITON_MIN_CXX_STANDARD=20 in the observed CI runs), but renamed
proactively given the same repo family already proved this exact
pattern live once.

TRI-1877
Missed in the prior memory.h/.cc -> triton_memory.h/.cc rename commit:
src/test/CMakeLists.txt lists ../memory.cc/../memory.h directly as
MEMORY_SRCS/MEMORY_HDRS (not via #include), which is a distinct
reference path my earlier sed pass over #include statements and
src/CMakeLists.txt didn't touch. Broke CMake configure with "Cannot
find source file: ../memory.cc" for response_cache_test.

TRI-1877
@mc-nv
mc-nv marked this pull request as ready for review September 10, 2026 15:28
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the previous Python-binding inconsistency fully resolved and no new actionable failures identified.

Summary

  • Propagates TRITON_MIN_CXX_STANDARD to the Python binding target.
  • Explicitly captures this in the asynchronous model-instance creation lambda for C++20 compatibility.
  • Renames the internal memory.h and memory.cc files to avoid a C++20-era header-name conflict and updates their references.
  • The previous Python-binding standard inconsistency is fully fixed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Standard[TRITON_MIN_CXX_STANDARD = 20] --> Stub[Server stub]
  Standard --> Core[Core library]
  Standard --> Python[Python bindings]
  Core --> Compatibility[Explicit this capture]
  Core --> Memory[triton_memory header and source]
Loading

Reviews (2) · Last reviewed commit: "fix: use TRITON_MIN_CXX_STANDARD for pyt..."

Comment thread CMakeLists.txt
@mc-nv
mc-nv requested a review from yinggeh September 10, 2026 18:21

@mattwittwer mattwittwer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mc-nv
mc-nv merged commit 4809f7d into main Sep 11, 2026
2 checks passed
@mc-nv
mc-nv deleted the mchornyi/TRI-1877/TRI-1855-std-20 branch September 11, 2026 03:15
mc-nv added a commit that referenced this pull request Sep 11, 2026
* build: Update C++ standard from c++17 to c++20

Upstream PyTorch raised ATen's minimum required C++ standard from 17
to 20 (pytorch/pytorch#178150), which broke the pytorch_backend build.
Align this repo's TRITON_MIN_CXX_STANDARD/CMAKE_CXX_STANDARD default
with that floor for consistency across the stack.

TRI-1877

* fix: explicitly capture 'this' in backend_model.cc lambda

C++20 deprecates implicit capture of 'this' via a bare '[=]' default
capture (CWG2211); with -Werror=deprecated this now fails the build
after the C++17->20 bump. List 'this' explicitly alongside the
existing by-value default and '&instance_mu' reference capture.

TRI-1877

* fix: rename memory.h/.cc to avoid colliding with <memory>

Same class of bug just fixed in tensorrt_backend's semaphore.h and
filesystem.h: a project header sharing a name with a C++ standard
library header, combined with a project include directory preceding
the system include path, risks a future internal #include <memory>
from libstdc++ silently resolving to this project's own header. Not
currently triggering a build failure (core built successfully with
TRITON_MIN_CXX_STANDARD=20 in the observed CI runs), but renamed
proactively given the same repo family already proved this exact
pattern live once.

TRI-1877

* fix: update test/CMakeLists.txt reference after memory.cc rename

Missed in the prior memory.h/.cc -> triton_memory.h/.cc rename commit:
src/test/CMakeLists.txt lists ../memory.cc/../memory.h directly as
MEMORY_SRCS/MEMORY_HDRS (not via #include), which is a distinct
reference path my earlier sed pass over #include statements and
src/CMakeLists.txt didn't touch. Broke CMake configure with "Cannot
find source file: ../memory.cc" for response_cache_test.

TRI-1877

* fix: use TRITON_MIN_CXX_STANDARD for python-bindings instead of hardcoded cxx_std_17

(cherry picked from commit 4809f7d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build system or external dependencies (build: PRs) fix Bug fix (fix: PRs)

Development

Successfully merging this pull request may close these issues.

2 participants