Skip to content

Conversation

dyates
Copy link
Contributor

@dyates dyates commented Aug 8, 2025

Adds the ability to retrieve a QuantumProcessorConfig from a project. There are two ways to retrieve processor configs: from the Engine or an EngineProcessor.

Here is an example using the processor:

engine = cirq_google.get_engine('my-project')
processor = engine.get_processor('my-processor')

run_name_config = processor.get_config_by_run_name(run_name="abc", config_id="123")
current_config = processor.get_config_by_run_name(config_id="123")
snapshot_config = processor.get_config_by_snapshot_id(snapshot_id="xyz", config_id="123")

Here is an example getting the config directly from the Engine:

engine = cirq_google.get_engine('my-project')
processor_id = 'my-processor'

run_name_config = engine.get_config_by_run_name(
    processor_id=processor_id, run_name="abc", config_id="123"
)
current_config = engine.get_config_by_run_name(
    processor_id=processor_id, config_id="123"
)
snapshot_config = engine.get_config_by_snapshot_id(
    processor_id=processor_id, snapshot_id="xyz", config_id="123"
)

@dyates dyates requested review from wcourtney, vtomole, verult and a team as code owners August 8, 2025 22:54
@github-actions github-actions bot added the size: XL lines changed >1000 label Aug 8, 2025
@dyates
Copy link
Contributor Author

dyates commented Aug 11, 2025

I'm working on fixing the errors. Some missing tests/logic for a few edge cases.

Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.51%. Comparing base (60cbc49) to head (2ef6805).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #7565    +/-   ##
========================================
  Coverage   97.50%   97.51%            
========================================
  Files        1103     1105     +2     
  Lines       99683   100007   +324     
========================================
+ Hits        97198    97521   +323     
- Misses       2485     2486     +1     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove

@hoisinberg
Copy link
Collaborator

I've verified that this works fully end-to-end with a colab containing the following code:

import cirq
import cirq_google
from cirq_google.engine.qcs_notebook import authenticate_user

authenticate_user()
engine = cirq_google.get_engine('quantum-michaelbq')
processor_id = 'WIL01_9A_BLACK'
run_name = 'current'
config_alias = 'cz_8'

print("Get config from engine")
config = engine.get_processor_config_from_run(processor_id=processor_id, run_name=run_name, config_alias=config_alias)
print(config.effective_device)

print("Get config from processor object")
config = engine.get_processor(processor_id).get_config_from_run(run_name=run_name, config_alias=config_alias)
print(config.effective_device)

@@ -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_from_snapshot(
self, processor_id: str, snapshot_id: str, config_alias: str = 'default'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Final nit: let's change config_alias to config_name here and throughout.

Copy link
Collaborator

@hoisinberg hoisinberg left a comment

Choose a reason for hiding this comment

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

Looks good on my part. Looks like there are just a couple of comments left from Will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: XL lines changed >1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants