Skip to content

fix: preserve implementation lookups under optimization - #929

Open
voltjia wants to merge 1 commit into
masterfrom
fix/optimized-active-query
Open

fix: preserve implementation lookups under optimization#929
voltjia wants to merge 1 commit into
masterfrom
fix/optimized-active-query

Conversation

@voltjia

@voltjia voltjia commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • This PR emits explicit specializations for generated active implementation queries and default implementation lookups.
  • This PR keeps the generic header-only lookup path available for operators that are not part of the generated installed API.
  • This PR compiles the installed Add C++ smoke consumer with optimization enabled to cover both query and configless call paths.

Motivation

The explicit instantiations added in #924 do not prevent a compiler from inlining the class-body definitions in an optimized downstream translation unit. Because downstream code does not include backend implementation headers, an optimized consumer can incorrectly observe an empty implementation list and select no default implementation even though the installed library contains the implementations.

Type of Change

  • feat - new feature / new operator / new platform
  • fix - bug fix
  • perf - performance improvement (no behavioral change)
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

CPU Release library build passed.
Installed CPU C++ consumer compiled with -O3 and executed Add query, explicit-config Call, and configless Call successfully.
Installed CPU -O3 query consumer reported Add: 0, Gemm: 0, Mul: 0, Relu: 0, RmsNorm: 0, and Silu: 0.
NVIDIA Release library build passed with the generated specialization source compiled by NVCC.
Installed NVIDIA -O3 query consumer reported Add: 0, Gemm: 0 1, Mul: 0, Relu: 0, RmsNorm: 0, and Silu: 0.

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU Yes Passed The 26 wrapper generator tests and the focused installed C++ API regression passed.
NVIDIA Yes Passed The NVIDIA library and installed optimized query consumer passed on an NVIDIA A100.
Iluvatar Yes Not run Hardware is unavailable in the current environment. Standard CI validation is required.
MetaX Yes Not run Hardware is unavailable in the current environment. Standard CI validation is required.
Cambricon Yes Not run Hardware is unavailable in the current environment. Standard CI validation is required.
Moore Yes Not run Hardware is unavailable in the current environment. Standard CI validation is required.
Ascend Yes Not run Hardware is unavailable in the current environment. Standard CI validation is required.
Full `pytest` output.
Running 26 items in this shard
..........................                                               [100%]
26 passed in 0.26s

Running 1 items in this shard
.                                                                        [100%]
1 passed, 6 deselected in 1.20s

Benchmark / Performance Impact

N/A. This PR changes where generated implementation lookup code is instantiated and does not change operator execution paths.

Notes for Reviewers

Please focus on the explicit specialization declarations in the installed generated header and their definitions in the generated library source. The generic helper templates intentionally remain in operator.h so non-generated custom operators preserve the existing header-only behavior.

@voltjia
voltjia requested a review from a team August 13, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant