Skip to content
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
77eec1a
Add `ProcessorConfig` and `ProcessorConfigSnapshot`
dyates Jul 7, 2025
69f1397
Update __init__; Add another unit test.
dyates Jul 7, 2025
a8e8262
Merge branch 'main' into add_get_config_snapshot
dyates Jul 7, 2025
df98f15
Regenerates QuantumEngineService gRPC client libraries with GAPIC
hoisinberg Jul 16, 2025
5fb5fbc
Merge branch 'main' into add_get_config_snapshot
dyates Jul 21, 2025
3b29858
Merge remote-tracking branch 'upstream/u/hoisinberg/get-quantum-proce…
dyates Jul 21, 2025
71dad68
Merge branch 'main' into add_get_config_snapshot
dyates Jul 23, 2025
7cbcdc1
Merge branch 'main' into add_get_config_snapshot
dyates Jul 29, 2025
6866f26
Add `get_quantum_processor_config_by_snapshot_id`
dyates Jul 30, 2025
20ca033
Add unit test for missing config.
dyates Jul 30, 2025
b3413a4
Add `get_quantum_processor_config_by_run_name`.
dyates Jul 30, 2025
eed577d
Implement `get_config` for `ProcessorConfigSnapshot`.
dyates Jul 31, 2025
cc447ff
Add `get_config*` functions to EngineProcessor.
dyates Aug 4, 2025
c30bde8
Sync changes
dyates Aug 5, 2025
b1ef097
Merge branch 'main' into add_get_config_snapshot
dyates Aug 5, 2025
2eb9ee9
Add `AbstractProcessorConfig` interface.
dyates Aug 8, 2025
aee07e6
Add `get_config*` methods to the `Engine` class.
dyates Aug 8, 2025
bc7db00
Merge branch 'main' into add_get_config_snapshot
dyates Aug 8, 2025
9e2fdcd
Add missing methods from other abstract engines and processors.
dyates Aug 8, 2025
cc4b43e
Add test for __repr__; Remove config logic from LocalAbstractEnginer.
dyates Aug 11, 2025
6835a61
Update imports.
dyates Aug 11, 2025
e96871c
Fix more formatting errors.
dyates Aug 11, 2025
e2429c3
Update test and linting errors.
dyates Aug 11, 2025
093cd1e
More formatting fixes.
dyates Aug 11, 2025
11d97f5
More fixes.
dyates Aug 11, 2025
2365a57
Fix test name
dyates Aug 11, 2025
67cabf4
More syntax errors.
dyates Aug 11, 2025
afe7f0e
More formatting fixes.
dyates Aug 11, 2025
947ad46
Fix remaining format issues
dyates Aug 11, 2025
4783519
Add missing documentation.
dyates Aug 11, 2025
3d1e101
Merge branch 'main' into add_get_config_functions
dyates Aug 15, 2025
1505ba8
Rename parameters and functioncs for consistency.
dyates Aug 15, 2025
f7bba28
Fix function params in AbstractLocalEngine
dyates Aug 15, 2025
f15e751
More `check/` fixes.
dyates Aug 15, 2025
449fdd4
More check fixes.
dyates Aug 15, 2025
d259f1a
Merge branch 'main' into add_get_config_functions
dyates Aug 22, 2025
6eba4b4
Address new comments.
dyates Aug 22, 2025
cd81646
Remove unused imports.
dyates Aug 22, 2025
4a03de1
Update import format.
dyates Aug 22, 2025
000ce5d
Update doc comments to mention default configs.
dyates Aug 25, 2025
00e2f36
Merge branch 'main' into add_get_config_functions
dyates Aug 25, 2025
4584bff
Remove N/A changes.
dyates Aug 25, 2025
a89213e
Remove changes to simulated_* engine files.
dyates Aug 25, 2025
f9ef67a
Change `config_alias` to `config_name`.
dyates Aug 29, 2025
7059f1a
Merge branch 'main' into add_get_config_functions
dyates Aug 29, 2025
32ad541
Remove config functions from local processor unit test.
dyates Aug 29, 2025
2ef6805
Format fixes.
dyates Aug 29, 2025
0a863fd
Merge branch 'main' into add_get_config_functions
dyates Sep 12, 2025
54cc85c
Adress final comments; Use existing id functions; Remove unused confi…
dyates Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cirq-google/cirq_google/cloud/quantum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from cirq_google.cloud.quantum import gapic_version as package_version

__version__ = package_version.__version__


from cirq_google.cloud.quantum_v1alpha1.services.quantum_engine_service.client import (
QuantumEngineServiceClient,
Expand Down
16 changes: 16 additions & 0 deletions cirq-google/cirq_google/cloud/quantum/gapic_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.0.0" # {x-release-please-version}
4 changes: 4 additions & 0 deletions cirq-google/cirq_google/cloud/quantum_v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from . import gapic_version as package_version

__version__ = package_version.__version__


from .services.quantum_engine_service import QuantumEngineServiceClient
from .services.quantum_engine_service import QuantumEngineServiceAsyncClient
Expand Down
16 changes: 16 additions & 0 deletions cirq-google/cirq_google/cloud/quantum_v1alpha1/gapic_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.0.0" # {x-release-please-version}
6 changes: 6 additions & 0 deletions cirq-google/cirq_google/engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

from cirq_google.engine.abstract_processor import AbstractProcessor as AbstractProcessor

from cirq_google.engine.abstract_processor_config import (
AbstractProcessorConfig as AbstractProcessorConfig,
)

from cirq_google.engine.abstract_program import AbstractProgram as AbstractProgram

from cirq_google.engine.abstract_local_engine import AbstractLocalEngine as AbstractLocalEngine
Expand Down Expand Up @@ -95,3 +99,5 @@
from cirq_google.engine.engine_result import EngineResult as EngineResult

from cirq_google.engine.processor_sampler import ProcessorSampler as ProcessorSampler

from cirq_google.engine.processor_config import ProcessorConfig as ProcessorConfig
39 changes: 38 additions & 1 deletion cirq-google/cirq_google/engine/abstract_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
if TYPE_CHECKING:
import cirq
from cirq_google.cloud import quantum
from cirq_google.engine import abstract_job, abstract_processor, abstract_program
from cirq_google.engine import (
abstract_job,
abstract_processor,
abstract_processor_config,
abstract_program,
)

VALID_DATE_TYPE = datetime.datetime | datetime.date

Expand Down Expand Up @@ -134,3 +139,35 @@ def get_sampler(self, processor_id: str | list[str]) -> cirq.Sampler:
processor_id: String identifier, or list of string identifiers,
determining which processors may be used when sampling.
"""

@abc.abstractmethod
def get_processor_config_by_snapshot_id(
self, processor_id: str, snapshot_id: str, config_id: str
) -> abstract_processor_config.AbstractProcessorConfig | None:
"""Returns a ProcessorConfig from this project and the given processor id.

Args:
processor_id: The processor unique identifier.
snapshot_id: The unique identifier for the snapshot.
config_id: The unique identifier for the snapshot.

Returns:
The ProcessorConfig from this project and processor.
"""

@abc.abstractmethod
def get_processor_config_by_run_name(
self, processor_id: str, config_id: str, run_name: str = 'current'
) -> abstract_processor_config.AbstractProcessorConfig | None:
"""Returns a ProcessorConfig from this project and the given processor id.

If no run_name is provided, the config from the most recent run is returned.

Args:
processor_id: The processor unique identifier.
run_name: The unique identifier for the automation run.
config_id: The unique identifier for the snapshot.

Returns:
The ProcessorConfig from this project and processor.
"""
12 changes: 12 additions & 0 deletions cirq-google/cirq_google/engine/abstract_local_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,15 @@ def get_sampler(self, processor_id: str | list[str]) -> cirq.Sampler:
if not isinstance(processor_id, str):
raise ValueError(f'Invalid processor {processor_id}')
return self._processors[processor_id].get_sampler()

def get_processor_config_by_snapshot_id(
self, processor_id: str, snapshot_id: str, config_id: str
):
# TODO: Implement later as needed.
pass

def get_processor_config_by_run_name(
self, processor_id: str, config_id: str, run_name: str = 'current'
):
# TODO: Implement later as needed.
pass
6 changes: 6 additions & 0 deletions cirq-google/cirq_google/engine/abstract_local_engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def list_programs(
def get_program(self, program_id: str) -> AbstractProgram:
return self._programs[program_id]

def get_config_by_run_name(self, *args, **kwargs):
pass

def get_config_by_snapshot(self, *args, **kwargs):
pass


class NothingEngine(AbstractLocalEngine):
"""Engine for Testing."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ def list_programs(self, *args, **kwargs):
def get_program(self, *args, **kwargs):
pass

def get_config_by_run_name(self, config_id: str, run_name: str = "current"):
pass

def get_config_by_snapshot(self, config_id: str, snapshot_id: str):
pass


def test_datetime():
recovery_time = datetime.datetime.now()
Expand Down
33 changes: 33 additions & 0 deletions cirq-google/cirq_google/engine/abstract_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import cirq_google.engine.abstract_engine as abstract_engine
import cirq_google.engine.abstract_job as abstract_job
import cirq_google.engine.calibration as calibration
from cirq_google.engine import abstract_processor_config


class AbstractProcessor(abc.ABC):
Expand Down Expand Up @@ -377,3 +378,35 @@ def get_schedule(
Returns:
Schedule time slots.
"""

@abc.abstractmethod
def get_config_by_run_name(
self, config_id: str, run_name: str = "current"
) -> abstract_processor_config.AbstractProcessorConfig | None:
"""Retrieves a ProcessorConfig from an automation run.

If no run name is provided, the config from the most recent run
is returned.

Args:
processor_id: The processor unique identifier.
config_id: The quantum processor's unique identifier.
run_name: The automation run name. Use 'current'
if none id provided.

Returns: The quantum processor config.
"""

@abc.abstractmethod
def get_config_by_snapshot(
self, config_id: str, snapshot_id: str
) -> abstract_processor_config.AbstractProcessorConfig | None:
"""Retrieves a ProcessorConfig from a given snapshot id.

Args:
processor_id: The processor unique identifier.
config_id: The quantum processor's unique identifier.
snapshot_id: The snapshot's unique identifier.

Returns: The quantum processor config.
"""
65 changes: 65 additions & 0 deletions cirq-google/cirq_google/engine/abstract_processor_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2025 The Cirq Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import abc
from typing import TYPE_CHECKING

if TYPE_CHECKING:
import cirq
import cirq_google as cg


class AbstractProcessorConfig(abc.ABC):
"""Interface for a QuantumProcessorConfig.

Describes available qubits, gates, and calivration data associated with
a processor configuration.
"""

@property
@abc.abstractmethod
def effective_device(self) -> cirq.Device:
"""The Device generated from thi configuration's device specification"""

@property
@abc.abstractmethod
def calibration(self) -> cg.Calibration:
"""Charicterization metrics captured for this configuration"""

@property
@abc.abstractmethod
def snapshot_id(self) -> str:
"""The snapshot that contains this processor config"""

@property
@abc.abstractmethod
def run_name(self) -> str:
"""The run that generated this config if avaiable."""

@property
@abc.abstractmethod
def project_id(self) -> str:
"""The if of the project that contains this config."""

@property
@abc.abstractmethod
def processor_id(self) -> str:
"""The processor id for this config."""

@property
@abc.abstractmethod
def config_id(self) -> str:
"""The unique identifier for this config."""
56 changes: 56 additions & 0 deletions cirq-google/cirq_google/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
engine_job,
engine_processor,
engine_program,
processor_config,
util,
)
from cirq_google.serialization import CIRCUIT_SERIALIZER, Serializer
Expand Down Expand Up @@ -623,6 +624,61 @@ def get_sampler(
max_concurrent_jobs=max_concurrent_jobs,
)

async def get_processor_config_by_snapshot_id_async(
self, processor_id: str, snapshot_id: str, config_id: str
) -> processor_config.ProcessorConfig | None:
"""Returns a ProcessorConfig from this project and the given processor id.

Args:
processor_id: The processor unique identifier.
snapshot_id: The unique identifier for the snapshot.
config_id: The unique identifier for the snapshot.

Returns:
The ProcessorConfig from this project and processor.
"""
client = self.context.client
quantum_config = await client.get_quantum_processor_config_by_snapshot_id_async(
project_id=self.project_id,
processor_id=processor_id,
snapshot_id=snapshot_id,
config_id=config_id,
)
if quantum_config:
return processor_config.ProcessorConfig(quantum_processor_config=quantum_config)
return None

get_processor_config_by_snapshot_id = duet.sync(get_processor_config_by_snapshot_id_async)

async def get_processor_config_by_run_name_async(
self, processor_id: str, config_id: str, run_name: str = 'current'
) -> processor_config.ProcessorConfig | None:
"""Returns a ProcessorConfig from this project and the given processor id.

If no run_name is provided, the config from the most recent run is returned.

Args:
processor_id: The processor unique identifier.
run_name: The unique identifier for the automation run.
config_id: The unique identifier for the snapshot.

Returns:
The ProcessorConfig from this project and processor.
"""
quantum_config = await self.context.client.get_quantum_processor_config_by_run_name_async(
project_id=self.project_id,
processor_id=processor_id,
run_name=run_name,
config_id=config_id,
)
if quantum_config:
return processor_config.ProcessorConfig(
quantum_processor_config=quantum_config, run_name=run_name
)
return None

get_processor_config_by_run_name = duet.sync(get_processor_config_by_run_name_async)


def get_engine(project_id: str | None = None) -> Engine:
"""Get an Engine instance assuming some sensible defaults.
Expand Down
Loading