Open
Conversation
Enable CVXPY Parameters as live nodes in the C expression tree, so parameter values can be updated via memcpy without rebuilding the tree. This is critical for parametric NLP problems (MPC, portfolio optimization). Changes: - inverse_data.py: add get_param_offsets() static method - converters.py: add build_parameter_dict(), _normalize_shape() helper, Parameter branches in matmul/multiply converters, param_dict threading through convert_expr/convert_expressions (now returns 4-tuple) - c_problem.py: use convert_expressions(), register params with C problem, add update_params() method for fast parameter value refresh Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The refactor in 33fe669 lost the inline code that copied initial values from dimension-reduced variables (diag, sparse, symmetric) to their reduced counterparts. This caused NLP solvers to find value=None on the reduced variable, breaking initialization. Mirror the existing parameter value-propagation pattern by calling lower_value(var) after creating the reduced variable. Also fix lower_value to handle sparse diagonal matrices by using .diagonal() instead of np.diag(), which does not accept sparse inputs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Benchmarks that have improved:
Benchmarks that have stayed the same: |
Detect the reshape(sparse_coeff @ reduced_param, shape, 'F') @ x pattern produced by CvxAttr2Constr for sparse parameters and fuse it into a single make_left_matmul/make_right_matmul with native CSR sparsity, instead of two separate matmuls. Values in update_params are converted to CSR order via COO→CSR for fused sparse parameters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test scalar, vector, dense matrix, and sparse matrix parameter multiplication with derivative checking and parameter value updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parameters are always registered via build_parameter_dict, so the fallthrough path that created them as make_constant was dead code. Replace with an explicit error if a parameter is missing from param_dict. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dance858
reviewed
Feb 18, 2026
| # Recursive case: atoms | ||
| atom_name = type(expr).__name__ | ||
|
|
||
| # Try to fuse sparse-parameter reconstruction matmuls before normal dispatch |
Collaborator
There was a problem hiding this comment.
is it possible to move this logic into convert_matmul?
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.
Enable CVXPY Parameters as live nodes in the C expression tree, so parameter values can be updated via memcpy without rebuilding the tree. This is critical for parametric NLP problems (MPC, portfolio optimization).
Changes:
Description
Please include a short summary of the change.
Issue link (if applicable):
Type of change
Contribution checklist