Skip to content

Add get config functions #7565

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

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

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 (5327175) to head (4a03de1).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #7565    +/-   ##
========================================
  Coverage   97.50%   97.51%            
========================================
  Files        1103     1105     +2     
  Lines       99652    99984   +332     
========================================
+ Hits        97166    97496   +330     
- Misses       2486     2488     +2     

☔ 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

) -> 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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can remove this line now that we have the default argument for run_name, or mention something about how we will use an internally-configured default run if left unspecified. Here and in the overrides.

) -> 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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update to talk about the default args

) -> processor_config.ProcessorConfig | None:
"""Retrieves a ProcessorConfig from an automation run.

If no run name is provided, the config from the most recent run
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update to mention default args

@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)

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