Skip to content

[dynamo] Preserve wrapper dispatch for bound classmethods - #12

Merged
cyyever merged 1 commit into
trimfrom
fix/dynamo-cached-classmethod
Oct 30, 2026
Merged

cyyever merged 1 commit into
trimfrom
fix/dynamo-cached-classmethod

Conversation

@cyyever

@cyyever cyyever commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Linked issue or supporting maintainer

Requested by the fork owner for trim.

BC-breaking?

No.

Summary (human written only)

User request:

also add pr to Dynamo fix to trim

Agent details (AI-generated)

Compiling an inherited @classmethod wrapped in functools.cache raises InternalTorchDynamoError: NotImplementedError in WrapperUserFunctionVariable.has_self. This blocks vLLM's CUDA platform capability query during DeepSeek-V4 compilation.

UserMethodVariable now delegates wrapped calls to the wrapper's own call_function, prepending the bound class. This preserves cache tracing and nested torch.compile(fullgraph=True) policy. The change adds regressions for inherited cached classmethods and nested fullgraph enforcement.

Validation:

  • The cached-classmethod regression fails before the patch.
  • Both new tests and two neighboring wrapper tests pass with Inductor available, using an isolated Python overlay of the installed CUDA wheel.
  • The real vLLM CUDA platform query compiles on an RTX PRO 5000 sandbox.
  • git diff --check passes. lintrunner -a ran; targeted checking reports only the existing B911 advisory at test/dynamo/test_functions.py:809. The initial broad invocation also lacked actionlint; the existing tool directory was linked for the targeted rerun. Its unrelated automatic workflow edit was discarded.

The DeepSeek dummy-weight probe passes the original failure and then fails later in the Triton warmup helper. Full DeepSeek inference with mandatory compilation has not passed yet.

Classmethod binding can wrap a WrapperUserFunctionVariable in
UserMethodVariable. Inlining that method as a plain function invokes
has_self on the wrapper, which has no ordinary inlining implementation.
Delegate wrapped calls with the bound class prepended so cache tracing and
nested fullgraph policy remain intact.

Test Plan:
Four Dynamo function tests passed using the installed CUDA wheel with an
isolated Python overlay; the new cached-classmethod regression fails
before the patch. The real vLLM CUDA platform query compiles successfully.
lintrunner -a was run; a pre-existing B911 advisory remains at line 809 of
test_functions.py. git diff --check passes.
@cyyever
cyyever marked this pull request as ready for review October 30, 2026 09:56
@cyyever
cyyever merged commit a0a8a55 into trim Oct 30, 2026
16 checks passed
cyyever added a commit that referenced this pull request Oct 31, 2026
Classmethod binding can wrap a WrapperUserFunctionVariable in
UserMethodVariable. Inlining that method as a plain function invokes
has_self on the wrapper, which has no ordinary inlining implementation.
Delegate wrapped calls with the bound class prepended so cache tracing and
nested fullgraph policy remain intact.

Test Plan:
Four Dynamo function tests passed using the installed CUDA wheel with an
isolated Python overlay; the new cached-classmethod regression fails
before the patch. The real vLLM CUDA platform query compiles successfully.
lintrunner -a was run; a pre-existing B911 advisory remains at line 809 of
test_functions.py. git diff --check passes.
cyyever added a commit that referenced this pull request Oct 31, 2026
Classmethod binding can wrap a WrapperUserFunctionVariable in
UserMethodVariable. Inlining that method as a plain function invokes
has_self on the wrapper, which has no ordinary inlining implementation.
Delegate wrapped calls with the bound class prepended so cache tracing and
nested fullgraph policy remain intact.

Test Plan:
Four Dynamo function tests passed using the installed CUDA wheel with an
isolated Python overlay; the new cached-classmethod regression fails
before the patch. The real vLLM CUDA platform query compiles successfully.
lintrunner -a was run; a pre-existing B911 advisory remains at line 809 of
test_functions.py. git diff --check passes.
cyyever added a commit that referenced this pull request Oct 31, 2026
Classmethod binding can wrap a WrapperUserFunctionVariable in
UserMethodVariable. Inlining that method as a plain function invokes
has_self on the wrapper, which has no ordinary inlining implementation.
Delegate wrapped calls with the bound class prepended so cache tracing and
nested fullgraph policy remain intact.

Test Plan:
Four Dynamo function tests passed using the installed CUDA wheel with an
isolated Python overlay; the new cached-classmethod regression fails
before the patch. The real vLLM CUDA platform query compiles successfully.
lintrunner -a was run; a pre-existing B911 advisory remains at line 809 of
test_functions.py. git diff --check passes.
cyyever added a commit that referenced this pull request Oct 31, 2026
Classmethod binding can wrap a WrapperUserFunctionVariable in
UserMethodVariable. Inlining that method as a plain function invokes
has_self on the wrapper, which has no ordinary inlining implementation.
Delegate wrapped calls with the bound class prepended so cache tracing and
nested fullgraph policy remain intact.

Test Plan:
Four Dynamo function tests passed using the installed CUDA wheel with an
isolated Python overlay; the new cached-classmethod regression fails
before the patch. The real vLLM CUDA platform query compiles successfully.
lintrunner -a was run; a pre-existing B911 advisory remains at line 809 of
test_functions.py. git diff --check passes.
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