Skip to content

create_device_from_processor_id #5303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

95-martin-orion
Copy link
Collaborator

Adds a convenience method for creating a device from a processor ID.

This is useful for creating virtual engines using non-Cirq simulators (like qsim), since we can't directly reference those simulators in cirq code. For example:

sim = qsimcirq.QSimSimulator()
device = create_device_from_processor_id(processor_id)
sim_processor = cirq_google.engine.SimulatedLocalProcessor(
    processor_id=processor_id, sampler=sim, device=device,
)
sim_engine = cirq_google.engine.SimulatedLocalEngine([sim_processor])

@95-martin-orion 95-martin-orion requested review from wcourtney, a team, vtomole and cduck as code owners April 28, 2022 21:29
@CirqBot CirqBot added the size: S 10< lines changed <50 label Apr 28, 2022
@@ -206,6 +206,30 @@ def _create_device_spec_from_template(template_name: str) -> v2.device_pb2.Devic
return device_spec


def create_device_from_processor_id(
processor_id: str,
gate_sets: Optional[Iterable[serializable_gate_set.SerializableGateSet]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommend omitting this arg and always set the gateset to FSIM_GATESET. The new Device implementation (cirq_google.GridDevice) will not have gatesets as a parameter to from_proto.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@95-martin-orion 95-martin-orion merged commit 292f757 into quantumlib:master Apr 29, 2022
@95-martin-orion 95-martin-orion deleted the cirq-realnoise-docs branch April 29, 2022 15:58
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* get_device_from_processor_id

* Remove py3.8 feature

* FSIM_GATESET only

* [FSIM_GATESET]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants