Add xDiT kernel source mapping support - #1154
Open
kyle-hoffmeyer wants to merge 14 commits into
Open
Conversation
kyle-hoffmeyer
force-pushed
the
khoffmey/feat/op_source_mapping_enhancements
branch
from
August 11, 2026 20:21
37b4013 to
c9b4fff
Compare
…n kernels - Replace c++filt subprocess with itanium-demangler Python package for reliable demangling of deeply-nested CK template symbols - Fix base_symbol() returning "void" for (anonymous namespace):: kernels by delegating to _demangle_kernel_name() - Add non-patchable classification for Tensile (Cijk_*) and MIOpen (igemm_*, batched_transpose_*, Im2d2Col*, SubTensorOpWithScalar*) - Tighten CK guard to `if demangled and demangled != raw:` so mangled regex fallback fires when demangling returns input unchanged - Expand scan paths: add .hpp to native extensions, remove /3rdparty/ skip from repo scan, add 3rdparty/composable_kernel/include to _CSRC_DIRS for CK kernel discovery Tested against 9 workloads (xDiT, vLLM, SGLang) across 3 containers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kyle-hoffmeyer
force-pushed
the
khoffmey/feat/op_source_mapping_enhancements
branch
from
August 14, 2026 17:51
710d39a to
d860f3a
Compare
Remove vllm from _repo_scan_roots() and revert tier 3 ranking logic back to original ambiguity-refusal behavior. These changes are for vLLM/SGLang workloads and not needed for the xDiT focus of this branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `if demangled and demangled != raw` guard is not needed when using itanium-demangler, which returns "" on failure (falsy). The original `if demangled:` guard works correctly with the new demangler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove 3rdparty/composable_kernel/include from _CSRC_DIRS, restore /3rdparty/ to _SCAN_SKIP_MARKERS, and remove .hpp from native extension lists. These changes only affect CK kernels which are classified as aiter_ck (non_patchable) before any index lookup — the indexed source is never returned. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI E2E report — ✅ Succeeded
|
kyle-hoffmeyer
marked this pull request as ready for review
August 17, 2026 21:34
kyle-hoffmeyer
requested review from
a team,
Ahmedhasssan-aig,
devalshahamd and
tsrikris
as code owners
August 17, 2026 21:34
kyle-hoffmeyer
marked this pull request as draft
August 17, 2026 21:35
kyle-hoffmeyer
marked this pull request as ready for review
August 17, 2026 22:11
kyle-hoffmeyer
marked this pull request as draft
August 17, 2026 22:16
Collaborator
Author
|
I'm not sure if I added the itanium-demangler dependency correctly. Please take a look. |
kyle-hoffmeyer
marked this pull request as ready for review
August 18, 2026 23:11
Collaborator
|
Can you please try to pass all the CI tests? |
| def _cxxfilt_base(mangled: str) -> str: | ||
| """Demangle via ``c++filt`` when available (``""`` on failure). | ||
| def _demangle_itanium(mangled: str) -> str: | ||
| """Demangle an Itanium-mangled symbol via ``itanium-demangler``. |
Collaborator
There was a problem hiding this comment.
Can we keep the _cxxfilt_base (to use it as fallback) if itanium is not installed or missing for any reason?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for kernel source mapping for xDiT diffusion workloads. Each fix addresses a specific failure observed during source resolution of device kernels in these traces.
Change 1: Replace
c++filtwithitanium-demanglerFile:
source_resolver.py—_demangle_itanium()replacing_cxxfilt_base()Problem:
c++filtis the tool used to demangle kernel names. An example of a mangled kernel name:These kernel names are very difficult to parse but can be demangled to more easily parse.
c++filt(GNU Binutils) fails on xDiT workloads due to deeply nested CK convolution kernel symbols (~20+ levels of template nesting, 1575+ characters). When demangling fails,c++filtreturns the input string unchanged — an ambiguous failure signal that causes_non_patchable_kind()to misclassify CK kernels as patchable.itanium-demanglerhandles deeper nesting (no hardcoded recursion limits) and returns""on failure (unambiguous). This makes the existingif demangled:guard in_non_patchable_kind()work correctly —""is falsy, so the mangled regex fallback fires and CK kernels are correctly classified asaiter_ck.xDiT example:
aten::miopen_convolutiondispatches to CK grouped convolution:14 CK convolution kernels across 4 xDiT traces are affected.
Comparison:
c++filt(GNU Binutils)itanium-demangler(Python)""(clear)shutil,subprocessImportErrorfallback)Change 2: Fix
_base_from_demangled()for(anonymous namespace)::kernelsFile:
source_resolver.py—_base_from_demangled()Problem:
_base_from_demangled()is the function used to parse a demangled kernel name._base_from_demangled()usedre.split(r"[(<]", ...)to extract the kernel name. For signatures containing(anonymous namespace), the(in the namespace qualifier was matched first, truncating the name to"void".Fix: Rewrite
_base_from_demangled()to match the logic in_bypass_source_resolver._demangle_kernel_name(), which already handles this case correctly. Both functions now use the same approach for extracting the bare function identifier: stripvoidprefix, strip(anonymous namespace)::, then remove template/function args. Ideally this shared logic would live in a common utility function, but that belongs to a broader cleanup PR.Change 3: Add Tensile and MIOpen non-patchable classification
File:
source_resolver.py—_non_patchable_kind()Problem: Tensile GEMM kernels (
Cijk_*) and MIOpen convolution kernels were reported as"unresolved"with no explanation. These kernels are written in GPU assembly and shipped pre-compiled — no source code exists.Fix:
_non_patchable_kind()now accepts anop_nameparameter. Tensile is identified by device kernel name prefix (Cijk_*). MIOpen is identified by op name ("miopen" in op_name) rather than device kernel name patterns, which vary across MIOpen versions (e.g.,igemm_*,batched_transpose_*,Im2d2Col,Im3d2Col,SubTensorOpWithScalar*). Using the op name catches all MIOpen kernels regardless of the device kernel naming convention.xDiT examples:
Tensile GEMMs (~37% of xDiT device kernels):
MIOpen convolutions (all caught via op name
aten::miopen_convolution):These are now reported as
"non_patchable"with a reason string instead of bare"unresolved".Change 4: Mark Inductor-generated Triton kernels as non-patchable
File:
_bypass_source_resolver.py—resolve_triton_py()File:
_bypass_report.pyProblem:
torch.compileInductor-generated Triton kernels are not patchable as the source for them is generated at compile time within Inductor. These kernels were previously reported as"unresolved"fromresolve_triton_py. Tier 1 correctly identified them as non-editable (viatorchinductorin thekernel_filepath), but returned"unresolved"instead of"non_patchable", causing tiers 2 and 3 to run unnecessarily.Fix: When
resolve_triton_py()has akernel_filepath buteditable_trace_source()rejects it, return"non_patchable"instead of"unresolved". The framework scan/repo scan gates in_bypass_report.pynow usesource_method == "unresolved", so only genuinely unresolved kernels fall through to tiers 2 and 3.xDiT example: Inductor-generated Triton kernels:
Verification
Tested via the full pipeline (
analyze_trace(top_k=0)→build_candidates(top_k=0)) intracelens-xdit:v26.7(TraceLens patched xDiT image) against 4 xDiT diffusion workloads. Traces can be found in xDiT folders in https://github.com/AMD-AGI/TraceLens/tree/main/tests/traces/inference.Cijk_*)unresolvednon_patchable(tensile_precompiled)igemm_*)unresolvednon_patchable(miopen_precompiled)batched_transpose_*)unresolvednon_patchable(miopen_precompiled)_ZN2ck...)unresolved(c++filt failed silently)non_patchable(aiter_ck)triton_poi_*)unresolved(framework + repo scan wasted)non_patchable(framework + repo scan skipped)unresolved(_base_from_demangledreturned"void")resolved→groupnorm.curesolvedresolved(unchanged)New dependency
itanium-demangler(pip package, pure Python, no system deps). Added topyproject.tomlruntimeoptional dependencies. When not installed, a warning is logged ("itanium-demangler is not installed. Kernel classification may be degraded.") and demangling falls back to the mangled regex path.