qadence 1.10.0__py3-none-any.whl → 1.10.2__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.
- qadence/ml_tools/config.py +23 -4
- qadence/ml_tools/constructors.py +56 -1
- qadence/pasqal_cloud_connection.py +1 -1
- qadence/states.py +27 -5
- qadence/types.py +2 -0
- qadence/utils.py +0 -2
- {qadence-1.10.0.dist-info → qadence-1.10.2.dist-info}/METADATA +9 -5
- {qadence-1.10.0.dist-info → qadence-1.10.2.dist-info}/RECORD +10 -10
- {qadence-1.10.0.dist-info → qadence-1.10.2.dist-info}/WHEEL +0 -0
- {qadence-1.10.0.dist-info → qadence-1.10.2.dist-info}/licenses/LICENSE +0 -0
qadence/ml_tools/config.py
CHANGED
@@ -434,15 +434,17 @@ class AnsatzConfig:
|
|
434
434
|
"""What type of ansatz.
|
435
435
|
|
436
436
|
`AnsatzType.HEA` for Hardware Efficient Ansatz.
|
437
|
-
`AnsatzType.IIA` for Identity
|
437
|
+
`AnsatzType.IIA` for Identity Intialized Ansatz.
|
438
|
+
`AnsatzType.ALA` for Alternating Layer Ansatz.
|
438
439
|
"""
|
439
440
|
|
440
441
|
ansatz_strategy: Strategy = Strategy.DIGITAL
|
441
442
|
"""Ansatz strategy.
|
442
443
|
|
443
|
-
`Strategy.DIGITAL` for fully digital ansatz. Required if `ansatz_type` is `AnsatzType.
|
444
|
-
`Strategy.SDAQC` for analog entangling block.
|
445
|
-
`
|
444
|
+
`Strategy.DIGITAL` for fully digital ansatz. Required if `ansatz_type` is `AnsatzType.ALA`.
|
445
|
+
`Strategy.SDAQC` for analog entangling block. Only available for `AnsatzType.HEA` or
|
446
|
+
`AnsatzType.ALA`.
|
447
|
+
`Strategy.RYDBERG` for fully rydberg hea ansatz. Only available for `AnsatzType.HEA`.
|
446
448
|
"""
|
447
449
|
|
448
450
|
strategy_args: dict = field(default_factory=dict)
|
@@ -484,6 +486,13 @@ class AnsatzConfig:
|
|
484
486
|
"""
|
485
487
|
# The default for a dataclass can not be a mutable object without using this default_factory.
|
486
488
|
|
489
|
+
m_block_qubits: int | None = None
|
490
|
+
"""
|
491
|
+
The number of qubits in the local entangling block of an Alternating Layer Ansatz (ALA).
|
492
|
+
|
493
|
+
Only used when `ansatz_type` is `AnsatzType.ALA`.
|
494
|
+
"""
|
495
|
+
|
487
496
|
param_prefix: str = "theta"
|
488
497
|
"""The base bame of the variational parameter."""
|
489
498
|
|
@@ -499,3 +508,13 @@ class AnsatzConfig:
|
|
499
508
|
assert (
|
500
509
|
self.ansatz_strategy != Strategy.RYDBERG
|
501
510
|
), "Rydberg strategy not allowed for Identity-initialized ansatz."
|
511
|
+
|
512
|
+
if self.ansatz_type == AnsatzType.ALA:
|
513
|
+
assert (
|
514
|
+
self.ansatz_strategy == Strategy.DIGITAL
|
515
|
+
), f"{self.ansatz_strategy} not allowed for Alternating Layer Ansatz.\
|
516
|
+
Only `Strategy.DIGITAL` allowed."
|
517
|
+
|
518
|
+
assert (
|
519
|
+
self.m_block_qubits is not None
|
520
|
+
), "m_block_qubits must be specified for Alternating Layer Ansatz."
|
qadence/ml_tools/constructors.py
CHANGED
@@ -13,13 +13,14 @@ from qadence.constructors import (
|
|
13
13
|
analog_feature_map,
|
14
14
|
feature_map,
|
15
15
|
hamiltonian_factory,
|
16
|
-
iia,
|
17
16
|
rydberg_feature_map,
|
18
17
|
rydberg_hea,
|
19
18
|
rydberg_tower_feature_map,
|
20
19
|
)
|
20
|
+
from qadence.constructors.ala import ala_digital
|
21
21
|
from qadence.constructors.hamiltonians import ObservableConfig, TDetuning
|
22
22
|
from qadence.constructors.hea import hea_digital, hea_sDAQC
|
23
|
+
from qadence.constructors.iia import iia
|
23
24
|
from qadence.measurements import Measurements
|
24
25
|
from qadence.noise import NoiseHandler
|
25
26
|
from qadence.operations import CNOT, RX, RY, I, N, Z
|
@@ -596,6 +597,58 @@ def _create_hea(
|
|
596
597
|
)
|
597
598
|
|
598
599
|
|
600
|
+
def _create_ala_digital(
|
601
|
+
num_qubits: int,
|
602
|
+
config: AnsatzConfig,
|
603
|
+
) -> AbstractBlock:
|
604
|
+
"""
|
605
|
+
Create the Digital Alternating Layer Ansatz based on the configuration.
|
606
|
+
|
607
|
+
Args:
|
608
|
+
num_qubits (int): The number of qubits.
|
609
|
+
config (AnsatzConfig): The configuration for the ansatz.
|
610
|
+
|
611
|
+
Returns:
|
612
|
+
AbstractBlock: The Digital Alternating Layer Ansatz.
|
613
|
+
"""
|
614
|
+
operations = config.strategy_args.get("operation", [RX, RY, RX])
|
615
|
+
entangler = config.strategy_args.get("entangler", CNOT)
|
616
|
+
|
617
|
+
return ala_digital(
|
618
|
+
n_qubits=num_qubits,
|
619
|
+
m_block_qubits=config.m_block_qubits, # type: ignore[arg-type]
|
620
|
+
param_prefix=config.param_prefix,
|
621
|
+
operations=operations,
|
622
|
+
entangler=entangler,
|
623
|
+
)
|
624
|
+
|
625
|
+
|
626
|
+
def _create_ala(
|
627
|
+
num_qubits: int,
|
628
|
+
config: AnsatzConfig,
|
629
|
+
) -> AbstractBlock:
|
630
|
+
"""
|
631
|
+
Create the Alternating Layer Ansatz based on the configuration.
|
632
|
+
|
633
|
+
Args:
|
634
|
+
num_qubits (int): The number of qubits.
|
635
|
+
config (AnsatzConfig): The configuration for the ansatz.
|
636
|
+
|
637
|
+
Returns:
|
638
|
+
AbstractBlock: The Alternating Layer Ansatz.
|
639
|
+
|
640
|
+
Raises:
|
641
|
+
ValueError: If the ansatz strategy is not `Strategy.DIGITAL`.
|
642
|
+
"""
|
643
|
+
if config.ansatz_strategy == Strategy.DIGITAL:
|
644
|
+
return _create_ala_digital(num_qubits=num_qubits, config=config)
|
645
|
+
else:
|
646
|
+
raise ValueError(
|
647
|
+
f"Invalid ansatz strategy {config.ansatz_strategy} provided. Only `Strategy.DIGITAL` \
|
648
|
+
allowed"
|
649
|
+
)
|
650
|
+
|
651
|
+
|
599
652
|
def create_ansatz(
|
600
653
|
register: int | Register,
|
601
654
|
config: AnsatzConfig,
|
@@ -619,6 +672,8 @@ def create_ansatz(
|
|
619
672
|
return _create_iia(num_qubits=num_qubits, config=config)
|
620
673
|
elif config.ansatz_type == AnsatzType.HEA:
|
621
674
|
return _create_hea(register=register, config=config)
|
675
|
+
elif config.ansatz_type == AnsatzType.ALA:
|
676
|
+
return _create_ala(num_qubits=num_qubits, config=config)
|
622
677
|
else:
|
623
678
|
raise NotImplementedError(
|
624
679
|
f"Ansatz of type {config.ansatz_type} not implemented yet. Only `AnsatzType.HEA` and\
|
@@ -68,7 +68,7 @@ class WorkloadSpec:
|
|
68
68
|
raise ValueError("All parameter values that are arrays, should have the same length")
|
69
69
|
|
70
70
|
|
71
|
-
def
|
71
|
+
def get_workload_spec(
|
72
72
|
model: QuantumModel,
|
73
73
|
result_types: list[ResultType],
|
74
74
|
parameter_values: dict[str, Tensor] | None = None,
|
qadence/states.py
CHANGED
@@ -40,6 +40,7 @@ __all__ = [
|
|
40
40
|
"equivalent_state",
|
41
41
|
"DensityMatrix",
|
42
42
|
"density_mat",
|
43
|
+
"overlap",
|
43
44
|
]
|
44
45
|
|
45
46
|
ATOL_64 = 1e-14 # 64 bit precision
|
@@ -559,11 +560,32 @@ def rand_bitstring(N: int) -> str:
|
|
559
560
|
return "".join(str(random.randint(0, 1)) for _ in range(N))
|
560
561
|
|
561
562
|
|
563
|
+
def overlap(s0: torch.Tensor, s1: torch.Tensor) -> torch.Tensor:
|
564
|
+
"""
|
565
|
+
Computes the exact overlap between two statevectors.
|
566
|
+
|
567
|
+
Arguments:
|
568
|
+
s0 (torch.Tensor): A statevector or batch of statevectors.
|
569
|
+
s1 (torch.Tensor): A statevector or batch of statevectors.
|
570
|
+
|
571
|
+
Returns:
|
572
|
+
A torch.Tensor with the result.
|
573
|
+
|
574
|
+
Examples:
|
575
|
+
```python exec="on" source="material-block" result="json"
|
576
|
+
from qadence.states import rand_bitstring
|
577
|
+
|
578
|
+
print(rand_bitstring(N=8))
|
579
|
+
```
|
580
|
+
"""
|
581
|
+
from qadence.overlap import overlap_exact
|
582
|
+
|
583
|
+
return overlap_exact(s0, s1)
|
584
|
+
|
585
|
+
|
562
586
|
def equivalent_state(
|
563
587
|
s0: torch.Tensor, s1: torch.Tensor, rtol: float = 0.0, atol: float = NORMALIZATION_ATOL
|
564
588
|
) -> bool:
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
expected = torch.ones_like(fid)
|
569
|
-
return torch.allclose(fid, expected, rtol=rtol, atol=atol) # type: ignore[no-any-return]
|
589
|
+
fidelity = overlap(s0, s1)
|
590
|
+
expected = torch.ones_like(fidelity)
|
591
|
+
return torch.allclose(fidelity, expected, rtol=rtol, atol=atol) # type: ignore[no-any-return]
|
qadence/types.py
CHANGED
qadence/utils.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: qadence
|
3
|
-
Version: 1.10.
|
3
|
+
Version: 1.10.2
|
4
4
|
Summary: Pasqal interface for circuit-based quantum computing SDKs
|
5
|
-
Author-email: Aleksander Wennersteen <aleksander.wennersteen@pasqal.com>, Gert-Jan Both <gert-jan.both@pasqal.com>, Niklas Heim <niklas.heim@pasqal.com>, Mario Dagrada <mario.dagrada@pasqal.com>, Vincent Elfving <vincent.elfving@pasqal.com>, Dominik Seitz <dominik.seitz@pasqal.com>, Roland Guichard <roland.guichard@pasqal.com>, "Joao P. Moutinho" <joao.moutinho@pasqal.com>, Vytautas Abramavicius <vytautas.abramavicius@pasqal.com>, Gergana Velikova <gergana.velikova@pasqal.com>, Eduardo Maschio <eduardo.maschio@pasqal.com>, Smit Chaudhary <smit.chaudhary@pasqal.com>, Ignacio Fernández Graña <ignacio.fernandez-grana@pasqal.com>, Charles Moussa <charles.moussa@pasqal.com>, Giorgio Tosti Balducci <giorgio.tosti-balducci@pasqal.com>, Daniele Cucurachi <daniele.cucurachi@pasqal.com>
|
5
|
+
Author-email: Aleksander Wennersteen <aleksander.wennersteen@pasqal.com>, Gert-Jan Both <gert-jan.both@pasqal.com>, Niklas Heim <niklas.heim@pasqal.com>, Mario Dagrada <mario.dagrada@pasqal.com>, Vincent Elfving <vincent.elfving@pasqal.com>, Dominik Seitz <dominik.seitz@pasqal.com>, Roland Guichard <roland.guichard@pasqal.com>, "Joao P. Moutinho" <joao.moutinho@pasqal.com>, Vytautas Abramavicius <vytautas.abramavicius@pasqal.com>, Gergana Velikova <gergana.velikova@pasqal.com>, Eduardo Maschio <eduardo.maschio@pasqal.com>, Smit Chaudhary <smit.chaudhary@pasqal.com>, Ignacio Fernández Graña <ignacio.fernandez-grana@pasqal.com>, Charles Moussa <charles.moussa@pasqal.com>, Giorgio Tosti Balducci <giorgio.tosti-balducci@pasqal.com>, Daniele Cucurachi <daniele.cucurachi@pasqal.com>, Pim Venderbosch <pim.venderbosch@pasqal.com>
|
6
6
|
License: Apache 2.0
|
7
7
|
License-File: LICENSE
|
8
8
|
Classifier: License :: OSI Approved :: Apache Software License
|
@@ -22,6 +22,7 @@ Requires-Dist: matplotlib
|
|
22
22
|
Requires-Dist: nevergrad
|
23
23
|
Requires-Dist: numpy
|
24
24
|
Requires-Dist: openfermion
|
25
|
+
Requires-Dist: pasqal-cloud
|
25
26
|
Requires-Dist: pyqtorch==1.7.0
|
26
27
|
Requires-Dist: pyyaml
|
27
28
|
Requires-Dist: rich
|
@@ -55,8 +56,8 @@ Provides-Extra: protocols
|
|
55
56
|
Requires-Dist: qadence-protocols; extra == 'protocols'
|
56
57
|
Provides-Extra: pulser
|
57
58
|
Requires-Dist: pasqal-cloud==0.12.7; extra == 'pulser'
|
58
|
-
Requires-Dist: pulser-core==1.2.
|
59
|
-
Requires-Dist: pulser-simulation==1.2.
|
59
|
+
Requires-Dist: pulser-core==1.2.1; extra == 'pulser'
|
60
|
+
Requires-Dist: pulser-simulation==1.2.1; extra == 'pulser'
|
60
61
|
Provides-Extra: visualization
|
61
62
|
Requires-Dist: graphviz; extra == 'visualization'
|
62
63
|
Description-Content-Type: text/markdown
|
@@ -74,7 +75,10 @@ programs** with tunable qubit interactions and arbitrary register topologies rea
|
|
74
75
|
|
75
76
|
**For a high-level overview of Qadence features, [check out our white paper](https://arxiv.org/abs/2401.09915).**
|
76
77
|
|
77
|
-
**For more detailed information, [check out the documentation](https://pasqal-io.github.io/qadence/latest/)
|
78
|
+
**For more detailed information, [check out the documentation](https://pasqal-io.github.io/qadence/latest/).
|
79
|
+
|
80
|
+
**For any questions or comments, [feel free to start a discussion](https://github.com/pasqal-io/qadence/discussions).
|
81
|
+
**
|
78
82
|
|
79
83
|
[](https://github.com/pasqal-io/qadence/actions/workflows/lint.yml)
|
80
84
|
[](https://github.com/pasqal-io/qadence/actions/workflows/test_fast.yml)
|
@@ -11,16 +11,16 @@ qadence/logger.py,sha256=Hb76pK3VyQjVjJb4_NqFlOJgjYJVa8t7DHJFlzOM86M,407
|
|
11
11
|
qadence/model.py,sha256=OH61_Ij_c7PRywiXf16tJ5mnK9iYNbBTdRiHeG8PZ54,21623
|
12
12
|
qadence/overlap.py,sha256=ekaUnIcQWdF4hSFuUWpRjaxo43JyDGFOayP7vMXCZpw,16821
|
13
13
|
qadence/parameters.py,sha256=RDYklyW5EQZTjsAazEXa4lLGDOdmUUU53hLj385uSaI,12687
|
14
|
-
qadence/pasqal_cloud_connection.py,sha256=
|
14
|
+
qadence/pasqal_cloud_connection.py,sha256=1lz_AJRo54-YMnsYGJD_SFpUK-0_ZzJRWr9Qqa_pBZU,9675
|
15
15
|
qadence/protocols.py,sha256=bcYTxSjgMPV-a-D6yv90jCpnGik8myzaNpFv9z1gzJ0,442
|
16
16
|
qadence/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
qadence/qubit_support.py,sha256=Nkn1Q01RVViTcggSIom7EFKdWpAuM4TMGwBZ5feCUxA,2120
|
18
18
|
qadence/register.py,sha256=mwmvS6PcTY0F9cIhTUXG3NT73FIagfMCwVqYa4DrQrk,13001
|
19
19
|
qadence/serial_expr_grammar.peg,sha256=z5ytL7do9kO8o4h-V5GrsDuLdso0KsRcMuIYURFfmAY,328
|
20
20
|
qadence/serialization.py,sha256=qEET6Gu9u2aSibPve3bJrqDzK2_gO3RPDJjt4ZY8GbE,15596
|
21
|
-
qadence/states.py,sha256=
|
22
|
-
qadence/types.py,sha256=
|
23
|
-
qadence/utils.py,sha256=
|
21
|
+
qadence/states.py,sha256=Aj28aNHGWkZrFw_mKpHrxCA1bDXlkFhw18D70tg0RF0,15953
|
22
|
+
qadence/types.py,sha256=fFjSG9JlPqxFizIK4PfjNZ4e13-yGckejq-fP5TEMdc,12051
|
23
|
+
qadence/utils.py,sha256=U670ftNhxkD2hejvV1mTM2YnhDgTms_39saZs-7GKl8,9777
|
24
24
|
qadence/analog/__init__.py,sha256=BCyS9R4KUjzUXN0Ax3b0eMo8ZAuSkGoJQVtZ4_pvAFs,279
|
25
25
|
qadence/analog/addressing.py,sha256=GSt4heEmRkBmoQIgdgkTclEFxZY-jjuAd77_SsZtGdI,6513
|
26
26
|
qadence/analog/constants.py,sha256=B2phQoN1ASL8CwM-Dsa1rbraYwGwwPSeiB3HbVe-MPA,1243
|
@@ -102,8 +102,8 @@ qadence/mitigations/analog_zne.py,sha256=5n1ffjGM1I5sd9TATsB90pKdDh32UTFJ-ZyOHKd
|
|
102
102
|
qadence/mitigations/protocols.py,sha256=0TeHvlGTN8_88XNEwrjA97C5BUlrh34wYmx0w6-5Tyw,1622
|
103
103
|
qadence/mitigations/readout.py,sha256=nI-voV5N0R7630Cn8t8x9EdV9iB76P0LDkRosy1s0Ec,6631
|
104
104
|
qadence/ml_tools/__init__.py,sha256=a52dLBtUh5rTJ0ks_LREv-txtQ8pQZZhnQaIg28fSOw,936
|
105
|
-
qadence/ml_tools/config.py,sha256=
|
106
|
-
qadence/ml_tools/constructors.py,sha256=
|
105
|
+
qadence/ml_tools/config.py,sha256=r78n5tHDuMBPnItWP9FYaDPxneTEAtbUJb5yLZBs64A,20163
|
106
|
+
qadence/ml_tools/constructors.py,sha256=MT37r2OZ9uqlf0J7jBGNzMlnaZjfhF6rmll0sIWyaAg,29700
|
107
107
|
qadence/ml_tools/data.py,sha256=5sAqG9rUtGZPzFlzEDhMjSeOXF8Z0BmszJ_FRzYAy2A,5311
|
108
108
|
qadence/ml_tools/models.py,sha256=DKSVFNC-Iq0-AmBrCZ1kqUpTBHQh_pX_1MqYT8eCG08,17045
|
109
109
|
qadence/ml_tools/optimize_step.py,sha256=wUnxfWy0c9rEKe41-26On1bPFBwmSYBF4WCGn76oyq8,3376
|
@@ -139,7 +139,7 @@ qadence/transpile/flatten.py,sha256=k4HAfVzvDV40HyfaukiEHyJtAtvFRIcyDbAWiCL8tf0,
|
|
139
139
|
qadence/transpile/invert.py,sha256=IeyidgBwECCKB0i7Ym0KkLyfcx42LyT2mbqkfbK1H8M,4843
|
140
140
|
qadence/transpile/noise.py,sha256=LDcDJtQGkgUPkL2t69gg6AScTb-p3J3SxCDZbYOu1L8,1668
|
141
141
|
qadence/transpile/transpile.py,sha256=xnzkHA6Qdb-Y5Fv9Latrolrpw44N6_OKc7_QGt70f0I,2713
|
142
|
-
qadence-1.10.
|
143
|
-
qadence-1.10.
|
144
|
-
qadence-1.10.
|
145
|
-
qadence-1.10.
|
142
|
+
qadence-1.10.2.dist-info/METADATA,sha256=nvxqPfkWiJhQZYUqC-m5izWbIYAswfaT4grepXhMYP0,10149
|
143
|
+
qadence-1.10.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
144
|
+
qadence-1.10.2.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
145
|
+
qadence-1.10.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|