Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"). You 

4# may not use this file except in compliance with the License. A copy of 

5# the License is located at 

6# 

7# http://aws.amazon.com/apache2.0/ 

8# 

9# or in the "license" file accompanying this file. This file is 

10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 

11# ANY KIND, either express or implied. See the License for the specific 

12# language governing permissions and limitations under the License. 

13 

14from abc import ABC, abstractmethod 

15from typing import Optional, Union 

16 

17from braket.annealing.problem import Problem 

18from braket.circuits import Circuit 

19from braket.tasks.quantum_task import QuantumTask 

20 

21 

22class Device(ABC): 

23 """ An abstraction over quantum devices that includes quantum computers and simulators. 

24 

25 """ 

26 

27 def __init__(self, name: str, status: str, status_reason: str): 

28 """ 

29 Args: 

30 name: Name of quantum device 

31 status: Status of quantum device 

32 status_reason: Status reason of quantum device 

33 """ 

34 self._name = name 

35 self._status = status 

36 self._status_reason = status_reason 

37 

38 @abstractmethod 

39 def run( 

40 self, 

41 task_specification: Union[Circuit, Problem], 

42 location, 

43 shots: Optional[int], 

44 *args, 

45 **kwargs 

46 ) -> QuantumTask: 

47 """ Run a quantum task specification on this quantum device. A task can be a circuit 

48 or an annealing problem. 

49 

50 Args: 

51 task_specification (Union[Circuit, Problem]): Specification of a task 

52 to run on device. 

53 

54 location: The location to save the task's results 

55 

56 shots (int): The number of times to run the task on the device. Default is 1_000. 

57 

58 Returns: 

59 QuantumTask: The QuantumTask tracking task execution on this device 

60 """ 

61 

62 @property 

63 def name(self) -> str: 

64 """ Return the name of this Device. 

65 

66 Returns: 

67 str: The name of this Device 

68 """ 

69 return self._name 

70 

71 @property 

72 def status(self) -> str: 

73 """ Return the status of this Device. 

74 

75 Returns: 

76 str: The status of this Device 

77 """ 

78 return self._status 

79 

80 @property 

81 def status_reason(self) -> str: 

82 """ Return the status reason of this Device. 

83 

84 Returns: 

85 str: The reason that the device is in the current status 

86 """ 

87 return self._status_reason