Repository navigation
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/196070
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit a815231 with merge base 81deebd ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
…he check Human Notes: Bug fixes discovered as part of #190899 CI runs: * Cmake changes the TYPE of variables if inactive, and mark them `INTERNAL`, so we can't directly compare both type & value. Instead just check value. * cuteDSL `.compile` takes the current host CPU arch, which may not be compatible with all machines -- notable AVX512 was present on the builder, not on H100 runner, causing failures. Moved to a conservative arch. Claude: Two stage-2 defects that only bite once a declaration exists, so they land ahead of the first one (#190899). The exported objects targeted the BUILD machine's CPU. CuTeDSL compiles the host stubs in an export_to_c object for the native host unless cute.compile is given a --host-target, so a builder with AVX512 emits AVX512 module loaders and every launch of those kernels faults on a host without it. Reproduced by running the wheel the B200 build job produced on an AVX2-only box: SIGILL inside topk_radix_f32_n4096_k64_nondet__sm90a_cuda_load_to_device, and the H100 test job in #190899 fails with the same signature. Which instructions appear depends on the builder, so the same commit is portable or not depending on which runner took the job. The pin is the baseline aten itself targets: torch compiles general code for the compiler default and keeps AVX2 and AVX512 in runtime-dispatched capability copies (CPU_CAPABILITY_FLAGS in cmake/Codegen.cmake), which a kernel's module loader cannot do. It reaches only the host half of the object, so device SASS is unchanged and the JIT route cannot diverge from it; a declaration naming its own --host-target still wins. toolchains.py is inside the sidecars' source closure, so artifacts exported before this change re-export rather than keeping their host-specific loaders. Second, the reconfigure's cache comparison read an entry's TYPE as part of its value. cmake_dependent_option re-declares a settled option as CACHE INTERNAL on the second configure -- USE_XCCL:BOOL=OFF becomes USE_XCCL:INTERNAL=OFF -- so stage 2 refused its own reconfigure as configuration drift and failed the build. Only the value is compared now, which leaves the check's purpose intact: a changed value, or an entry EnvVarForwarding newly FORCEs, is still drift. Authored with an AI assistant (Claude Code). Test Plan: ``` pytest tools/test/test_native_aot_tools.py -k "pins_the_host_isa or retyped_by_the_reconfigure or RelinkNeverStrands" ``` Each new test was checked against the unfixed code: dropping the pin, letting it override a declaration's own, and putting the TYPE back into the compared value all fail it. The pin was also confirmed end to end -- objdump of a real exported object carries no ymm or zmm registers where it previously had 16 ymm references. ghstack-source-id: cfb568b Pull-Request: #196070
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
| Last assignment wins, as in _cmake_cache_value. The doc line names the source of an | ||
| entry EnvVarForwarding wrote ("From environment", "From env <NAME>"). | ||
|
|
||
| Value only, no TYPE: a reconfigure redeclares settled options as INTERNAL |
There was a problem hiding this comment.
I suspected this would be pretty fragile, and claude agrees. Using CMake file API (cache-v2) instead of string processing seems legit
Ignoring the type fixes the reported symptom, but I think it also opens a false
negative. When `cmake_dependent_option`'s condition goes unsatisfied it keeps the
old value in the cache as INTERNAL and shadows it with a normal variable set to
the force value. So `USE_XCCL:BOOL=ON` -> `USE_XCCL:INTERNAL=ON` means the build
just flipped to OFF, while a type-blind comparison sees `ON -> ON` and reports no
drift. The type change is the only signal there.
More generally, hand-parsing CMakeCache.txt for drift looks fragile past this
case. In a torch build cache ~40% of entries are INTERNAL bookkeeping
(`try_compile` results, `FIND_PACKAGE_MESSAGE_DETAILS_*`) that appear lazily;
`-D` args land as `UNINITIALIZED` until a later `set(... CACHE ...)` retypes
them; `caffe2_update_option` FORCE-rewrites values mid-configure; and `ON`/`1`/
`TRUE` compare unequal while meaning the same thing. The doc-line heuristic is
shaky too: CMake wraps helpstrings at ~60 chars and at newlines (90 wrapped runs
in my build's cache), so `doc` keeps only the trailing fragment, and
`set(... CACHE ...)` updates an existing entry's helpstring even without FORCE,
so the reconfigure can erase the `From environment` marker the check relies on.
A marker that stops matching fails open.
Would inverting the filter be simpler: compare only the entries EnvVarForwarding
wrote, with values normalized through CMake's truthiness rules? That's a handful
of names we control, rather than denylisting each churn pattern as it bites. If a
general cache read is needed, the CMake file API (`cache-v2`) hands back
name/type/value/helpstring as JSON with no format guessing.
There was a problem hiding this comment.
Yeah, definitely more fragile than one would like -- ended up only looking at the EnvVarForwarding'd variables, checking effective values (pretty much the "inverting the filter" suggestion). We no longer read CMakeCache.txt, so the file API doesn't end up being necessary.
| # the exported ABI; otherwise the two routes' SASS diverges. | ||
| opts = b.get("options") | ||
| host_target = self._HOST_TARGETS.get(platform.machine()) | ||
| if host_target and "--host-target" not in (opts or ""): |
There was a problem hiding this comment.
I think we should error if host_target is None (as there would be no cuteDSL wheels anyway), and I assume we error for windows somewhere earlier?
There was a problem hiding this comment.
Behavior fixed - empty --host-target now raises, and the argument being missing completely goes through the platform.machine() path, and raises if platform.machine() not in _HOST_TARGETS.
[ghstack-poisoned]
|
Starting merge as part of PR stack under #190899 |
2 similar comments
|
Starting merge as part of PR stack under #190899 |
|
Starting merge as part of PR stack under #190899 |
…e2e tests (#190899) Human Notes: Finally do a thing! Add `topk` as an AOT-provided override in libtorch_cuda. Claude: Declares a 48-point grid (fp32/bf16 x N{2048..16384} x K{64,128,256} x both determinism modes) over the radix-select kernel. The det specialization (stable prefix-sum gather + lex (ord, -idx) sort) is bit-exact vs aten including tie resolution, so det-mode calls are served AOT too; the dispatch chain keys on deterministicAlgorithms(). The kernel gains in_dtype and index_dtype compile parameters; the AOT route writes int64 indices directly (no widening copy). build(spec) lives beside the JIT wrappers, so both routes compile the same class. fp16 and off-grid shapes keep their JIT eligibility, as do calls the prelude declines: a non-last dim, largest/sorted false, sub-full-wave M, or a base pointer less aligned than the kernels were compiled for. ARCHS is stated rather than defaulted, and covers Hopper as well as Blackwell: measured on an H100, the AOT kernels beat aten on 48/48 of the grid, median 2.16x (min 1.26x at M=4096/N=2048, max 2.99x at M=256/N=4096 fp32). Both spellings of each capability are listed -- archs_from_cuda_arch_list maps 9.0 and 9.0a to different nvcc targets, and a wheel built with the plain list would otherwise export trees generation then filters out. CI: a native_aot test config (test.sh) asserts the wheel actually embeds the kernels -- a silently artifact-free wheel would make every routing test vacuously pass on the JIT/aten fallbacks -- then runs the python_native suites. One build+test pair per capability in native-aot.yml: cuda-arch-list 9.0a tested on linux.aws.h100 and 10.0a on linux.dgx.b200, both built on a GPU-less builder (path-triggered + nightly). test_uncovered_fp32_served_by_jit_layer skips below sm_100, since the JIT topk override is gated there while these AOT kernels are not. This lands with the first op so the AOT path is exercised in CI from this commit onward. Authored with an AI assistant (Claude Code). Test Plan: ``` .venv/bin/python test/python_native/test_native_aot.py # incl. det-mode routing + bit-exact-with-ties tests # (test_deterministic_mode_routes_to_aot_bit_exact, # test_deterministic_ties_bit_exact) .venv/bin/python test/python_native/test_topk_radix_kernel.py .venv/bin/python test/python_native/test_topk_cutedsl.py ``` On an H100, against the kernels a `spin develop` embedded: ``` .venv/bin/python test/python_native/test_native_aot.py # 11 tests, 1 skipped .venv/bin/python test/python_native/test_aot_manifest.py # 18 tests .venv/bin/python test/python_native/test_registry.py # 35 tests ``` Pull Request resolved: #190899 Approved by: https://github.com/MatthiasKohl, https://github.com/ngimel ghstack dependencies: #190898, #196070
Stack from ghstack (oldest at bottom):
Human Notes:
Bug fixes discovered as part of #190899 CI runs:
INTERNAL,so we can't directly compare both type & value. Instead just check value.
.compiletakes the current host CPU arch, which may not be compatiblewith all machines -- notable AVX512 was present on the builder, not on H100 runner,
causing failures. Moved to a conservative arch.
Claude:
Two stage-2 defects that only bite once a declaration exists, so they land ahead
of the first one (#190899).
The exported objects targeted the BUILD machine's CPU. CuTeDSL compiles the host
stubs in an export_to_c object for the native host unless cute.compile is given a
--host-target, so a builder with AVX512 emits AVX512 module loaders and every
launch of those kernels faults on a host without it. Reproduced by running the
wheel the B200 build job produced on an AVX2-only box: SIGILL inside
topk_radix_f32_n4096_k64_nondet__sm90a_cuda_load_to_device, and the H100 test job
in #190899 fails with the same signature. Which instructions appear depends on
the builder, so the same commit is portable or not depending on which runner took
the job.
The pin is the baseline aten itself targets: torch compiles general code for the
compiler default and keeps AVX2 and AVX512 in runtime-dispatched capability
copies (CPU_CAPABILITY_FLAGS in cmake/Codegen.cmake), which a kernel's module
loader cannot do. It reaches only the host half of the object, so device SASS is
unchanged and the JIT route cannot diverge from it; a declaration naming its own
--host-target still wins. toolchains.py is inside the sidecars' source closure,
so artifacts exported before this change re-export rather than keeping their
host-specific loaders.
Second, the reconfigure's cache comparison read an entry's TYPE as part of its
value. cmake_dependent_option re-declares a settled option as CACHE INTERNAL on
the second configure -- USE_XCCL:BOOL=OFF becomes USE_XCCL:INTERNAL=OFF -- so
stage 2 refused its own reconfigure as configuration drift and failed the build.
Only the value is compared now, which leaves the check's purpose intact: a
changed value, or an entry EnvVarForwarding newly FORCEs, is still drift.
Authored with an AI assistant (Claude Code).
Test Plan:
Each new test was checked against the unfixed code: dropping the pin, letting it
override a declaration's own, and putting the TYPE back into the compared value
all fail it. The pin was also confirmed end to end -- objdump of a real exported
object carries no ymm or zmm registers where it previously had 16 ymm
references.