Consider creating a builder class for constructing circuits?

Open
#6,050 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Read the linked discussions in issues #3246 and #2775, then review PR #6013 and get_earliest_accommodating_moment_index. Trace how Circuit._load_contents_with_earliest_strategy and _stratify_circuit construct circuits. Done means deciding where the utility belongs and defining a builder that generalizes it for both construction paths.

Written by the indexing model from the issue text.

Description

area/circuits kind/design-issue kind/health skill/expert status/needs-agreed-design triage/needs-more-evidence

Description of the issue
We have often discussed in the past the need for a builder pattern for constructing circuits, for example see https://github.com/quantumlib/Cirq/issues/3246 and https://github.com/quantumlib/Cirq/issues/2775.

https://github.com/quantumlib/Cirq/pull/6013 made a first attempt of abstracting out an important piece of circuit construction code into a free function - get_earliest_accommodating_moment_index.

This issue to discuss:

  1. Where to best put the free function get_earliest_accommodating_moment_index.
  2. Create a new circuit builder class that can generalize the utility provided by get_earliest_accommodating_moment_index and can be used in both Circut._load_contents_with_earliest_strategy and _stratify_circuit for efficiently constructing new circuits.

Cirq version

1.2.0.dev
Dominant language
Python
Stars
5.1k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
48

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quantumlib/Cirq

All issues in quantumlib/Cirq

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.