Skip to content

functional: add value_and_grad and auxiliary value/grad args#52

Closed
Pavlo3P wants to merge 1 commit into
masterfrom
50-improve-functional-class
Closed

functional: add value_and_grad and auxiliary value/grad args#52
Pavlo3P wants to merge 1 commit into
masterfrom
50-improve-functional-class

Conversation

@Pavlo3P

@Pavlo3P Pavlo3P commented Jul 1, 2026

Copy link
Copy Markdown
Owner

What this PR does

Widen Functional.value/grad to accept *args/**kwargs (auxiliary parameters such as data, temperature, or a penalty weight) and add value_and_grad with a base default that delegates to value + grad, so subclasses can override with a single-pass evaluator. Extras are threaded through call and the check-free cores; checked_method already forwards them and validates only x.

Checklist

  • Tests pass (pytest tests/ -x -q)
  • Docstring added or updated, if public behavior changed
  • CHANGELOG entry added under [Unreleased]
  • If this PR touches geometry, adjoints, spectral methods, scalar fields, or batching: describe the mathematical invariant being preserved or added below.

Widen Functional.value/grad to accept *args/**kwargs (auxiliary parameters
such as data, temperature, or a penalty weight) and add value_and_grad with
a base default that delegates to value + grad, so subclasses can override
with a single-pass evaluator. Extras are threaded through __call__ and the
check-free cores; checked_method already forwards them and validates only x.

Groundwork for the 0.4.2 optimizer-loop work (fused value_and_grad) and
TraceFunctional.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Pavlo3P Pavlo3P linked an issue Jul 1, 2026 that may be closed by this pull request
@Pavlo3P Pavlo3P closed this Jul 1, 2026
@Pavlo3P Pavlo3P deleted the 50-improve-functional-class branch July 1, 2026 05:30
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.

Improve Functional class

1 participant