{"id":9579,"library":"cirq-google","title":"Cirq Google Plugin","description":"Cirq Google (`cirq-google`) is the module for the Cirq quantum computing framework that provides tools and access to the Google Quantum Computing Service. It enables users to run quantum circuits on Google's quantum processors and high-performance simulators. The current version is 1.6.1, and it typically releases new versions in sync with the main `cirq` library, which has a release cadence of monthly/bi-monthly patches and quarterly minor versions.","status":"active","version":"1.6.1","language":"en","source_language":"en","source_url":"https://github.com/quantumlib/cirq","tags":["quantum computing","google cloud","cirq","hardware","quantum engine","qcvs"],"install":[{"cmd":"pip install cirq cirq-google","lang":"bash","label":"Install Cirq Google"}],"dependencies":[{"reason":"cirq-google is a plugin for the core Cirq library and requires it to be installed.","package":"cirq"},{"reason":"Requires Python version 3.11 or newer since cirq v1.6.0.","package":"python","optional":false}],"imports":[{"note":"The primary entry point for interacting with Google's Quantum Engine.","symbol":"QuantumEngine","correct":"from cirq_google import QuantumEngine"},{"note":"Example of importing a specific Google quantum device model.","symbol":"Sycamore","correct":"from cirq_google.devices import Sycamore"}],"quickstart":{"code":"import cirq\nimport cirq_google\nimport os\n\n# Replace with your Google Cloud Project ID (e.g., 'your-project-id')\n# For local testing, any string can be used, but for actual hardware access,\n# it must be a valid GCP project ID with Quantum Engine API enabled.\nPROJECT_ID = os.environ.get(\"GOOGLE_CLOUD_PROJECT\", \"gcp-project-for-cirq-testing\")\n\ntry:\n    # Initialize the QuantumEngine client\n    # This assumes you have authenticated via 'gcloud auth application-default login'\n    # or set the GOOGLE_APPLICATION_CREDENTIALS environment variable.\n    print(f\"Attempting to initialize QuantumEngine for project: {PROJECT_ID}\")\n    engine = cirq_google.QuantumEngine(project_id=PROJECT_ID)\n    \n    # For quickstart, we'll try to use a local simulator\n    # For actual hardware/remote simulator usage, you would use:\n    # processor = engine.get_processor('willow_pink') # Example processor\n    # job = engine.run_circuit(program=circuit, processor_ids=[processor.name], repetitions=10)\n    # results = job.results()\n\n    # Define a simple circuit\n    qubit = cirq.GridQubit(0, 0)\n    circuit = cirq.Circuit(\n        cirq.H(qubit),\n        cirq.measure(qubit, key='m')\n    )\n\n    # Run the circuit on a local Cirq simulator for quick demonstration\n    print(\"Running circuit on local Cirq simulator...\")\n    simulator = cirq.Simulator()\n    results = simulator.run(circuit, repetitions=10)\n    print(\"Local simulation results:\")\n    print(results)\n\nexcept Exception as e:\n    print(f\"Could not initialize QuantumEngine or connect to remote resources ({e}).\")\n    print(\"Falling back to local Cirq simulator for demonstration.\")\n    \n    # Define a simple circuit\n    qubit = cirq.GridQubit(0, 0)\n    circuit = cirq.Circuit(\n        cirq.H(qubit),\n        cirq.measure(qubit, key='m')\n    )\n\n    # Run the circuit on a local Cirq simulator\n    simulator = cirq.Simulator()\n    results = simulator.run(circuit, repetitions=10)\n    print(\"Local simulation results (fallback):\")\n    print(results)\n","lang":"python","description":"This quickstart demonstrates how to initialize the `QuantumEngine` client and run a simple Cirq circuit. For actual remote execution, ensure your Google Cloud environment is authenticated and `GOOGLE_CLOUD_PROJECT` (or a hardcoded project ID) is correctly configured. The example includes a fallback to a local Cirq simulator for immediate runnability without a full GCP setup."},"warnings":[{"fix":"For new projects, avoid `cirq-rigetti`. For legacy code, pin `cirq-rigetti==1.5.0` and `cirq<1.6.0` or update your code to use the standalone `pyquil` library if applicable. `cirq-rigetti` was deprecated in v1.5.0 and removed in v1.6.0.","message":"Cirq-Rigetti subpackage has been removed. If your project depends on `cirq-rigetti`, you must use an older version of Cirq (e.g., `cirq-rigetti-1.5.0`) or install `cirq-rigetti` explicitly if available.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Upgrade your Python environment to 3.11.0 or higher. For example, using `pyenv install 3.11.8` and `pyenv local 3.11.8` or `conda install python=3.11`.","message":"The minimum required Python version has been increased to 3.11.0. Older Python versions (e.g., 3.10 or earlier) are no longer supported.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"For fault-tolerant quantum algorithm resource estimation, use the `Qualtran` library directly from `https://github.com/quantumlib/Qualtran.git`. `cirq-ft` was deprecated in v1.3.0 and removed in v1.4.0.","message":"The `cirq-ft` package was removed. Its functionality has moved to the `Qualtran` repository.","severity":"breaking","affected_versions":">=1.4.0"},{"fix":"Run `gcloud auth application-default login` in your terminal, or set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to a service account key JSON file. Ensure your GCP project has the Quantum Engine API enabled.","message":"Authentication to Google Quantum Engine requires setting up Google Cloud credentials. Without proper authentication, `cirq_google.QuantumEngine` initialization or usage will fail.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"If your code explicitly uses `cirq_rigetti`, you need to downgrade your cirq-google installation to version 1.5.0 or earlier (e.g., `pip install cirq-google==1.5.0`). Alternatively, refactor your code to use the standalone `pyquil` library.","cause":"The `cirq-rigetti` subpackage was removed starting from cirq-google v1.6.0.","error":"ModuleNotFoundError: No module named 'cirq_rigetti'"},{"fix":"If your code depends on `cirq_ft`, you need to install and use the `Qualtran` library directly from its GitHub repository (`https://github.com/quantumlib/Qualtran.git`). Alternatively, downgrade your `cirq-google` installation to `cirq-google<1.4.0` if you need the old `cirq-ft` functionality.","cause":"The `cirq-ft` package was removed from `cirq` and `cirq-google` starting from v1.4.0, as its functionality moved to the `Qualtran` library.","error":"ModuleNotFoundError: No module named 'cirq_ft'"},{"fix":"Upgrade your Python environment to version 3.11 or later. For example, create a new virtual environment with `python3.11 -m venv .venv` and activate it.","cause":"You are trying to install or run `cirq-google` (version 1.6.0 or newer) with an unsupported Python version (e.g., 3.10 or older).","error":"RuntimeError: Python version must be >= 3.11.0"},{"fix":"Ensure you are logged into Google Cloud via `gcloud auth application-default login` in your terminal, or set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to a valid service account key file. Also, verify that the specified GCP project ID is correct and has the Quantum Engine API enabled.","cause":"The Cirq Google client failed to authenticate with the Google Quantum Engine. This means Google Cloud credentials are not properly set up or are expired.","error":"cirq_google.engine.calibration.engine_client.QuantumEngineError: Could not find or validate client credentials."}]}