Skip to content

docs: fix diffcp solver selection and default JAX batching examples - #254

Open
dajiaohuang wants to merge 1 commit into
cvxpy:masterfrom
dajiaohuang:docs/fix-diffcp-solver-selection
Open

dajiaohuang wants to merge 1 commit into
cvxpy:masterfrom
dajiaohuang:docs/fix-diffcp-solver-selection

Conversation

@dajiaohuang

Copy link
Copy Markdown

Summary

Correct executable documentation examples without changing solver behavior:

  • Select the DIFFCP backend with solver, and SCS/Clarabel within diffcp with solver_args["solve_method"] (including the case-sensitive "Clarabel"). Fix the solver guide, basic-usage guidance and constructor docstrings.
  • Scope eps/max_iters to SCS and list Clarabel's actual tolerance/iteration settings.
  • Remove the default-DIFFCP jax.vmap example and explain that built-in batching works with diffcp, while traced transformations require Moreau.

Evidence

On current master, a small DPP least-squares layer following the solver guide raises TypeError: ... unexpected keyword argument 'solver'. Passing solver=cp.CLARABEL as suggested elsewhere raises RuntimeError: Unknown solver. Executing the corrected construction, per-call override and Clarabel fallback snippets produces the expected solution and gradients. The default-backend vmap example raises TracerArrayConversionError; direct batching works.

Validation

Local Windows / Python 3.13, CVXPY 1.9.3, diffcp 1.1.9, SCS 3.3.1, Clarabel 0.11.1, Torch 2.14.1+cpu, JAX 0.11.2:

  • Exact solver-guide snippets: base fails, corrected examples pass with a deterministic least-squares forward/backward oracle.
  • Torch and JAX: unbatched/mixed-batch solver selection and overrides, analytic broadcast gradients, independent CVXPY solution and finite differences; simple batched DGP value/gradient oracle pass.
  • pytest tests/test_jax.py tests/test_dual_variables_jax.py tests/test_torch.py tests/test_dual_variables.py tests/test_parse_args.py tests/test_readme_examples.py: 102 passed, 30 skipped, 3 failed. The failures are the existing three SCS gradchecks described in gradcheck tests fail with scs >= 3.3.0 (pass on 3.2.11) #244, also reproduced before edits; not changed here.
  • Ruff 0.12.7 check on the three edited Python files and git diff --check pass. ASTs excluding docstrings are identical to master.
  • Full pre-commit is not green: existing lint/format violations, optional-dependency/type-check failures and unrelated whitespace/EOF fixes. Unrelated autofixes were reverted; these three Python files also fail formatting on the base. Direct pyright with the isolated interpreter also reports existing typing/optional-backend errors.

MLX, Moreau, MPAX, CUDA/Julia and the documentation build were not run. No runtime implementation changes.

@SteveDiamond SteveDiamond left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the documentation and docstring changes against the current interfaces. The backend/solve_method distinction and batching guidance look reasonable.

This branch has not been deployed

No deployments
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.

2 participants