Skip to content

Drop the ConeFormat step in to_conic for newer cvxpy - #23

Merged
TobiaMarcucci merged 1 commit into
TobiaMarcucci:mainfrom
nicoloangileri:fix/to-conic-cone-format
Oct 9, 2026
Merged

TobiaMarcucci merged 1 commit into
TobiaMarcucci:mainfrom
nicoloangileri:fix/to-conic-cone-format

Conversation

@nicoloangileri

Copy link
Copy Markdown
Contributor

Fixes #20.

This applies the change @Transurgeon suggested in #20, written so that it works with both the current cvxpy release and cvxpy master. That way it does not have to wait for cvxpy 1.10.

How we noticed

I was updating a cvxpy PR (cvxpy/cvxpy#3490), and its test_gcsopt check failed in tests/test_programs.py::TestConvexProgram::test_to_conic:

AssertionError: np.float64(-6.928203228560545) != -inf within 4 places

The PR doesn't touch anything that gcsopt uses, so I looked at the same check on cvxpy master. It has been red on every master commit since cvxpy/cvxpy#3525. The last green run was on e7e704c6 (2026-09-11) and the first red one on 773163eb (#3525, 2026-09-13). Since cvxpy's gcsopt.yml workflow runs this suite on every cvxpy PR, every cvxpy PR currently shows a red check. That is what led me to #20.

Change

Since the PR #22 changes, to_conic builds the chain with solver=cp.SCS. In cvxpy master that chain ends with ..., ConeFormat, SCS, so chain.reductions[:-1] keeps ConeFormat. The program then comes back in SCS's cone layout instead of the stuffed layout that _constrain_in_cone decodes.

The fix drops the solver-facing steps by type. The steps are Solver and, when it can be imported, ConeFormat. On cvxpy releases without ConeFormat, this is the same as removing the last reduction, as before.

Tests

pytest tests:

cvxpy main this PR
1.9.3 (PyPI) 21 passed 21 passed
master (1.10.0.dev, includes #3525) 2 failed (test_to_conic, test_to_conic_multiple_soc), 19 passed 21 passed

@nicoloangileri

Copy link
Copy Markdown
Contributor Author

Hi @TobiaMarcucci, a gentle ping: cvxpy's test_gcsopt job still fails on every cvxpy PR because of the new ConeFormat step, and this PR keeps gcsopt working with both old and new cvxpy. Happy to adjust if you prefer a different approach. Thanks!

@TobiaMarcucci

Copy link
Copy Markdown
Owner

Sorry for the slow response. The fix looks good to me. Thanks very much!

@TobiaMarcucci
TobiaMarcucci merged commit e24b22d into TobiaMarcucci:main Oct 9, 2026
6 checks passed
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.

Upcoming CVXPY change (#3525) breaks ConvexProgram.to_conic

2 participants