Skip to content

Improve and standardize the cuPDLPx Python API#100

Merged
ZedongPeng merged 29 commits into
MIT-Lu-Lab:mainfrom
LucasBoTang:main
Jul 10, 2026
Merged

Improve and standardize the cuPDLPx Python API#100
ZedongPeng merged 29 commits into
MIT-Lu-Lab:mainfrom
LucasBoTang:main

Conversation

@LucasBoTang

Copy link
Copy Markdown
Collaborator

Summary

This PR hardens and standardizes the Python interface for cuPDLPx. It fixes binding/API correctness issues, strengthens validation, and makes the public API more consistent with common optimization solver conventions.

Highlights

  • Fixed correctness issues in the Python binding layer, including a solve_once result-lifetime leak and an incorrect status-code mapping.
  • Improved binding memory safety with RAII for native problem and result objects.
  • Strengthened validation for model data and bounds, warm starts, solver parameters, and sparse matrix inputs.
  • Standardized solver status reporting:
    • Model.Status is now an integer status code.
    • Model.StatusName provides the human-readable status.
    • The redundant Model.StatusCode property was removed.
  • Improved model and parameter ergonomics:
    • optimize() now returns the model instance.
    • resetParams() restores default parameter values.
    • Params supports attribute access, item access, and lightweight mapping-style helpers.
  • Added support for SciPy sparse arrays (csr_array and coo_array) alongside legacy sparse matrices.
  • Updated documentation and tests, and removed obsolete code and pytest configuration.

Breaking changes

  • Model.Status is now an int; use Model.StatusName for the textual status.
  • Model.StatusCode has been removed.
  • setWarmStart() now raises ValueError when provided vectors have incorrect dimensions.
  • Invalid model data, bounds, sparse matrices, and parameters are rejected earlier and may now raise Python exceptions before entering the solver.

Testing

  • Rebuilt the Python extension in WSL.

  • Passed the Python API tests and full Python test suite:

    pytest test/test_api_surface.py
    pytest test

@ZedongPeng ZedongPeng self-requested a review July 10, 2026 19:01
@ZedongPeng ZedongPeng merged commit b113780 into MIT-Lu-Lab:main Jul 10, 2026
18 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.

2 participants