Repository navigation
fix(kernels): a per-format capture refinement may only narrow SUPPORTS_GRAPH_CAPTURE (#5014) - #5045
Merged
Merged
Conversation
…S_GRAPH_CAPTURE (#5014) ``graph_capture_safe()`` consulted an instance's ``supports_graph_capture()`` hook before looking at the class declaration, so a kernel that declares ``SUPPORTS_GRAPH_CAPTURE = False`` but inherits ``GGUFTorchLinear``'s per-format hook (``GGUFCppKernel``, ``GGUFCudaKernel``) was reported capturable whenever its format happened to be in ``GRAPH_CAPTURE_QTYPES``. The hook is a refinement of the declaration, not an override of it: it may narrow ``True`` per runtime format, never widen a ``False``. ``graph_capture_safe()`` now reads the declaration first and only asks the instance when that declaration is ``True``. ``GGUFTorchLinear``'s own hook applies the same rule, so ``GGUFTorchLinear.supports_graph_capture()`` also answers ``False`` on a subclass that turned the claim off. No runtime format changes: Q2_K/Q3_K still narrow to ``False`` and Q4_K/Q5_K/Q6_K stay capturable. Follow-up to #5014 / #5035. The test node fails on unmodified main (the helper answers ``True`` for a subclass that declares ``False``) and passes here; the other 19 nodes of the file are unchanged.
Qubitium
force-pushed
the
root/gguf-kquant-graph-5014
branch
from
November 18, 2026 00:14
3b3a2a2 to
d8f398e
Compare
7 tasks done
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
graph_capture_safe()asked an instance'ssupports_graph_capture()hook before reading the class declaration. For a kernel that declaresSUPPORTS_GRAPH_CAPTURE = Falsebut inheritsGGUFTorchLinear's per-format hook (GGUFCppKernel,GGUFCudaKernel), the hook answered for the format and the helper reported the kernel capturable. The refinement is only allowed to narrow the declaration, never widen it.graph_capture_safe()readsSUPPORTS_GRAPH_CAPTUREfirst and consults the instance hook only when the declaration isTrue.GGUFTorchLinear.supports_graph_capture()returnsFalsewhen the concrete class turned the claim off.False, Q4_K/Q5_K/Q6_K stay capturable.Follow-up hardening to #5014 (landed in #5035); the merged fix is untouched.
Test
tests/kernels/test_gguf_kquant_graph_capture_5014.py::test_instance_refinement_cannot_widen_a_subclass_declarationorigin/main(0783ccdbc, test copied into a separate worktree): 1 failed, 19 passed — the helper answersTruefor a subclass that declaresFalse.The new node uses
__new__to build a real instance of a subclass that declaresFalse(so it exercises the inherited hook without theSUPPORTS_*registration check) and a duck-typed instance whose hook would widen the claim.Checklist
mainruff checkclean on the three touched filesTrue