@@ -21,22 +21,12 @@ std::string prepareOpenQasm(std::string source) {
21
21
22
22
namespace cudaq {
23
23
24
- std::string getDeviceArn (const std::string &machine) {
25
- if (machine.starts_with (" arn:aws:braket" )) {
24
+ std::string checkDeviceArn (const std::string &machine) {
25
+ if (machine.starts_with (" arn:aws:braket" ))
26
26
return machine;
27
- }
28
-
29
- if (deviceArns.contains (machine)) {
30
- return deviceArns.at (machine);
31
- }
32
-
33
- std::string knownMachines;
34
- for (const auto &machine : deviceArns)
35
- knownMachines += machine.first + " " ;
36
- const auto errorMessage =
37
- fmt::format (" Machine \" {}\" is invalid. Machine must be either an Amazon "
38
- " Braket device ARN or one of the known devices: {}" ,
39
- machine, knownMachines);
27
+ const auto errorMessage = fmt::format (" Machine \" {}\" is invalid. Machine "
28
+ " must be an Amazon Braket device ARN." ,
29
+ machine);
40
30
throw std::runtime_error (errorMessage);
41
31
}
42
32
@@ -51,31 +41,25 @@ BraketServerHelper::getValueOrDefault(const BackendConfig &config,
51
41
// Initialize the Braket server helper with a given backend configuration
52
42
void BraketServerHelper::initialize (BackendConfig config) {
53
43
cudaq::info (" Initializing Amazon Braket backend." );
54
-
55
44
// Fetch machine info before checking emulate because we want to be able to
56
- // emulate specific machines.
57
- auto machine = getValueOrDefault (config, " machine" , SV1);
58
- auto deviceArn = getDeviceArn (machine);
45
+ // emulate specific machines, defaults to state vector simulator
46
+ auto machine =
47
+ getValueOrDefault (config, " machine" ,
48
+ " arn:aws:braket:::device/quantum-simulator/amazon/sv1" );
49
+ auto deviceArn = checkDeviceArn (machine);
59
50
cudaq::info (" Running on device {}" , deviceArn);
60
-
61
51
config[" defaultBucket" ] = getValueOrDefault (config, " default_bucket" , " " );
62
52
config[" deviceArn" ] = deviceArn;
63
- config[" qubits" ] = deviceQubitCounts.contains (deviceArn)
64
- ? deviceQubitCounts.at (deviceArn)
65
- : DEFAULT_QUBIT_COUNT;
66
53
if (!config[" shots" ].empty ())
67
54
this ->setShots (std::stoul (config[" shots" ]));
68
-
69
55
const auto emulate_it = config.find (" emulate" );
70
56
if (emulate_it != config.end () && emulate_it->second == " true" ) {
71
57
cudaq::info (" Emulation is enabled, ignore all Amazon Braket connection "
72
58
" specific information." );
73
59
backendConfig = std::move (config);
74
60
return ;
75
61
}
76
-
77
62
parseConfigForCommonParams (config);
78
-
79
63
// Move the passed config into the member variable backendConfig
80
64
backendConfig = std::move (config);
81
65
};
@@ -90,25 +74,19 @@ BraketServerHelper::createJob(std::vector<KernelExecution> &circuitCodes) {
90
74
ServerMessage taskRequest;
91
75
taskRequest[" name" ] = circuitCode.name ;
92
76
taskRequest[" deviceArn" ] = backendConfig.at (" deviceArn" );
93
-
94
- taskRequest[" qubits" ] = backendConfig.at (" qubits" );
95
77
taskRequest[" input" ][" format" ] = " qasm2" ;
96
78
taskRequest[" input" ][" data" ] = circuitCode.code ;
97
-
98
79
auto action = nlohmann::json::parse (
99
80
" {\" braketSchemaHeader\" : {\" name\" : \" braket.ir.openqasm.program\" , "
100
81
" \" version\" : \" 1\" }, \" source\" : \"\" , \" inputs\" : {}}" );
101
82
action[" source" ] = prepareOpenQasm (circuitCode.code );
102
83
taskRequest[" action" ] = action.dump ();
103
84
taskRequest[" shots" ] = shots;
104
-
105
85
tasks.push_back (taskRequest);
106
86
}
107
-
108
87
cudaq::info (" Created job payload for braket, language is OpenQASM 2.0, "
109
88
" targeting device {}" ,
110
89
backendConfig.at (" deviceArn" ));
111
-
112
90
return ret;
113
91
};
114
92
0 commit comments