Skip to content

benchmark against QuantumAlgebra - #163

Merged
oameye merged 10 commits into
mainfrom
QuantumAlgebra
Jul 21, 2026
Merged

benchmark against QuantumAlgebra#163
oameye merged 10 commits into
mainfrom
QuantumAlgebra

Conversation

@oameye

@oameye oameye commented Jun 9, 2026

Copy link
Copy Markdown
Member

Docs preview: https://qojulia.github.io/SecondQuantizedAlgebra.jl/previews/PR163/comparison/

Adds a cross-package benchmark suite and a "Comparison with other packages" docs page that pit SecondQuantizedAlgebra.jl (SQA) against four other symbolic second-quantized algebra packages, across three languages: QuantumAlgebra.jl, SymPy (sympy.physics.quantum), OpenFermion, and sneg (Mathematica).

image

Fairness contract

Every row times each package producing the same canonical (normal-ordered) result from the same physical input, written idiomatically in that package.

  • Eager packages (SQA, sneg) canonicalize on every *, so the operation itself is timed. Lazy packages (QuantumAlgebra, SymPy, OpenFermion) are timed through their normalization call.
  • Products of 3+ factors use the eager workflow on the lazy side too (normalize after each multiply), so we measure the algorithm, not a workflow footgun.
  • Before timing, each script verifies textbook identities in its own package (a a† = 1 + a†a, a a a† = a†a a + 2a, two-level completeness). A failing check aborts that package's run. Any single trial over 3 s is reported as capped.
  • Cross-language ratios are order-of-magnitude indicators (BenchmarkTools median / Python timeit / Mathematica RepeatedTiming). The Julia-vs-Julia column is precise.

Results

Single Linux workstation, 2026-07-17: SQA 0.9.0 and QuantumAlgebra 1.6.0 on Julia 1.12.6, SymPy 1.14.0 and OpenFermion 1.8.1 on Python 3.14.6, sneg 2.0.21 on Mathematica 14.2. The SQA column is absolute time; every other cell shows that package's time with its ratio to SQA in parentheses. n/a means the scenario is not expressible in that package.

@oameye
oameye marked this pull request as ready for review July 20, 2026 08:01

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark Results

Details
Benchmark suite Current: bc413da Previous: 5a37827 Ratio
Accumulation/Many-mode H/foldl M=16 9551 ns 10870 ns 0.88
Accumulation/Many-mode H/foldl M=24 20844 ns 24726 ns 0.84
Accumulation/Many-mode H/foldl M=8 2299.1111111111113 ns 2800.8888888888887 ns 0.82
Accumulation/Many-mode H/sum M=16 1311 ns 1683.1 ns 0.78
Accumulation/Many-mode H/sum M=24 1810.4 ns 2298.777777777778 ns 0.79
Accumulation/Many-mode H/sum M=8 534.0752688172043 ns 713.2805755395683 ns 0.75
Accumulation/Same-site/foldl 5138 ns 6229.6 ns 0.82
Accumulation/Same-site/sum 1604.8 ns 2101.777777777778 ns 0.76
Commutator/Nested JC/depth=1 1214.4 ns 1678.1 ns 0.72
Commutator/Nested JC/depth=2 13475 ns 18254 ns 0.74
Commutator/Nested JC/depth=3 49280 ns 68689 ns 0.72
Commutator/Nested JC/depth=4 122277 ns 170841 ns 0.72
Commutator/Nested JC/depth=5 265554 ns 377859 ns 0.70
Commutator/Schrieffer-Wolff/[S, V] 128500 ns 201047 ns 0.64
Commutator/Schrieffer-Wolff/[S, [S, H0]] 237861 ns 375935 ns 0.63
Indexing/Diagonal collapse/[H_Dicke, S_j] 30140 ns 43342 ns 0.70
Indexing/Diagonal collapse/[H_JC, σ_j] 40410 ns 61826 ns 0.65
Indexing/Simplify/double-sum spin-spin 10693 ns 16030 ns 0.67
Indexing/Simplify/indexed JC H 1085 ns 1135.1 ns 0.96
Indexing/Sum construction/double Σ_ij(J_ij*S_i*S_j) 5884.6 ns 8596.333333333334 ns 0.68
Indexing/Sum construction/single Σ_i(σ_i*σ_j) 7137.5 ns 11642 ns 0.61
Normal Order/Fock (c*c')^n/n=2 486.4948979591837 ns 602.224043715847 ns 0.81
Normal Order/Fock (c*c')^n/n=3 726.5644171779142 ns 869 ns 0.84
Normal Order/Fock (c*c')^n/n=4 997.7777777777778 ns 1154.2 ns 0.86
Normal Order/Fock (c*c')^n/n=5 1326.1 ns 1539.9 ns 0.86
Normal Order/Ground state/3-level rewrite 652.5204678362574 ns 818.7183098591549 ns 0.80
Normal Order/Multi-mode/2-mode 6-op chain 817.6518518518518 ns 957.578947368421 ns 0.85
Simplify/Jaynes-Cummings/H 845.0727272727273 ns 1057 ns 0.80
Simplify/Jaynes-Cummings/H² 1788.3 ns 2381.1111111111113 ns 0.75
Simplify/Two cavities/H 876.0333333333333 ns 1083.1 ns 0.81
Simplify/Two cavities/H² 3521.25 ns 4564.285714285715 ns 0.77
Simplify/Λ-system/H 998.6 ns 1350.5 ns 0.74
Simplify/Λ-system/H² 1709.4 ns 2286.5555555555557 ns 0.75

This comment was automatically generated by workflow using github-action-benchmark.

@oameye
oameye requested a review from ChristophHotter July 21, 2026 09:26
@oameye
oameye merged commit d338716 into main Jul 21, 2026
6 of 7 checks passed
@oameye
oameye deleted the QuantumAlgebra branch July 21, 2026 19:10
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