Skip to content

Fix @grad for qualified function names - #330

Closed
gezerui888 wants to merge 1 commit into
JuliaDiff:masterfrom
gezerui888:fix/qualified-grad-names
Closed

gezerui888 wants to merge 1 commit into
JuliaDiff:masterfrom
gezerui888:fix/qualified-grad-names

Conversation

@gezerui888

Copy link
Copy Markdown

Fixes #318.

Qualified definitions such as @grad function M.f(x) fail with gensym(::Expr). I changed the generated closure name to use a symbol prefix, while preserving the qualified callee for dispatch and tape recording.

The regression checks qualified and unqualified rules through direct gradients and ordinary/compiled tape replay, including primal values after inputs change.

Validation:

  • Julia 1.13.1 full suite: 12,611 passed, 9 expected broken checks.
  • Julia 1.10.13 macro, ChainRules, and gradient tests: 1,117 passed.
  • Runic formatting check passed.

cc @devmotion

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.32%. Comparing base (608569b) to head (e95e568).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #330   +/-   ##
=======================================
  Coverage   94.32%   94.32%           
=======================================
  Files          19       19           
  Lines        1710     1710           
=======================================
  Hits         1613     1613           
  Misses         97       97           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@devmotion

Copy link
Copy Markdown
Member

Thank you for the PR! However, I think it's better to let standard Julia macro hygiene do its job, as for @grad_from_chainrules in #328. I fixed the issue in an analogous way in #331.

@devmotion devmotion closed this Nov 10, 2026
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.

@grad fails for qualified function names (gensym(::Expr))

2 participants