qumat 0.5.0rc1__py3-none-any.whl → 0.5.0rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,8 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
- from braket.aws import AwsDevice
17
+ import boto3
18
+ from braket.aws import AwsDevice, AwsSession
18
19
  from braket.devices import LocalSimulator
19
20
  from braket.circuits import Circuit, FreeParameter
20
21
 
@@ -22,15 +23,29 @@ from braket.circuits import Circuit, FreeParameter
22
23
  def initialize_backend(backend_config):
23
24
  backend_options = backend_config["backend_options"]
24
25
  simulator_type = backend_options.get("simulator_type", "default")
26
+ region = backend_options.get("region")
27
+
28
+ # Create AWS session with region if specified
29
+ aws_session = None
30
+ if region:
31
+ boto_session = boto3.Session(region_name=region)
32
+ aws_session = AwsSession(boto_session=boto_session)
33
+
25
34
  if simulator_type == "local":
26
35
  return LocalSimulator()
27
36
  elif simulator_type == "default":
28
- return AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
37
+ return AwsDevice(
38
+ "arn:aws:braket:::device/quantum-simulator/amazon/sv1",
39
+ aws_session=aws_session,
40
+ )
29
41
  else:
30
42
  print(
31
43
  f"Simulator type '{simulator_type}' is not supported in Amazon Braket. Using default."
32
44
  )
33
- return AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
45
+ return AwsDevice(
46
+ "arn:aws:braket:::device/quantum-simulator/amazon/sv1",
47
+ aws_session=aws_session,
48
+ )
34
49
 
35
50
 
36
51
  def create_empty_circuit(num_qubits: int | None = None):
@@ -105,7 +120,17 @@ def execute_circuit(circuit, backend, backend_config):
105
120
  # placeholder method for use in the testing suite
106
121
  def get_final_state_vector(circuit, backend, backend_config):
107
122
  circuit.state_vector()
108
- result = backend.run(circuit, shots=0).result()
123
+ parameter_values = backend_config.get("parameter_values", {})
124
+ if parameter_values and circuit.parameters:
125
+ # Braket accepts parameter names as strings in inputs dict
126
+ inputs = {
127
+ param_name: value
128
+ for param_name, value in parameter_values.items()
129
+ if param_name in {p.name for p in circuit.parameters}
130
+ }
131
+ result = backend.run(circuit, shots=0, inputs=inputs).result()
132
+ else:
133
+ result = backend.run(circuit, shots=0).result()
109
134
  state_vector = result.values[0]
110
135
 
111
136
  return state_vector
qumat/cirq_backend.py CHANGED
@@ -159,7 +159,12 @@ def apply_u_gate(circuit, qubit_index, theta, phi, lambd):
159
159
 
160
160
  def get_final_state_vector(circuit, backend, backend_config):
161
161
  simulator = cirq.Simulator()
162
- result = simulator.simulate(circuit)
162
+ parameter_values = backend_config.get("parameter_values", None)
163
+ if parameter_values:
164
+ resolver = cirq.ParamResolver(parameter_values)
165
+ result = simulator.simulate(circuit, param_resolver=resolver)
166
+ else:
167
+ result = simulator.simulate(circuit)
163
168
  return result.final_state_vector
164
169
 
165
170
 
qumat/qiskit_backend.py CHANGED
@@ -147,6 +147,14 @@ def get_final_state_vector(circuit, backend, backend_config):
147
147
  # Add save_statevector instruction
148
148
  working_circuit.save_statevector()
149
149
 
150
+ # Bind parameters if present
151
+ if working_circuit.parameters:
152
+ parameter_values = backend_config.get("parameter_values", {})
153
+ parameter_bindings = {
154
+ param: parameter_values[str(param)] for param in working_circuit.parameters
155
+ }
156
+ working_circuit = working_circuit.assign_parameters(parameter_bindings)
157
+
150
158
  # Simulate the circuit
151
159
  transpiled_circuit = qiskit.transpile(working_circuit, simulator)
152
160
  job = simulator.run(transpiled_circuit)
qumat/qumat.py CHANGED
@@ -356,13 +356,34 @@ class QuMat:
356
356
  """Return the final state vector of the quantum circuit.
357
357
 
358
358
  The complete quantum state vector after circuit execution,
359
- representing the full quantum state of all qubits.
359
+ representing the full quantum state of all qubits. For parameterized
360
+ circuits, call bind_parameters() first to set parameter values.
360
361
 
361
362
  :returns: The final state vector as a numpy array.
362
363
  :rtype: numpy.ndarray
363
364
  :raises RuntimeError: If the circuit has not been initialized.
365
+ :raises ValueError: If parameterized circuit has unbound parameters.
364
366
  """
365
367
  self._ensure_circuit_initialized()
368
+
369
+ # Only pass bound parameters (non-None values) to backend
370
+ bound_parameters = {
371
+ param: value
372
+ for param, value in self.parameters.items()
373
+ if value is not None
374
+ }
375
+
376
+ # Check if there are unbound parameters in the circuit
377
+ if self.parameters and len(bound_parameters) < len(self.parameters):
378
+ unbound_params = [
379
+ p for p in self.parameters.keys() if self.parameters[p] is None
380
+ ]
381
+ raise ValueError(
382
+ f"Circuit contains unbound parameters: {unbound_params}. "
383
+ f"Please call bind_parameters() before get_final_state_vector()."
384
+ )
385
+
386
+ self.backend_config["parameter_values"] = bound_parameters
366
387
  return self.backend_module.get_final_state_vector(
367
388
  self.circuit, self.backend, self.backend_config
368
389
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qumat
3
- Version: 0.5.0rc1
3
+ Version: 0.5.0rc2
4
4
  Summary: A library for composing quantum machine learning.
5
5
  Author-email: Apache Mahout <dev@mahout.apache.org>
6
6
  License-Expression: Apache-2.0
@@ -47,7 +47,7 @@ For additional information about Mahout, visit the [Mahout Home Page](http://mah
47
47
  ## Qumat
48
48
 
49
49
  <p align="center">
50
- <img src="docs/assets/mascot_with_text.png" width="400" alt="Apache Mahout">
50
+ <img src="https://raw.githubusercontent.com/apache/mahout/refs/heads/main/docs/assets/mascot_with_text.png" width="400" alt="Apache Mahout">
51
51
  </p>
52
52
 
53
53
  Qumat is a high-level Python library for quantum computing that provides:
@@ -0,0 +1,11 @@
1
+ qumat/__init__.py,sha256=HweBfNndHmuHN3X2t0JR9vP9wsfDqkjSzBbEdS0XfF0,854
2
+ qumat/amazon_braket_backend.py,sha256=wU8RTsCHbZ6GP02KriG7Y6TKfXHymXLVU5pzuURH_vQ,6635
3
+ qumat/cirq_backend.py,sha256=GFc-k1FcP7TJordSBIGvJyQ6D00mmgVyTW92jNJ_UOM,6723
4
+ qumat/qdp.py,sha256=gKiQjlrB_oFwm--_LdJKPgO_XvXfhdV6XXtWHonbtFg,2332
5
+ qumat/qiskit_backend.py,sha256=70sNoylEq6ff4gyLILiVfhd8MF570HP09cVF1ZXy2gk,7344
6
+ qumat/qumat.py,sha256=uatL6R73Y7N76hUuFaJeIAHaBezQUSj3eRNx3smHhgs,25230
7
+ qumat-0.5.0rc2.dist-info/METADATA,sha256=hA4Txuhv0qVPeqxLg177SClJitA-m3HllBu04UQ4efg,4670
8
+ qumat-0.5.0rc2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
9
+ qumat-0.5.0rc2.dist-info/licenses/LICENSE,sha256=PM3t-YVh-GyXESTynXe-orGOAJ9z1xBgh0mbsLdn0Co,12628
10
+ qumat-0.5.0rc2.dist-info/licenses/NOTICE,sha256=TBC-GYUVZqnqxC23u5wXAUvyMwYXx0-H4_NT5ASLmvM,295
11
+ qumat-0.5.0rc2.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- qumat/__init__.py,sha256=HweBfNndHmuHN3X2t0JR9vP9wsfDqkjSzBbEdS0XfF0,854
2
- qumat/amazon_braket_backend.py,sha256=dDCn4oXsZwQqJdQIMWQD29HiNGECxYulklEiqFZsnPo,5787
3
- qumat/cirq_backend.py,sha256=jBdNQBi_86Z4cloDV1LXmhXRl7ae3mQbwf30AOjNrfY,6490
4
- qumat/qdp.py,sha256=gKiQjlrB_oFwm--_LdJKPgO_XvXfhdV6XXtWHonbtFg,2332
5
- qumat/qiskit_backend.py,sha256=ZjNbu3ToN9FLVL_C_3HLp5tS_wib0up48ibmUiq3VTI,6996
6
- qumat/qumat.py,sha256=pzpi015z9MwIgrRok1MFJjcKfLGHVBFbzsswJEcdwEo,24308
7
- qumat-0.5.0rc1.dist-info/METADATA,sha256=0IcBFH6ADR1rjAiFzaMtYFxCFLYVv3snED7k9r7GTtA,4606
8
- qumat-0.5.0rc1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
9
- qumat-0.5.0rc1.dist-info/licenses/LICENSE,sha256=PM3t-YVh-GyXESTynXe-orGOAJ9z1xBgh0mbsLdn0Co,12628
10
- qumat-0.5.0rc1.dist-info/licenses/NOTICE,sha256=TBC-GYUVZqnqxC23u5wXAUvyMwYXx0-H4_NT5ASLmvM,295
11
- qumat-0.5.0rc1.dist-info/RECORD,,