This release is a pre-release and may not be stable for production use.
MIXSQPX: A JAX-compatible interface to the mixSQP algorithm
This package provides a jax-compatible interface to the mixSQP algorithm described in,
Kim, Y., Carbonetto, P., Stephens, M., & Anitescu, M. (2020). A Fast Algorithm for Maximum Likelihood Estimation of Mixture Proportions Using Sequential Quadratic Programming. Journal of Computational and Graphical Statistics, 29(2), 261–273.
The implementation of the mixSQP algorithm in this package was ported from the R implementation by the authors of this paper which uses the Rarmadillo package as an interface to the Armadillo C++ library.
This package provides a function mixsolve, which can be transformed with
JAX transformations such as jit.
Installation
This branch uses uv as the project frontend and
hatchling as the build backend. Building the package requires a working Rust
toolchain because the default backend is a bundled Rust shared library.
Local Development
# Install uv if you don't have it already.
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository.
git clone https://github.com/pdiegert/mixsqpx.git
cd mixsqpx
# Install Rust if you don't have it already.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Sync the development environment and install the package editable.
uv sync --group test --group examples
uv sync builds the Rust library through the Hatch build hook and installs the
package in editable mode.
Verification
Run the test suite to verify your installation:
uv run --group test pytest tests
Build a wheel locally with:
uv build
Benchmark the Rust backend explicitly with:
uv run --group test python scripts/benchmark_mixsolve.py
Solver accuracy and diagnostics
The Rust solver certifies the full simplex KKT conditions against the original component matrix, including the zero-weight components. The SVD approximation is used for search curvature; the objective, convergence certificate and returned derivatives use the full regularized matrix. Exact active-face Newton steps are used near convergence within the same SQP solve.
tol_svd is an absolute singular-value cutoff. Setting it to zero disables
the low-rank approximation. density_offset is a nonnegative offset after
row scaling (default 1e-8); zero is allowed. With row-scaled components A,
the simplex objective is -mean(log(A @ probabilities + density_offset)).
The implementation uses the equivalent component matrix A + density_offset,
which preserves the homogeneous SQP reformulation and multiplier-one KKT
conditions. Gradients and Hessians are with respect to this component matrix
at the actual returned, normalized weights.
result = mixsolve(
log_component_likelihood,
tol_svd=1e-10,
density_offset=1e-9,
control_sqp=1e-9,
return_info=True,
)
weights = result.probabilities
info = result.info
The typed diagnostics expose status, iterations, active_residual,
inactive_residual, simplex_residual, and svd_rank. Status is 0 for certified
convergence, 1 for the iteration limit, 2 for stagnation, and 3 for invalid
input. Requesting diagnostics permits inspection of an uncertified candidate.
Without return_info=True, failure to meet the requested KKT tolerance raises
an error. The default successful return remains (probabilities, gradient, hessian).
Invalid likelihood inputs return NaN arrays, with status 3 when diagnostics are
requested. Restart the Python process after rebuilding the native library.
Consumers differentiating a profiled objective must apply the same offset to the outer objective and implicit derivatives. A positive offset changes the criterion and its row-scaling derivative must be retained. Its magnitude and any sample-size rule are caller-controlled.
Legacy C++ Reference Path
This branch is intended to merge as a Rust-first package. The legacy C++/Armadillo backend is kept only as an archival benchmark/reference path.
- Keep the legacy implementation in a separate checkout or worktree.
- Use a separate environment for the legacy package.
- Do not treat the legacy C++ build as part of the default developer install on this branch.
A recommended setup is:
git worktree add ../mixsqpx-legacy legacy-cpp-final
Additional details for benchmarking and the opt-in exact legacy reference test are documented in LEGACY_CPP_REFERENCE.md.
License
This project is licensed under the MIT License - see the LICENCE file for details.
Acknowledgements
This project includes code adapted from the mixSQP project, which is available under the MIT license. We thank the original authors (Youngseok Kim, Peter Carbonetto, Matthew Stephens and Mihai Anitescu) for their work.
Metadata
Release files for mixsqpx 0.2.2a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mixsqpx-0.2.2a1.tar.gz | 9.5 MB | Without provenance | Details for mixsqpx-0.2.2a1.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mixsqpx-0.2.2a1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for mixsqpx-0.2.2a1-py3-none-win_amd64.whl |
| mixsqpx-0.2.2a1-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for mixsqpx-0.2.2a1-py3-none-manylinux_2_28_x86_64.whl |
| mixsqpx-0.2.2a1-py3-none-macosx_26_0_arm64.whl | Python 3 | none | macOS 26.0+ ARM64 | Details for mixsqpx-0.2.2a1-py3-none-macosx_26_0_arm64.whl |
Total release size: 10.2 MB
Release files / mixsqpx-0.2.2a1.tar.gz
| Download URL | mixsqpx-0.2.2a1.tar.gz |
|---|---|
| Size | 9.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca4da168e8d25e1c7740040459faf4ccc6b32eb0ef24651a11296eb287d6f17c
|
|
BLAKE2b-256 checksum How to use checksums |
858cf5b4a2d86f9721c756166aeaad943c98a5c9119e28d150f57fd70b3b76a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / mixsqpx-0.2.2a1-py3-none-win_amd64.whl
| Download URL | mixsqpx-0.2.2a1-py3-none-win_amd64.whl |
|---|---|
| Size | 168.5 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b04a0308bbe2c220edb30d9d31209f39333dc09cd3a74301f00d12eff21e8b17
|
|
BLAKE2b-256 checksum How to use checksums |
f5f3b7016ed617fd65e1921823df91258ea0b49912b294cde8d27ce2884e6bad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / mixsqpx-0.2.2a1-py3-none-manylinux_2_28_x86_64.whl
| Download URL | mixsqpx-0.2.2a1-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 287.0 kB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
393e939c0cdd7640732d55aac7cadbcee4bd7e6da06aa1d0356eedaf273f926a
|
|
BLAKE2b-256 checksum How to use checksums |
0c0769b43dfa7409581cecfa313752ef8afa7493ccd08bc8d36f5c1da06c4a33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / mixsqpx-0.2.2a1-py3-none-macosx_26_0_arm64.whl
| Download URL | mixsqpx-0.2.2a1-py3-none-macosx_26_0_arm64.whl |
|---|---|
| Size | 234.5 kB |
| Tags | Python 3 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
74ddb1b7cda5df3bcc550e27ba273f120945b26e4dc0ab69044f5eff70242de2
|
|
BLAKE2b-256 checksum How to use checksums |
70748365f24bd23d84e2338952f6ea62c6b5fe54a4237ac4997616c6afa99214
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for mixsqpx 0.2.2a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.