Skip to content

Conversation

@Transurgeon
Copy link
Member

  • Simplify _verify_hess_vec_args and _verify_jacobian_args in log.py and exp.py to check self.args[0].is_affine() instead of requiring isinstance(Variable)
  • Remove _hess_vec methods from both atoms (NLP solver handles derivatives via C diff engine)
  • Fix _extract_affine_as_linear_op in converters.py to create column vector (n_vars, 1) instead of row vector for compatibility with C new_linear function
  • Add comprehensive test suite for affine argument handling including gradient verification, Hessian structure tests, edge cases, and constraint tests

Transurgeon and others added 30 commits January 11, 2026 15:03
Replace the pure-Python Oracles class with a new implementation that
wraps the C-based C_problem class from dnlp_diff_engine. This provides
automatic differentiation via the compiled C library instead of the
Python-based jacobian/hessian computation.

Key changes:
- Replace Oracles class implementation in nlp_solver.py
- Use lazy import to avoid circular dependency at module load time
- Convert CSR sparse matrices from diff engine to COO format for solvers
- Cache sparsity structures for jacobian and hessian

Currently supported atoms: log, exp, sum, AddExpression, NegExpression,
Promote. Other atoms (multiply, power, matmul, etc.) need to be added
to the diff engine before all NLP tests pass.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Document all newly added Python bindings (power, trig, hyperbolic, matmul)
- Update test status: 2/15 IPOPT tests now pass
- Clarify blocking issues for remaining tests (index, norm, C bugs)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…alue extraction

- Remove redundant objective_forward/constraint_forward calls from gradient(),
  jacobian(), and hessian() since NLP solvers guarantee call ordering
- Replace matrix densification + zip iteration with direct COO data return
  for jacobian and hessian value extraction

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Updated implemented atoms list (index, reshape, sqrt, quad_over_lin, rel_entr)
- Updated test results summary with current pass/fail status
- Added known issues section (segfaults, bivariate matmul, rel_entr scalar)
- Added missing atoms by priority

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- reshape atom now fully implemented with Python binding (commit 81c5a12)
- All 3 circle packing tests now PASS
- test_clnlbeam now PASSES (previously segfaulted)
- Memory issues with many constraints fixed
- Only test_localization still failing (needs broadcast_to)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Full nlp_tests results (2025-01-14):
- 259 passed, 20 failed, 64 skipped, 1 xfailed

Remaining failures by missing atom:
- broadcast_to: 5 tests (localization, broadcast, best_of)
- Prod: 9 tests
- MulExpression (bivariate matmul): 5 tests
- rel_entr scalar variants: 1 test

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Examples: X @ Y (both Variables), cos(X) @ sin(Y)
Currently supported: A @ f(x) and f(x) @ A where A is constant

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Added Prod to implemented atoms list
- Updated test_prod.py results: 13 passing, 1 failing (axis param)
- Updated summary: 267 passed, 12 failed (down from 20)

Remaining failures: broadcast_to (5), Prod axis (1), MulExpression (5), rel_entr scalar (1)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Create cvxpy/reductions/solvers/nlp_solvers/diff_engine/ package
- Move C_problem wrapper and ATOM_CONVERTERS from dnlp-diff-engine
- converters.py: Expression tree conversion from CVXPY atoms to C nodes
- c_problem.py: C_problem class wrapping the C problem struct
- Update nlp_solver.py to import from new location

This separates CVXPY-specific glue code from the pure C autodiff library,
eliminating circular dependencies and preparing dnlp-diff-engine for
standalone PyPI distribution.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Merge license header and module docstring into single docstring
to avoid "module level import not at top of file" errors.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…asting rule. This is now internally done in the diff engine
dance858 and others added 8 commits January 19, 2026 08:52
- Simplify _verify_hess_vec_args and _verify_jacobian_args in log.py
  and exp.py to check self.args[0].is_affine() instead of requiring
  isinstance(Variable)
- Remove _hess_vec methods from both atoms (NLP solver handles
  derivatives via C diff engine)
- Fix _extract_affine_as_linear_op in converters.py to create column
  vector (n_vars, 1) instead of row vector for compatibility with C
  new_linear function
- Add comprehensive test suite for affine argument handling including
  gradient verification, Hessian structure tests, edge cases, and
  constraint tests

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@Transurgeon Transurgeon marked this pull request as draft January 20, 2026 20:08
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

Benchmarks that have stayed the same:

   before           after         ratio
 [2ed0cd09]       [2b198459]
     41.5±0ms         43.8±0ms     1.06  matrix_stuffing.SmallMatrixStuffing.time_compile_problem
      321±0ms          336±0ms     1.05  gini_portfolio.Yitzhaki.time_compile_problem
      13.7±0s          14.3±0s     1.04  finance.CVaRBenchmark.time_compile_problem
      293±0ms          304±0ms     1.04  matrix_stuffing.ParamSmallMatrixStuffing.time_compile_problem
      942±0ms          971±0ms     1.03  gini_portfolio.Cajas.time_compile_problem
      246±0ms          252±0ms     1.02  simple_QP_benchmarks.SimpleQPBenchmark.time_compile_problem
      236±0ms          241±0ms     1.02  gini_portfolio.Murray.time_compile_problem
      148±0ms          151±0ms     1.02  high_dim_convex_plasticity.ConvexPlasticity.time_compile_problem
      1.47±0s          1.50±0s     1.02  matrix_stuffing.ParamConeMatrixStuffing.time_compile_problem
      927±0ms          939±0ms     1.01  simple_LP_benchmarks.SimpleScalarParametrizedLPBenchmark.time_compile_problem
     14.3±0ms         14.4±0ms     1.01  simple_QP_benchmarks.ParametrizedQPBenchmark.time_compile_problem
      1.90±0s          1.92±0s     1.01  simple_QP_benchmarks.UnconstrainedQP.time_compile_problem
      690±0ms          696±0ms     1.01  matrix_stuffing.ConeMatrixStuffingBench.time_compile_problem
      1.07±0s          1.08±0s     1.01  finance.FactorCovarianceModel.time_compile_problem
      3.22±0s          3.23±0s     1.00  quantum_hilbert_matrix.QuantumHilbertMatrix.time_compile_problem
      289±0ms          290±0ms     1.00  slow_pruning_1668_benchmark.SlowPruningBenchmark.time_compile_problem
      4.39±0s          4.40±0s     1.00  huber_regression.HuberRegression.time_compile_problem
      5.10±0s          5.10±0s     1.00  optimal_advertising.OptimalAdvertising.time_compile_problem
      854±0ms          852±0ms     1.00  simple_QP_benchmarks.LeastSquares.time_compile_problem
      548±0ms          546±0ms     1.00  semidefinite_programming.SemidefiniteProgramming.time_compile_problem
      5.15±0s          5.11±0s     0.99  svm_l1_regularization.SVMWithL1Regularization.time_compile_problem
      1.65±0s          1.64±0s     0.99  tv_inpainting.TvInpainting.time_compile_problem
      23.0±0s          22.6±0s     0.98  sdp_segfault_1132_benchmark.SDPSegfault1132Benchmark.time_compile_problem
      11.8±0s          11.5±0s     0.97  simple_LP_benchmarks.SimpleLPBenchmark.time_compile_problem
     15.2±0ms         14.5±0ms     0.95  simple_LP_benchmarks.SimpleFullyParametrizedLPBenchmark.time_compile_problem

Transurgeon and others added 6 commits January 20, 2026 15:35
Use is_affine() check instead of isinstance(Variable) so that any
affine expression (e.g., 2*x + 3) passes through without creating
unnecessary auxiliary variables and equality constraints.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Keep AFFINE_ARG_ATOMS special handling for coefficient extraction
while incorporating latest diffengine-setup changes.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add diag_vec to ATOM_CONVERTERS for cp.diag(vector) support
- Add automatic reshape when linear_op flattens matrix expressions

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

3 participants