Restructure Space and Dimension to align with QuTiP#659
Restructure Space and Dimension to align with QuTiP#659
QuTiP#659Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #659 +/- ##
==========================================
+ Coverage 93.09% 93.29% +0.19%
==========================================
Files 58 57 -1
Lines 3839 3906 +67
==========================================
+ Hits 3574 3644 +70
+ Misses 265 262 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors QuantumToolbox.jl’s dimension/space model to better align with QuTiP by introducing Dimensions plus new space types (Space, TensorSpace, LiouvilleSpace), and propagating that change through core quantum objects, solvers, utilities, tests, and documentation.
Changes:
- Replace the old
ProductDimensions/HilbertSpaceapproach withDimensions+Space/TensorSpace/LiouvilleSpace, and update Qobj/QobjEvo constructors and dimension checks accordingly. - Update time-evolution solvers and superoperator utilities to use the new dimension model (including stricter endomorphism checks in several public APIs).
- Update tests and docs to reflect the new
dims/dimensionsrepresentations and new constructors.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/core-test/states_and_operators.jl | Updates expected dims shapes for kets and superoperators. |
| test/core-test/quantum_objects_evo.jl | Updates QobjEvo superoperator dimension expectations to LiouvilleSpace. |
| test/core-test/quantum_objects.jl | Adapts many dimension assertions to Dimensions/Space and new dims conventions. |
| test/core-test/negativity_and_partial_transpose.jl | Adjusts partial-transpose invalid-dimension tests for new dimension semantics. |
| test/core-test/low_rank_dynamics.jl | Updates concrete type expectations for Ket objects under new dimension types. |
| test/core-test/enr_state_operator.jl | Updates energy-restricted / tensor-space dimension construction in tests. |
| test/core-test/eigenvalues_and_operators.jl | Updates inferred EigsolveResult dimension type parameters. |
| src/utilities.jl | Adds VectorOrTuple alias used across new dimension/space APIs. |
| src/time_evolution/time_evolution_dynamical.jl | Updates dimension-length and size utilities to get_size/.to semantics. |
| src/time_evolution/time_evolution.jl | Tightens TimeEvolutionProblem to Dimensions and adds init-state handling helper. |
| src/time_evolution/ssesolve.jl | Uses shared init-state handler and updates identity sizing/dimension plumbing. |
| src/time_evolution/smesolve.jl | Uses shared init-state handler and updates identity sizing/dimension plumbing. |
| src/time_evolution/sesolve.jl | Uses shared init-state handler and updates solution dimension construction. |
| src/time_evolution/mesolve.jl | Uses shared init-state handler and updates solution dimension construction. |
| src/time_evolution/mcsolve.jl | Updates ensemble result normalization to pass full Dimensions. |
| src/time_evolution/brmesolve.jl | Constructs superoperator outputs in Liouville space with explicit Dimensions. |
| src/steadystate.jl | Adds endomorphism validation and extracts underlying operator dimensions from Liouville space. |
| src/spin_lattice.jl | Generalizes input dims type and switches to get_size-based checks. |
| src/spectrum.jl | Adds dimension validity checks and adjusts size computations to new dimension model. |
| src/qobj/superoperators.jl | Ensures spre/spost/sprepost/liouvillian return Liouville-space Dimensions. |
| src/qobj/states.jl | Migrates state constructors to Dimensions and get_size. |
| src/qobj/space.jl | Removes legacy HilbertSpace implementation (moved into new dimension system). |
| src/qobj/quantum_object_evo.jl | Constrains QobjEvo dimensions to Dimensions, updates size checking and default dims inference. |
| src/qobj/quantum_object_base.jl | Reworks _check_QuantumObject, _gen_dimensions, and data-size handling for Dimensions. |
| src/qobj/quantum_object.jl | Constrains Qobj dimensions to Dimensions and updates default dims inference for vectors/matrices. |
| src/qobj/operators.jl | Switches operator helpers to Dimensions/get_size and simplifies eye/qeye dims handling. |
| src/qobj/functions.jl | Updates tensor (kron) and vec/mat conversion utilities to new dimension model. |
| src/qobj/energy_restricted.jl | Generalizes dims inputs and switches to get_size for EnrSpace. |
| src/qobj/eigsolve.jl | Migrates eigensolver result dimensions to Dimensions and updates Arnoldi-Lindblad flow. |
| src/qobj/dimensions.jl | Introduces new Dimensions and space types (Space, TensorSpace, LiouvilleSpace) plus get_size. |
| src/qobj/arithmetic_and_attributes.jl | Updates arithmetic, multiplication dimension rules, and ptrace/permute for new dimensions. |
| src/negativity.jl | Updates negativity/partial-transpose typing and dimension-length logic. |
| src/entropy.jl | Updates dimension type constraints and two-qubit dimension construction. |
| src/correlations.jl | Refactors correlation flow to evolve OperatorKet states and updates identity sizing via get_size. |
| src/QuantumToolbox.jl | Removes include of deleted qobj/space.jl and relies on qobj/dimensions.jl for spaces. |
| ext/QuantumToolboxMakieExt.jl | Imports get_size to match updated core APIs. |
| ext/QuantumToolboxCUDAExt.jl | Updates CUDA conversion method constraints to Dimensions. |
| ext/MakieExt/fock_distribution.jl | Switches to get_size for dimension sizing in plotting. |
| docs/src/resources/api.md | Updates API listings to reflect new dimension/space types and removes old size helpers. |
| docs/src/getting_started/type_stability.md | Updates examples to use get_size. |
| .github/copilot-instructions.md | Updates internal contributor guidance to new Dimensions conventions. |
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Benchmark Results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.
| Benchmark suite | Current: 777ebb4 | Previous: 249806f | Ratio |
|---|---|---|---|
Autodiff/sesolve/Reverse (Mooncake) |
1483684.5 ns |
1094990 ns |
1.35 |
Time Evolution/Dynamical Shifted Fock/mcsolve/Serial |
1017460441 ns |
700110195 ns |
1.45 |
Time Evolution/Dynamical Shifted Fock/mcsolve/Multithreaded |
517511389 ns |
375463135 ns |
1.38 |
Time Evolution/time-dependent/mesolve/QobjEvo |
1533457832.5 ns |
895083873 ns |
1.71 |
Time Evolution/time-dependent/mesolve/Tuple |
1393319053.5 ns |
899622590.5 ns |
1.55 |
Time Evolution/time-dependent/mesolve/Liouvillian |
1527492016.5 ns |
891257959.5 ns |
1.71 |
This comment was automatically generated by workflow using github-action-benchmark.
Checklist
Thank you for contributing to
QuantumToolbox.jl! Please make sure you have finished the following tasks before opening the PR.make test.juliaformatted by running:make format.docs/folder) related to code changes were updated and able to build locally by running:make docs.CHANGELOG.mdshould be updated (regarding to the code changes) and built by running:make changelog.Request for a review after you have completed all the tasks. If you have not finished them all, you can also open a Draft Pull Request to let the others know this on-going work.
Description
This PR basically overwrites many changes made in PR #600:
ProductDimensionsandHilbertSpacestructures withDimensions+Space/TensorSpace/LiouvilleSpace.get_hilbert_sizeandget_liouville_size, and useget_sizeinstead.The changes are summarized by copilot below.