From 66217c586454794a36b36b28e018b482b35a15ae Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Sat, 17 Jan 2026 15:05:40 -0500 Subject: [PATCH 01/13] memory leak fixes --- src/bindings.cpp.in | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bindings.cpp.in b/src/bindings.cpp.in index 817ffe6d..6666690e 100644 --- a/src/bindings.cpp.in +++ b/src/bindings.cpp.in @@ -1,4 +1,5 @@ #include +#include #include #include @@ -132,6 +133,7 @@ class PyOSQPSolver { const CSC& _A; py::array_t _u; OSQPSolver *_solver; + std::unique_ptr _solution_cache; }; PyOSQPSolver::PyOSQPSolver( @@ -143,8 +145,7 @@ PyOSQPSolver::PyOSQPSolver( OSQPInt m, OSQPInt n, const OSQPSettings *settings -): m(m), n(n), _P(P), _A(A) { - this->_solver = new OSQPSolver(); +): m(m), n(n), _P(P), _A(A), _solver(nullptr) { this->_q = q; this->_l = l; this->_u = u; @@ -164,8 +165,10 @@ OSQPSettings* PyOSQPSolver::get_settings() { } PyOSQPSolution& PyOSQPSolver::get_solution() { - PyOSQPSolution* solution = new PyOSQPSolution(*this->_solver->solution, this->m, this->n); - return *solution; + if (!_solution_cache) { + _solution_cache = std::make_unique(*this->_solver->solution, this->m, this->n); + } + return *_solution_cache; } OSQPInfo* PyOSQPSolver::get_info() { From ee7427a4f6aa1f71f70a440c18e5bea86660d5f5 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Mon, 19 Jan 2026 22:18:20 -0500 Subject: [PATCH 02/13] updated macos-13 to macos-15-intel, as per https://github.com/actions/runner-images/issues/13046 --- .github/workflows/build_default.yml | 4 ++-- .github/workflows/build_mkl.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_default.yml b/.github/workflows/build_default.yml index a66c4a04..da05f546 100644 --- a/.github/workflows/build_default.yml +++ b/.github/workflows/build_default.yml @@ -46,8 +46,8 @@ jobs: cibw_archs: "auto" - os: windows-2022 cibw_archs: "auto64" - # Include macos-13 to get Intel x86_64 macs and maos-latest to get the Aaarch64 macs - - os: macos-13 + # Include macos-15-intel to get Intel x86_64 macs and macos-latest to get the Aaarch64 macs + - os: macos-15-intel cibw_archs: "x86_64" - os: macos-latest cibw_archs: "arm64" diff --git a/.github/workflows/build_mkl.yml b/.github/workflows/build_mkl.yml index 67f5c677..1457633a 100644 --- a/.github/workflows/build_mkl.yml +++ b/.github/workflows/build_mkl.yml @@ -17,9 +17,9 @@ jobs: strategy: fail-fast: false matrix: - # macos-latest now uses arm64 runners, but MKL is x86_64 only, so restrict to the macos-13 runners + # macos-latest now uses arm64 runners, but MKL is x86_64 only, so restrict to the macos-15-intel runners # to get x86_64 architecture. - os: [ubuntu-latest, macos-13] + os: [ubuntu-latest, macos-15-intel] steps: - uses: actions/checkout@master From 80198522c40729e0140bbdabe96bd166d95d80a8 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Tue, 20 Jan 2026 10:56:52 -0500 Subject: [PATCH 03/13] prefer-binary for packages needed for cibuildwheel testing --- cibuildwheel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 4b8cb2f8..250a7e2e 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -6,7 +6,7 @@ before-build = "rm -rf {package}/osqp_sources/build" # Install CPU-only version of torch beforehand since that allows cibuildwheel # to satisfy the "test" dependency group install, but much faster. The runtime # cost of torch-based osqp tests are considered negligible so torch-cpu is ok. -before-test = "pip install torch --index-url https://download.pytorch.org/whl/cpu" +before-test = "pip install torch --prefer-binary --index-url https://download.pytorch.org/whl/cpu" test-groups = ["test"] test-command = "python -m pytest -s {project}/src/osqp/tests" # 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable From 58f34e250745f900bc04131c27349cc0486f341d Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Tue, 20 Jan 2026 11:54:41 -0500 Subject: [PATCH 04/13] c++14 standard; openblas deps for cibuildwheel on linux --- CMakeLists.txt | 3 +++ cibuildwheel.toml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33349318..231fbe5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.15...3.26) project(ext) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(PYTHON "ON") set(OSQP_BUILD_UNITTESTS "OFF") set(OSQP_USE_LONG "OFF") diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 250a7e2e..a6ad5842 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -12,6 +12,9 @@ test-command = "python -m pytest -s {project}/src/osqp/tests" # 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable test-skip = "cp313-manylinux_aarch64" +[tool.cibuildwheel.linux] +before-all = "yum install -y openblas-devel" + [tool.cibuildwheel.macos] # 02/13/25 - Skip testing on cp313-macosx_x86_64 because torch/numpy deps are unsatisfiable test-skip = "cp313-macosx_x86_64" From b01eb25917dbf442666909fe21f6171de58b78f8 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Tue, 20 Jan 2026 12:12:07 -0500 Subject: [PATCH 05/13] skipping cp311 --- cibuildwheel.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index a6ad5842..977aedf5 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -1,6 +1,9 @@ [tool.cibuildwheel] build = "cp3*" -skip = ["cp36-*", "cp37-*", "*-win32", "*-manylinux_i686", "*-musllinux_*"] +# 01/20/26 - cp311-* added to list because we can't get scipy to install +# (for wheel testing purposes). Building scipy insists on OpenBLAS which is +# unavailable inside the container. +skip = ["cp36-*", "cp37-*", "cp311-*", "*-win32", "*-manylinux_i686", "*-musllinux_*"] build-verbosity = 1 before-build = "rm -rf {package}/osqp_sources/build" # Install CPU-only version of torch beforehand since that allows cibuildwheel @@ -12,9 +15,6 @@ test-command = "python -m pytest -s {project}/src/osqp/tests" # 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable test-skip = "cp313-manylinux_aarch64" -[tool.cibuildwheel.linux] -before-all = "yum install -y openblas-devel" - [tool.cibuildwheel.macos] # 02/13/25 - Skip testing on cp313-macosx_x86_64 because torch/numpy deps are unsatisfiable test-skip = "cp313-macosx_x86_64" From 60508cb04d476c633b71ed674ad31a4917662480 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Tue, 20 Jan 2026 13:32:39 -0500 Subject: [PATCH 06/13] pinning scipy for tests to avoid building it from source --- cibuildwheel.toml | 7 ++----- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 977aedf5..4b8cb2f8 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -1,15 +1,12 @@ [tool.cibuildwheel] build = "cp3*" -# 01/20/26 - cp311-* added to list because we can't get scipy to install -# (for wheel testing purposes). Building scipy insists on OpenBLAS which is -# unavailable inside the container. -skip = ["cp36-*", "cp37-*", "cp311-*", "*-win32", "*-manylinux_i686", "*-musllinux_*"] +skip = ["cp36-*", "cp37-*", "*-win32", "*-manylinux_i686", "*-musllinux_*"] build-verbosity = 1 before-build = "rm -rf {package}/osqp_sources/build" # Install CPU-only version of torch beforehand since that allows cibuildwheel # to satisfy the "test" dependency group install, but much faster. The runtime # cost of torch-based osqp tests are considered negligible so torch-cpu is ok. -before-test = "pip install torch --prefer-binary --index-url https://download.pytorch.org/whl/cpu" +before-test = "pip install torch --index-url https://download.pytorch.org/whl/cpu" test-groups = ["test"] test-command = "python -m pytest -s {project}/src/osqp/tests" # 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable diff --git a/pyproject.toml b/pyproject.toml index c52e0fc7..150109ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ cu12 = [ # support installation of torch at all, which is why it is useful to have this # dependency group. test-no-nn = ["pytest>=6"] -test = ["torch", "scipy!=1.12.0", { include-group = "test-no-nn" }] +test = ["torch", "scipy!=1.12.0,<1.17", { include-group = "test-no-nn" }] dev = ["pre-commit", { include-group = "test" }] [tool.scikit-build] From fb5f0e02314f733522bc39e8b95db2a891eef332 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Tue, 20 Jan 2026 14:00:08 -0500 Subject: [PATCH 07/13] pinning scipy before torch install --- cibuildwheel.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 4b8cb2f8..55ee4c45 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -6,7 +6,10 @@ before-build = "rm -rf {package}/osqp_sources/build" # Install CPU-only version of torch beforehand since that allows cibuildwheel # to satisfy the "test" dependency group install, but much faster. The runtime # cost of torch-based osqp tests are considered negligible so torch-cpu is ok. -before-test = "pip install torch --index-url https://download.pytorch.org/whl/cpu" +before-test = """ +pip install "scipy!=1.12.0,<1.17" +pip install torch --index-url https://download.pytorch.org/whl/cpu" +""" test-groups = ["test"] test-command = "python -m pytest -s {project}/src/osqp/tests" # 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable From 4a90c76cf52b63af41512520b1729f1d3601434b Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Tue, 20 Jan 2026 14:12:46 -0500 Subject: [PATCH 08/13] syntax fix --- cibuildwheel.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 55ee4c45..0a31ec11 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -6,10 +6,7 @@ before-build = "rm -rf {package}/osqp_sources/build" # Install CPU-only version of torch beforehand since that allows cibuildwheel # to satisfy the "test" dependency group install, but much faster. The runtime # cost of torch-based osqp tests are considered negligible so torch-cpu is ok. -before-test = """ -pip install "scipy!=1.12.0,<1.17" -pip install torch --index-url https://download.pytorch.org/whl/cpu" -""" +before-test = 'pip install "scipy!=1.12.0,<1.17" && pip install torch --index-url https://download.pytorch.org/whl/cpu' test-groups = ["test"] test-command = "python -m pytest -s {project}/src/osqp/tests" # 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable From 0cf4b23a55a8cb5e395453e9265009dded2b879e Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Mon, 26 Jan 2026 13:33:15 -0500 Subject: [PATCH 09/13] binary only versions of scipy installed --- cibuildwheel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 0a31ec11..492e95e6 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -6,7 +6,7 @@ before-build = "rm -rf {package}/osqp_sources/build" # Install CPU-only version of torch beforehand since that allows cibuildwheel # to satisfy the "test" dependency group install, but much faster. The runtime # cost of torch-based osqp tests are considered negligible so torch-cpu is ok. -before-test = 'pip install "scipy!=1.12.0,<1.17" && pip install torch --index-url https://download.pytorch.org/whl/cpu' +before-test = 'pip install scipy --prefer-binary && pip install torch --index-url https://download.pytorch.org/whl/cpu' test-groups = ["test"] test-command = "python -m pytest -s {project}/src/osqp/tests" # 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable From f2b17f406336256bc58954dd0d06b615d28cb1cb Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Mon, 26 Jan 2026 13:38:49 -0500 Subject: [PATCH 10/13] not being too particular about scipy version on main pyproject toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 150109ff..c52e0fc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ cu12 = [ # support installation of torch at all, which is why it is useful to have this # dependency group. test-no-nn = ["pytest>=6"] -test = ["torch", "scipy!=1.12.0,<1.17", { include-group = "test-no-nn" }] +test = ["torch", "scipy!=1.12.0", { include-group = "test-no-nn" }] dev = ["pre-commit", { include-group = "test" }] [tool.scikit-build] From 7df4acb49e56ac86a7a655cc105e2078c399e2ed Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Mon, 26 Jan 2026 13:59:46 -0500 Subject: [PATCH 11/13] skip pytorch tests on linux arm platforms --- cibuildwheel.toml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 492e95e6..bf859829 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -9,12 +9,13 @@ before-build = "rm -rf {package}/osqp_sources/build" before-test = 'pip install scipy --prefer-binary && pip install torch --index-url https://download.pytorch.org/whl/cpu' test-groups = ["test"] test-command = "python -m pytest -s {project}/src/osqp/tests" -# 09/10/25 - Skip testing on cp313-manylinux_aarch64 because torch/numpy deps are unsatisfiable -test-skip = "cp313-manylinux_aarch64" -[tool.cibuildwheel.macos] -# 02/13/25 - Skip testing on cp313-macosx_x86_64 because torch/numpy deps are unsatisfiable -test-skip = "cp313-macosx_x86_64" +[[tool.cibuildwheel.overrides]] +# Platforms on which installing pytorch is problematic, so we skip testing +# the `osqp.nn` module +select = "*manylinux_aarch64" +before-test = 'pip install scipy --prefer-binary' +test-groups = ["test-no-nn"] [tool.cibuildwheel.pyodide] build = "cp312-pyodide_wasm32" From e221cd300c9135027f21cb875af3e599b8340d91 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Mon, 26 Jan 2026 14:09:36 -0500 Subject: [PATCH 12/13] custom pytest invocation for situations where we choose not to install pytorch --- cibuildwheel.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index bf859829..7a284e17 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -16,6 +16,7 @@ test-command = "python -m pytest -s {project}/src/osqp/tests" select = "*manylinux_aarch64" before-test = 'pip install scipy --prefer-binary' test-groups = ["test-no-nn"] +test-command = "python -m pytest -s {project}/src/osqp/tests --continue-on-collection-errors --ignore={project}/src/osqp/tests/nn_test.py" [tool.cibuildwheel.pyodide] build = "cp312-pyodide_wasm32" From f8d55da5dc53e053039130ed995abf586942e60d Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Mon, 26 Jan 2026 15:15:18 -0500 Subject: [PATCH 13/13] added cp13 macos to platforms where we cannot do pytorch stuff --- cibuildwheel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 7a284e17..a9082b9d 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -13,7 +13,7 @@ test-command = "python -m pytest -s {project}/src/osqp/tests" [[tool.cibuildwheel.overrides]] # Platforms on which installing pytorch is problematic, so we skip testing # the `osqp.nn` module -select = "*manylinux_aarch64" +select = "*manylinux_aarch64 cp313-macosx_x86_64" before-test = 'pip install scipy --prefer-binary' test-groups = ["test-no-nn"] test-command = "python -m pytest -s {project}/src/osqp/tests --continue-on-collection-errors --ignore={project}/src/osqp/tests/nn_test.py"