Skip to content

Update main - #12

Merged
JeremieGince merged 6 commits into
mainfrom
dev
Jun 22, 2026
Merged

Update main#12
JeremieGince merged 6 commits into
mainfrom
dev

Conversation

@JeremieGince

@JeremieGince JeremieGince commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

This pull request introduces significant enhancements to the Rust backend and the PyTorch interface for computing the Pfaffian, primarily by adding support for half-precision (float16) and complex (complex64/complex128) matrix types, improving numerical stability and flexibility. The build workflow is also refactored to better separate versioning, building, and publishing steps. Additionally, the PyTorch block determinant strategy now computes correct gradients for singular blocks, ensuring differentiability for all inputs.

Rust backend: extended precision and type support

  • Added support for float16 (half-precision) and complex (complex64, complex128) types to the Pfaffian computation, including trait implementations, new kernel functions (signed_pfaffian_f16, signed_pfaffian_c64, signed_pfaffian_c128), and tests for correctness and edge cases. [1] [2] [3] [4] [5] [6] [7] [8]

Build and CI workflow improvements

  • Refactored the GitHub Actions workflow to split version computation, multi-platform wheel building, and publishing into separate jobs, enabling parallel builds and clearer artifact handling. [1] [2]

PyTorch interface and documentation

  • Updated the PyTorch interface documentation to clarify that the Rust backend now supports both real and complex precisions, and that both strategies are differentiable for real and complex inputs.

Block determinant strategy: improved gradient for singular blocks

  • Enhanced the backward method in PfaffianBlockDet to compute the correct gradient for singular blocks using the cofactor matrix (adjugate), ensuring finite and accurate derivatives even when the block is not invertible. Added a helper method _cofactor_matrix for this computation.

These changes collectively increase the precision, robustness, and usability of the Pfaffian computation library across a wider range of input types and edge cases.


Checklist

Please complete the following checklist when submitting a PR. The PR will not be reviewed until all items are checked.

  • All new features include a unit test.
    Make sure that the tests passed and the coverage is
    sufficient by running
    uv run pytest --session-timeout=600.
  • All new functions and code are clearly documented.
  • The code passes all pre-commit hooks.
    You can do this by running uvx pre-commit run --all-files.
  • The code is type-checked using Mypy.
    You can do this by running uv run mypy src tests.

@github-actions

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
275 275 100% 98% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/torch_pfaffian/init.py 100% 🟢
src/torch_pfaffian/strategies/pfaffian_block_det.py 100% 🟢
src/torch_pfaffian/strategies/pfaffian_fdbpf.py 100% 🟢
src/torch_pfaffian/strategies/pfaffian_parlett_reid.py 100% 🟢
src/torch_pfaffian/strategies/pfaffian_rust_parlett_reid.py 100% 🟢
src/torch_pfaffian/strategies/strategy.py 100% 🟢
TOTAL 100% 🟢

updated for commit: f23f095 by action🐍

@JeremieGince
JeremieGince merged commit 67d5908 into main Jun 22, 2026
12 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.

1 participant