Skip to content

Add --solver argparse option to example scripts#229

Draft
sbarratt wants to merge 3 commits into
masterfrom
curated-jax-examples
Draft

Add --solver argparse option to example scripts#229
sbarratt wants to merge 3 commits into
masterfrom
curated-jax-examples

Conversation

@sbarratt
Copy link
Copy Markdown
Collaborator

@sbarratt sbarratt commented Apr 8, 2026

Summary

  • Remove hardcoded solver=cp.CUCLARABEL and GPU/device-specific code from torch_example.py and jax_example.py
  • Add --solver argparse flag so users can choose any supported solver (DIFFCP, MOREAU, CUCLARABEL, MPAX)
  • Examples now default to CVXPY's default solver when --solver is not specified

Test plan

  • python examples/torch/torch_example.py (default solver)
  • python examples/torch/torch_example.py --solver MOREAU
  • python examples/jax/jax_example.py (default solver)
  • python examples/jax/jax_example.py --solver MOREAU

🤖 Generated with Claude Code

sbarratt and others added 3 commits April 8, 2026 16:11
Explicitly opt out of sparse tensor invariant checks when converting
scipy CSR matrices to torch CSR tensors. The input from scipy already
guarantees sorted, deduplicated indices, so the checks are unnecessary.
This silences the PyTorch UserWarning about implicit invariant check
state.
Remove old jax_example.py and tutorial.ipynb, replace with 5
self-contained examples matching the PyTorch set:

- hello_world: differentiate through least-squares, compare with jnp.linalg.lstsq
- batching: batched least-squares in one call
- lqr: learn LQR value function via trajectory rollouts (BPTT)
- optimal_transport: sensitivity analysis of entropy-regularized OT
- signal_denoising: learn TV denoising params with optax Adam

Add run_example.sh with ./run_example.sh all support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove hardcoded solver and device-specific code from examples.
Solver is now configurable via --solver flag (DIFFCP, MOREAU, CUCLARABEL, MPAX).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant