Skip to content

Comments

Diff engine param#147

Draft
Transurgeon wants to merge 25 commits intomasterfrom
diff-engine-param
Draft

Diff engine param#147
Transurgeon wants to merge 25 commits intomasterfrom
diff-engine-param

Conversation

@Transurgeon
Copy link
Member

Description

Please include a short summary of the change.
Issue link (if applicable):

Type of change

  • New feature (backwards compatible)
  • New feature (breaking API changes)
  • Bug fix
  • Other (Documentation, CI, ...)

Contribution checklist

  • Add our license to new files.
  • Check that your code adheres to our coding style.
  • Write unittests.
  • Run the unittests and check that they’re passing.
  • Run the benchmarks to make sure your change doesn’t introduce a regression.

Transurgeon and others added 23 commits February 9, 2026 01:27
Add get_param_offsets static method to InverseData and use it in
build_parameter_dict to compute parameter offsets. Register parameter
nodes (parameter, param_scalar_mult, param_vector_mult, left_param_matmul)
with the C problem and support updating parameter values without
rebuilding the expression tree.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces DiffEngineParamConeProg, which replaces the tensor-based
ParamConeProg with a C expression tree that evaluates A, b, q, d (and P
for QPs) via the diff engine's automatic differentiation. Uses the
evaluate-at-zero trick: since all expressions are affine in x after
DCP2Cone, the Jacobian gives A and the gradient gives q directly.

Also adds SymbolicQuadForm and DivExpression converters to the diff
engine, updates ConicSolver/QpSolver to accept the new program type,
and includes comprehensive comparison tests against the SCIPY backend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve canon_backend=None to DEFAULT_CANON_BACKEND in
construct_solving_chain so that changing the default actually
propagates through all code paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DIFF_ENGINE doesn't yet support all atoms, so keep CPP as default.
The matrix_stuffing benchmarks now use ASV parameterized benchmarks
to compare both backends side-by-side.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
n_params was only used for a size validation check and can be computed
from n_param_nodes + each node's size. This simplifies the API by
removing one argument from problem_register_params and one field to
maintain.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The dimensions are now read directly from param_node->d1/d2 inside the
C implementation, so the Python binding and caller no longer need to
pass them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Precompute total parameter size when parameters are registered instead
of recomputing it on every update_params call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document why these use generic make_index rather than custom C nodes:
hot-path cost is dominated by Jacobian memcpy, not index lookup, and
the Hessian sparsity limitation is identical either way.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts:
#	CLAUDE.md
#	cvxpy/reductions/solvers/nlp_solvers/diff_engine/_bindings/bindings.c
#	cvxpy/reductions/solvers/solving_chain.py
#	diff_engine_core
The import used `import _diffengine` directly, which isn't available.
Updated to `from sparsediffpy import _sparsediffengine as _diffengine`
to match the rest of the codebase.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Inherit from ParamProb so DiffEngineParamConeProg is no longer a
duck-typed stand-in: move split_solution to the base class, simplify
isinstance checks to use ParamProb, deduplicate format_constraints by
delegating to _build_restruct_operator, and fix PowConeND ndim==1 bug
in the shared operator builder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…aths

Update _convert_matmul to use the unified make_left_matmul binding which
accepts (param_or_none, child, csr_data, csr_indices, csr_indptr, m, n).
For updatable parameters, build a dense CSR so all entries can change
between solves via refresh_param_values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use value_sparse.toarray() for parameters with sparse_idx to avoid
the deprecation warning from .value on sparse CVXPY expressions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace _has_parameters helper with direct isinstance(arg, cp.Parameter)
checks. Use value_sparse for sparse parameters to avoid deprecation
warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Transurgeon Transurgeon marked this pull request as draft February 17, 2026 21:23
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