Skip to content

Conversation

@Transurgeon
Copy link
Member

Description

This PR is currently in draft and will probably stay so for a while.
The purpose is to try out the C differentiation engine that @dance858 and I have been working on. This will allow us to seamlessly try out the many tests that we wrote for DNLP.

Transurgeon and others added 2 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 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
@Transurgeon Transurgeon marked this pull request as draft January 11, 2026 20:42
@github-actions
Copy link

github-actions bot commented Jan 12, 2026

Benchmarks that have improved:

   before           after         ratio
 [6af3241a]       [f31fa2ac]
  •     1.13±0s          976±0ms     0.86  gini_portfolio.Cajas.time_compile_problem
    

Benchmarks that have stayed the same:

   before           after         ratio
 [6af3241a]       [f31fa2ac]
      288±0ms          298±0ms     1.03  slow_pruning_1668_benchmark.SlowPruningBenchmark.time_compile_problem
      928±0ms          950±0ms     1.02  simple_LP_benchmarks.SimpleScalarParametrizedLPBenchmark.time_compile_problem
     40.6±0ms         41.5±0ms     1.02  matrix_stuffing.SmallMatrixStuffing.time_compile_problem
      1.08±0s          1.10±0s     1.02  finance.FactorCovarianceModel.time_compile_problem
      11.4±0s          11.6±0s     1.02  simple_LP_benchmarks.SimpleLPBenchmark.time_compile_problem
      150±0ms          152±0ms     1.02  high_dim_convex_plasticity.ConvexPlasticity.time_compile_problem
      328±0ms          332±0ms     1.01  gini_portfolio.Yitzhaki.time_compile_problem
      1.90±0s          1.92±0s     1.01  simple_QP_benchmarks.UnconstrainedQP.time_compile_problem
      834±0ms          841±0ms     1.01  simple_QP_benchmarks.LeastSquares.time_compile_problem
     14.2±0ms         14.3±0ms     1.01  simple_LP_benchmarks.SimpleFullyParametrizedLPBenchmark.time_compile_problem
      3.27±0s          3.28±0s     1.00  quantum_hilbert_matrix.QuantumHilbertMatrix.time_compile_problem
      4.40±0s          4.42±0s     1.00  huber_regression.HuberRegression.time_compile_problem
      5.09±0s          5.09±0s     1.00  optimal_advertising.OptimalAdvertising.time_compile_problem
      23.0±0s          23.0±0s     1.00  sdp_segfault_1132_benchmark.SDPSegfault1132Benchmark.time_compile_problem
      694±0ms          694±0ms     1.00  matrix_stuffing.ConeMatrixStuffingBench.time_compile_problem
      1.67±0s          1.67±0s     1.00  tv_inpainting.TvInpainting.time_compile_problem
      14.1±0s          14.1±0s     0.99  finance.CVaRBenchmark.time_compile_problem
      534±0ms          531±0ms     0.99  semidefinite_programming.SemidefiniteProgramming.time_compile_problem
      5.07±0s          5.03±0s     0.99  svm_l1_regularization.SVMWithL1Regularization.time_compile_problem
      248±0ms          245±0ms     0.99  simple_QP_benchmarks.SimpleQPBenchmark.time_compile_problem
      246±0ms          241±0ms     0.98  gini_portfolio.Murray.time_compile_problem
      293±0ms          287±0ms     0.98  matrix_stuffing.ParamSmallMatrixStuffing.time_compile_problem
     14.7±0ms         14.3±0ms     0.97  simple_QP_benchmarks.ParametrizedQPBenchmark.time_compile_problem
      1.48±0s          1.39±0s     0.94  matrix_stuffing.ParamConeMatrixStuffing.time_compile_problem

Transurgeon and others added 2 commits January 12, 2026 16:07
…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 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
@Transurgeon
Copy link
Member Author

Transurgeon commented Jan 13, 2026

the first commit cleans up the inefficient value retrieval for the jacobian and hessian.
the latest TODO is based on the updates in PR #20 of the DNLP diff-engine.

Transurgeon and others added 22 commits January 14, 2026 15:42
- 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…asting rule. This is now internally done in the diff engine
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