Skip to content

✨ Add QCO density-matrix DD simulation - #2080

Closed
simon1hofmann wants to merge 14 commits into
codex/qco-dd-construction-deallocationfrom
codex/qco-dd-density-matrix
Closed

✨ Add QCO density-matrix DD simulation#2080
simon1hofmann wants to merge 14 commits into
codex/qco-dd-construction-deallocationfrom
codex/qco-dd-density-matrix

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Summary

Adds density-matrix execution as the final QCO DD functionality layer on top of #2079.

  • Construct referenced density-matrix DDs from pure states with validated qubit bounds and correct complex conjugation.
  • Simulate supported QCO programs as U ρ U†, including dynamic allocation, measurement, reset, classical control, and physically irrelevant global-phase cancellation.
  • Deallocate entangled qubits and Qtensors through a physical partial trace while preserving wire mappings.
  • Correct normalized partial trace and node renumbering when MatrixDDs omit identity levels.
  • Sample pure and mixed density states, deferring terminal measurements while retaining per-shot execution for dynamic and callee-measurement cases.
  • Expose make_density_matrix, simulate_density, and sample_density in Python with live-reference/package validation and a documented exact initial-register contract.
  • Consume input matrix references consistently on success, failure, and zero-shot paths. Validate density inputs on every path, seed root-call tracking, translate invalid Python arguments to ValueError, and report invalid density probabilities through normal MLIR failures.

This final QCO DD layer follows #1915, #1973, and #2077#2079.

Validation

  • Focused QCO utility binary: 180/180 tests passed.
  • DD package tests: 281/281 passed, including 11/11 trace-focused tests.
  • Focused Python QCO DD tests: 15/15 passed against rebuilt bindings.
  • Commit hooks and git diff --check passed.

GPT-5.6 via Codex materially assisted with implementation, testing, review, and stack restructuring under maintainer direction. Maintainer review remains required.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

@simon1hofmann simon1hofmann changed the title codex/qco dd density matrix ✨ Add QCO density-matrix DD simulation Aug 13, 2026
@simon1hofmann simon1hofmann added enhancement Improvement of existing feature DD Anything related to the DD package c++ Anything related to C++ code MLIR Anything related to MLIR python Anything related to Python code labels Aug 13, 2026
@simon1hofmann simon1hofmann added this to the MLIR Support milestone Aug 13, 2026
@simon1hofmann simon1hofmann self-assigned this Aug 13, 2026
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch from deee3fa to 9b0bd0e Compare August 13, 2026 10:51
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch 2 times, most recently from 6a5d936 to d721d90 Compare August 13, 2026 11:14
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch 2 times, most recently from 1610209 to 2cc1383 Compare August 13, 2026 11:24
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from d721d90 to f018bc5 Compare August 13, 2026 11:24
@mergify mergify Bot added the conflict label Aug 13, 2026
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from f018bc5 to ee78dbd Compare August 13, 2026 12:21
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch from 2cc1383 to 24e5bf7 Compare August 13, 2026 12:21
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from ee78dbd to 878256e Compare August 13, 2026 12:23
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch 2 times, most recently from 660ed03 to 9f92f1d Compare August 13, 2026 12:26
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from 878256e to 19d2a47 Compare August 13, 2026 12:26
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch 2 times, most recently from 9c1a42e to c7dd051 Compare August 13, 2026 12:51
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from 500a038 to 3ac809d Compare August 13, 2026 12:51
@mergify mergify Bot removed the conflict label Aug 13, 2026
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch from c7dd051 to 759e359 Compare August 13, 2026 14:27
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch 2 times, most recently from 69621de to 2a0aad6 Compare August 13, 2026 15:11
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch from 759e359 to 8f994f8 Compare August 13, 2026 15:11
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from 2a0aad6 to 9a3981a Compare August 13, 2026 16:36
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from 5112cf9 to bcde134 Compare August 31, 2026 16:20
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch from 2591ca2 to 1040ed9 Compare August 31, 2026 16:59
Assisted-by: GPT-5.6 via Codex
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from bcde134 to 7080496 Compare August 31, 2026 17:43
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch from 1040ed9 to aa7f7f2 Compare August 31, 2026 17:48
simon1hofmann and others added 6 commits August 31, 2026 20:22
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from c7b62f6 to 8caa3b7 Compare August 31, 2026 18:27
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
Assisted-by: GPT-5.6 via Codex
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-density-matrix branch from aa7f7f2 to 621f909 Compare August 31, 2026 18:29
@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from 8caa3b7 to bdce626 Compare September 1, 2026 08:57
@mergify mergify Bot added the conflict label Sep 1, 2026
@burgholzer

Copy link
Copy Markdown
Member

I think it is almost save to say that we can close this for now. Density matrix simulation is not a priority for now and has actually been moved out of the DD package into DDSIM for v4. I believe it does not make too much sense to add it back now for the MLIR part of the code base.
If you agree @simon1hofmann, then let's close this and remove this PR from the existing PR stack.

@simon1hofmann
simon1hofmann force-pushed the codex/qco-dd-construction-deallocation branch from bdce626 to eab1c1d Compare September 1, 2026 11:26
@simon1hofmann

simon1hofmann commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

I think it is almost save to say that we can close this for now. Density matrix simulation is not a priority for now and has actually been moved out of the DD package into DDSIM for v4. I believe it does not make too much sense to add it back now for the MLIR part of the code base. If you agree @simon1hofmann, then let's close this and remove this PR from the existing PR stack.

Just cross-checked with #2288, but seems like we do not really need it, will close this PR and restack #2288 onto #2079.

@mergify mergify Bot removed the conflict label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Anything related to C++ code DD Anything related to the DD package enhancement Improvement of existing feature MLIR Anything related to MLIR python Anything related to Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants