feat!: [codex] support polymorphic handles and configs - #917
Draft
voltjia wants to merge 1 commit into
Draft
Conversation
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
ConfigandHandlepolymorphic through virtualClone()contracts and final-class CRTP helpers.Configclone while borrowing the per-callHandlethrough an RAII scope, so cache hits do not clone or allocate.Motivation
Operator-specific options currently have to be added to the shared
src/config.h, and assigning a derivedConfigorHandletoOperatorBaseslices its dynamic state. This change provides an extensible foundation so an operator can own its configuration type without expanding the shared base for every feature.This PR is deliberately independent of #800 and contains no Triton/JIT changes.
Type of Change
feat- new extensibility APIfix- bug fixperf- performance improvement (no behavioral change)refactor- code restructuring without behavior changetest- focused C++ API coveragedocs- documentation onlybuild/ci- build system or CI configurationchore- tooling, formatting, or other non-code changes!in the Conventional Commits prefix or aBREAKING CHANGE:footer)Platforms Affected
The shared dispatch and public C++ types are used by every backend.
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Validated from commit
f9a26ee6c95dc408d2cf9897d972149947c95420inaccelerator-dev/nvidia:latest, using the CPU backend and InfiniRT master96e0613421f88e90959656764639c8a3282cb318:Test Results on Supported Platforms
Additional C++ API test output
Benchmark / Performance Impact
N/A - this is not a performance PR.
A cache hit does not call
Clone()and does not allocate. Relative to the current key construction, it adds dynamic-type hashing, one virtualcache_fingerprint()call, and hash combines. A cache miss or explicitMake()adds one allocation/copy for the ownedConfig. Normal invocation borrows theHandle; only the explicit owningset_handle()API clones it.Notes for Reviewers
ConfigandHandlegain virtual tables, andOperatorBasechanges layout and copy/move semantics. Downstream C++ consumers and plugins must rebuild.CloneableConfig<T>orCloneableHandle<T>and befinal. Clone validation rejects dynamic-type or observable-base-state loss.Config::CacheFingerprint()must be stable and include every derived field that affects construction or invocation. Dynamic type and implementation index are included separately.config(), preventing stale construction references.Call()appends config identity even when a customCacheKeyBuilderomits it; specialized sampling builders use the shared helper as well.