1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14- from typing import List , cast , Optional , Union , Dict , Any
14+ from typing import List , Optional , Union , Dict , Any
1515import functools
1616from math import sqrt
17- import httpx
17+ import json
1818import numpy as np
1919import networkx as nx
2020import cirq
2121from pyquil .quantum_processor import QCSQuantumProcessor
22- from qcs_api_client .models import InstructionSetArchitecture
23- from qcs_api_client .operations .sync import get_instruction_set_architecture
24- from cirq_rigetti ._qcs_api_client_decorator import _provide_default_client
22+ from qcs_sdk .client import QCSClient
23+ from qcs_sdk .qpu .isa import get_instruction_set_architecture , InstructionSetArchitecture , Family
2524
2625
2726class UnsupportedQubit (ValueError ):
@@ -50,6 +49,8 @@ class UnsupportedRigettiQCSQuantumProcessor(ValueError):
5049class RigettiQCSAspenDevice (cirq .devices .Device ):
5150 """A cirq.Qid supporting Rigetti QCS Aspen device topology."""
5251
52+ isa : InstructionSetArchitecture
53+
5354 def __init__ (self , isa : Union [InstructionSetArchitecture , Dict [str , Any ]]) -> None :
5455 """Initializes a RigettiQCSAspenDevice with its Rigetti QCS `InstructionSetArchitecture`.
5556
@@ -63,9 +64,9 @@ def __init__(self, isa: Union[InstructionSetArchitecture, Dict[str, Any]]) -> No
6364 if isinstance (isa , InstructionSetArchitecture ):
6465 self .isa = isa
6566 else :
66- self .isa = InstructionSetArchitecture .from_dict ( isa )
67+ self .isa = InstructionSetArchitecture .from_raw ( json . dumps ( isa ) )
6768
68- if self .isa .architecture .family . lower () != 'aspen' :
69+ if self .isa .architecture .family != Family . Aspen :
6970 raise UnsupportedRigettiQCSQuantumProcessor (
7071 'this integration currently only supports Aspen devices, '
7172 f'but client provided a { self .isa .architecture .family } device'
@@ -224,23 +225,22 @@ def __repr__(self):
224225 return f'cirq_rigetti.RigettiQCSAspenDevice(isa={ self .isa !r} )'
225226
226227 def _json_dict_ (self ):
227- return {'isa' : self .isa .to_dict ( )}
228+ return {'isa' : json . loads ( self .isa .json () )}
228229
229230 @classmethod
230231 def _from_json_dict_ (cls , isa , ** kwargs ):
231- return cls (isa = InstructionSetArchitecture .from_dict ( isa ))
232+ return cls (isa = InstructionSetArchitecture .from_raw ( json . dumps ( isa ) ))
232233
233234
234- @_provide_default_client # pragma: no cover
235235def get_rigetti_qcs_aspen_device (
236- quantum_processor_id : str , client : Optional [httpx . Client ]
236+ quantum_processor_id : str , client : Optional [QCSClient ] = None
237237) -> RigettiQCSAspenDevice :
238238 """Retrieves a `qcs_api_client.models.InstructionSetArchitecture` from the Rigetti
239239 QCS API and uses it to initialize a RigettiQCSAspenDevice.
240240
241241 Args:
242242 quantum_processor_id: The identifier of the Rigetti QCS quantum processor.
243- client: Optional; A `httpx.Client ` initialized with Rigetti QCS credentials
243+ client: Optional; A `QCSClient ` initialized with Rigetti QCS credentials
244244 and configuration. If not provided, `qcs_api_client` will initialize a
245245 configured client based on configured values in the current user's
246246 `~/.qcs` directory or default values.
@@ -250,12 +250,7 @@ def get_rigetti_qcs_aspen_device(
250250 set and architecture.
251251
252252 """
253- isa = cast (
254- InstructionSetArchitecture ,
255- get_instruction_set_architecture (
256- client = client , quantum_processor_id = quantum_processor_id
257- ).parsed ,
258- )
253+ isa = get_instruction_set_architecture (client = client , quantum_processor_id = quantum_processor_id )
259254 return RigettiQCSAspenDevice (isa = isa )
260255
261256
0 commit comments