Skip to content

Document dispatch! behavior for shared blocks - #591

Open
GiggleLiu wants to merge 1 commit into
masterfrom
automanage/document-dispatch-aliases
Open

GiggleLiu wants to merge 1 commit into
masterfrom
automanage/document-dispatch-aliases

Conversation

@GiggleLiu

Copy link
Copy Markdown
Member

dispatch! walks every occurrence in a circuit and mutates its parameterized blocks. When repeated layers share the same underlying gate objects, later parameter slices overwrite the earlier values, while non-mutating dispatch rebuilds independent occurrences.

Document this aliasing constraint and the supported remedies: construct/deep-copy each occurrence before in-place dispatch, or use dispatch.

Closes #568.

Validation:

  • reproduced the report on Yao 0.9.2: one layer matches, while two shared layers differ between dispatch! and dispatch
  • verified independently deep-copied layers make dispatch! and dispatch agree (norm == 0.0)
  • git diff --check

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.22%. Comparing base (8f17bfb) to head (9fc1379).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #591   +/-   ##
=======================================
  Coverage   89.22%   89.22%           
=======================================
  Files          89       89           
  Lines        5855     5855           
=======================================
  Hits         5224     5224           
  Misses        631      631           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

The inplace dispatch! function works incorrectly (inconsistently with dispatch) for some circuits

1 participant