Skip to content

Commit ea8bc18

Browse files
scottsmeta-codesync[bot]
authored andcommitted
Remove LIBKINETO_NO* compatibility shim (pytorch#1399)
Summary: The CMake refactor (pytorch#1388) replaced `LIBKINETO_NOCUPTI`, `LIBKINETO_NOROCTRACER`, and `LIBKINETO_NOXPUPTI` with a single `KINETO_BACKEND` variable, but kept a shim that translated the legacy flags during the cross-repo migration window. pytorch/pytorch#183388 migrated PyTorch's `cmake/Dependencies.cmake` and `torch/csrc/autograd/init.cpp` have now both been migrated to use `KINETO_BACKEND` / `HAS_*` directly. The shim has no remaining caller. **Approach** Delete the shim block and the cached-vs-new-legacy-flags conflict warning that existed only to ease the migration. Replace with a simpler guard that warns when `KINETO_BACKEND` wasn't set at all and the build defaulted to `cpu`. This catches stragglers passing legacy `LIBKINETO_NO*` flags as a side effect — they'll be silently ignored, `KINETO_BACKEND` will default to `cpu`, and the new warning will tell them how to pick a backend explicitly. The new code carries no knowledge of the legacy flag names, so the kineto repo is now free of all `LIBKINETO_NO*` references. The warning fires only on initial configure (subsequent re-runs find `KINETO_BACKEND` populated in the cache) and on a freshly-wiped build directory. Pull Request resolved: pytorch#1399 Reviewed By: NicolasHug Differential Revision: D104927633 Pulled By: scotts fbshipit-source-id: 71e5f4103d77e4550bf74c5bed22c9808c8a6f5b
1 parent 77e2b46 commit ea8bc18

1 file changed

Lines changed: 9 additions & 32 deletions

File tree

libkineto/CMakeLists.txt

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,11 @@ endif()
5555
# Selection is explicit: if the chosen toolkit isn't available, configuration
5656
# fails. Use KINETO_BACKEND=cpu to build without GPU support.
5757

58-
# Backwards-compat shim: derive KINETO_BACKEND from legacy LIBKINETO_NO* flags
59-
# when the user hasn't set KINETO_BACKEND directly.
60-
# TODO: remove after PyTorch migrates to KINETO_BACKEND.
58+
# Track whether the user explicitly set KINETO_BACKEND before the default
59+
# fires below, so we can warn when we fall back to cpu.
60+
set(_kineto_backend_explicit ON)
6161
if(NOT DEFINED CACHE{KINETO_BACKEND} AND NOT DEFINED KINETO_BACKEND)
62-
if(DEFINED LIBKINETO_NOROCTRACER AND NOT LIBKINETO_NOROCTRACER)
63-
set(KINETO_BACKEND "rocm" CACHE STRING "")
64-
elseif(DEFINED LIBKINETO_NOCUPTI AND NOT LIBKINETO_NOCUPTI)
65-
set(KINETO_BACKEND "cuda" CACHE STRING "")
66-
elseif(DEFINED LIBKINETO_NOXPUPTI AND NOT LIBKINETO_NOXPUPTI)
67-
set(KINETO_BACKEND "xpu" CACHE STRING "")
68-
endif()
62+
set(_kineto_backend_explicit OFF)
6963
endif()
7064

7165
set(KINETO_BACKEND "cpu" CACHE STRING
@@ -81,29 +75,12 @@ endif()
8175
unset(_KINETO_BACKEND_VALID)
8276
message(STATUS "KINETO_BACKEND = ${KINETO_BACKEND}")
8377

84-
# Warn if legacy LIBKINETO_NO* flags disagree with the cached KINETO_BACKEND.
85-
# The shim only fires on initial configure; once KINETO_BACKEND is in the
86-
# cache, subsequent legacy-flag changes are silently ignored. Detect that and
87-
# tell the user. TODO: remove with the rest of the legacy shim.
88-
if(DEFINED LIBKINETO_NOCUPTI OR DEFINED LIBKINETO_NOROCTRACER OR DEFINED LIBKINETO_NOXPUPTI)
89-
if(DEFINED LIBKINETO_NOROCTRACER AND NOT LIBKINETO_NOROCTRACER)
90-
set(_legacy_implied_backend "rocm")
91-
elseif(DEFINED LIBKINETO_NOCUPTI AND NOT LIBKINETO_NOCUPTI)
92-
set(_legacy_implied_backend "cuda")
93-
elseif(DEFINED LIBKINETO_NOXPUPTI AND NOT LIBKINETO_NOXPUPTI)
94-
set(_legacy_implied_backend "xpu")
95-
else()
96-
set(_legacy_implied_backend "cpu")
97-
endif()
98-
if(NOT KINETO_BACKEND STREQUAL _legacy_implied_backend)
99-
message(WARNING
100-
"Legacy LIBKINETO_NO* flags imply KINETO_BACKEND=${_legacy_implied_backend} "
101-
"but KINETO_BACKEND=${KINETO_BACKEND} (cached from a previous configure). "
102-
"Legacy flags are ignored. Pass -DKINETO_BACKEND=${_legacy_implied_backend} "
103-
"explicitly or remove the build directory to switch backends.")
104-
endif()
105-
unset(_legacy_implied_backend)
78+
if(NOT _kineto_backend_explicit)
79+
message(WARNING
80+
"KINETO_BACKEND was not set; defaulting to 'cpu'. "
81+
"Pass -DKINETO_BACKEND={cpu,cuda,rocm,xpu} explicitly to silence this warning.")
10682
endif()
83+
unset(_kineto_backend_explicit)
10784

10885
# Per-backend configure-time setup.
10986
if(KINETO_BACKEND STREQUAL "cuda")

0 commit comments

Comments
 (0)