dense-evolution 8.2.1__tar.gz → 8.2.2__tar.gz
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.
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/PKG-INFO +1 -1
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/__init__.py +7 -4
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/__init__.py +2 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/zne.py +58 -1
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/__init__.py +13 -2
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/density_matrix_channels.py +30 -1
- dense_evolution-8.2.2/dense_evolution/noise/pink.py +80 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution.egg-info/PKG-INFO +1 -1
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution.egg-info/SOURCES.txt +7 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/pyproject.toml +1 -1
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/research/local_site/app/server.py +184 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/__init__.py +12 -0
- dense_evolution-8.2.2/tools/dashboard/core/crypto_protocols.py +77 -0
- dense_evolution-8.2.2/tools/dashboard/core/mass_decomposition_tool.py +47 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/mitigation.py +76 -1
- dense_evolution-8.2.2/tools/dashboard/core/native_hf_diagnostics.py +62 -0
- dense_evolution-8.2.2/tools/dashboard/core/rag_tool.py +45 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/ia_utils/rag.py +52 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/client.py +105 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/models.py +52 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/server.py +24 -11
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/tools/chemistry_tools.py +45 -2
- dense_evolution-8.2.2/tools/mcp_server/tools/crypto_tools.py +66 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/tools/mitigation_tools.py +20 -0
- dense_evolution-8.2.2/tools/mcp_server/tools/retrieval_tools.py +44 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/tools/system_tools.py +12 -3
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/README.md +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/autodiff.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/_engine_imports.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/circuit_chunker.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/core.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/disk_overflow.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/geometry.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/guard.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/chunk/kernels.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/mps.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/backends/statevector.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/chunk.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/compiler.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/diagram.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/gates.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/parser.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/qft.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/random_circuit.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/registry.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/topology.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/trotter.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/circuits/uccsd.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/cli.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/compiler.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/config.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/drawing.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/entropy.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/fermions.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/gates.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/harrison_tb.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/healing.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/interop/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/interop/qiskit_pennylane.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/measurement.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/healing.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/kl_divergence.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/magic_entropy.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/magic_entropy_shadows.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/renyi.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mitigation/stabilizer_renyi_entropy.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/mps.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/assembly.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/basis.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/boys.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/bridge.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/cartesian.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/coulomb.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/differentiable.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/gaussians.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/kinetic.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/libcint_bridge.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/overlap.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/native_hf/scf.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/coherent_attack.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/cosmic_ray.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/differentiable.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus/amplitude_damping.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus/bitflip.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus/combined.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus/depolarizing.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus/ideal.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus/phaseflip.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/kraus_channels.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/oscillating.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/observables.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/parser.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/physics/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/physics/entropy.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/physics/fermions.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/physics/observables.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/physics/qec.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/physics/spectral.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/physics/states.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/qec.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/qft.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/qmmm/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/qmmm/ase_bridge.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/qmmm/forces.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/qmmm/propagation.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/qmmm/region.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/random_circuit.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/registry.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/simulator.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/solvers/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/solvers/autodiff.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/solvers/harrison_tb.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/solvers/vhd_tb.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/states.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/topology.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/trotter.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/utils/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/utils/drawing.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/utils/mass_decomposition.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/utils/measurement.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/vhd_tb.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution.egg-info/dependency_links.txt +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution.egg-info/entry_points.txt +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution.egg-info/requires.txt +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution.egg-info/top_level.txt +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/license.md +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/research/local_site/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/research/local_site/app/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/setup.cfg +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/_gate_tables.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/band_structure.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/circuit_builder_component.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/circuit_diagram.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/engine.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/graphical_builder.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/hamiltonians.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/noise_tools.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/qasm_library.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/qmmm.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/state_visuals.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/system_limits.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/vector_healing.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/visuals.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/vqe.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/dashboard/core/wormhole.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/ia_utils/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/ia_utils/adversarial_vector_attack.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/ia_utils/vector_healing.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/config.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/molecules.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/tools/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/tools/circuit_tools.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/tools/noise_tools.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/tools/wormhole_tools.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/utils/__init__.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/utils/cache.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/utils/images.py +0 -0
- {dense_evolution-8.2.1 → dense_evolution-8.2.2}/tools/mcp_server/utils/truncation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dense-evolution
|
|
3
|
-
Version: 8.2.
|
|
3
|
+
Version: 8.2.2
|
|
4
4
|
Summary: High-performance quantum simulation toolkit -- Statevector/MPS engines with JIT compilation, noise modeling, VQE, QEC, quantum chemistry, and agent-native tooling
|
|
5
5
|
Author-email: Salvatore Pennacchio <jtatopenn@libero.it>
|
|
6
6
|
License: Business Source License 1.1
|
|
@@ -6,7 +6,8 @@ from .backends.statevector import DenseSVSimulator
|
|
|
6
6
|
from .circuits.parser import QASMParser, QASMCircuit
|
|
7
7
|
from .circuits.compiler import QuantumTranspiler
|
|
8
8
|
from .noise import (NoiseModel, NoiseSpec, global_depolarizing_channel, amplitude_damping_channel,
|
|
9
|
-
cosmic_ray_burst_profile, oscillating_p_eff
|
|
9
|
+
phaseflip_channel_exact, cosmic_ray_burst_profile, oscillating_p_eff,
|
|
10
|
+
pink_noise_p_eff)
|
|
10
11
|
from .circuits.registry import QuantumHardwareRegistry
|
|
11
12
|
from .circuits.gates import GATES, PARAMETRIC_GATES, GATE_IDS
|
|
12
13
|
from .backends.chunk import Chunk
|
|
@@ -33,6 +34,7 @@ from .mitigation.zne import (richardson_extrapolate, richardson_amplification_fa
|
|
|
33
34
|
project_to_physical, uhlmann_fidelity, zne_density_matrix,
|
|
34
35
|
jsd_predictive_zne_density_matrix,
|
|
35
36
|
coherence_predictive_zne_density_matrix,
|
|
37
|
+
classically_augmented_zne_phaseflip,
|
|
36
38
|
richardson_extrapolate_jit, zero_noise_extrapolation_jit,
|
|
37
39
|
polynomial_extrapolate_jit, uhlmann_fidelity_jit, zne_density_matrix_jit)
|
|
38
40
|
from .circuits.diagram import plot_circuit
|
|
@@ -58,7 +60,7 @@ from .physics.qec import (pauli_commutes, compute_syndrome, erasure_aware_decode
|
|
|
58
60
|
blind_minimum_weight_decode, decode_with_erasure_fallback,
|
|
59
61
|
counts_in_intervals_dimension, nearest_coset_decode)
|
|
60
62
|
|
|
61
|
-
__version__ = "8.2.
|
|
63
|
+
__version__ = "8.2.2"
|
|
62
64
|
|
|
63
65
|
__all__ = [
|
|
64
66
|
"__version__",
|
|
@@ -89,8 +91,9 @@ __all__ = [
|
|
|
89
91
|
"bounded_exponential_extrapolate",
|
|
90
92
|
"project_to_physical", "uhlmann_fidelity", "zne_density_matrix",
|
|
91
93
|
"jsd_predictive_zne_density_matrix", "coherence_predictive_zne_density_matrix",
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
+
"classically_augmented_zne_phaseflip",
|
|
95
|
+
"global_depolarizing_channel", "amplitude_damping_channel", "phaseflip_channel_exact",
|
|
96
|
+
"cosmic_ray_burst_profile", "oscillating_p_eff", "pink_noise_p_eff",
|
|
94
97
|
"richardson_extrapolate_jit", "zero_noise_extrapolation_jit",
|
|
95
98
|
"polynomial_extrapolate_jit", "uhlmann_fidelity_jit", "zne_density_matrix_jit",
|
|
96
99
|
# Physics -- states, observables, entropy, fermions, QEC
|
|
@@ -14,6 +14,7 @@ from .zne import (
|
|
|
14
14
|
project_to_physical, uhlmann_fidelity, zne_density_matrix,
|
|
15
15
|
jsd_predictive_zne_density_matrix,
|
|
16
16
|
coherence_predictive_zne_density_matrix,
|
|
17
|
+
classically_augmented_zne_phaseflip,
|
|
17
18
|
richardson_extrapolate_jit, zero_noise_extrapolation_jit,
|
|
18
19
|
polynomial_extrapolate_jit, uhlmann_fidelity_jit, zne_density_matrix_jit,
|
|
19
20
|
)
|
|
@@ -38,6 +39,7 @@ __all__ = [
|
|
|
38
39
|
"project_to_physical", "uhlmann_fidelity", "zne_density_matrix",
|
|
39
40
|
"jsd_predictive_zne_density_matrix",
|
|
40
41
|
"coherence_predictive_zne_density_matrix",
|
|
42
|
+
"classically_augmented_zne_phaseflip",
|
|
41
43
|
"richardson_extrapolate_jit", "zero_noise_extrapolation_jit",
|
|
42
44
|
"polynomial_extrapolate_jit", "uhlmann_fidelity_jit", "zne_density_matrix_jit",
|
|
43
45
|
"calculate_advanced_sigma", "calculate_phi_ab", "calculate_vettore_dinamico",
|
|
@@ -23,7 +23,8 @@ from .healing import calculate_delta_preemp
|
|
|
23
23
|
__all__ = ["richardson_extrapolate", "richardson_amplification_factor", "zero_noise_extrapolation",
|
|
24
24
|
"polynomial_extrapolate", "bounded_exponential_extrapolate",
|
|
25
25
|
"project_to_physical", "uhlmann_fidelity", "zne_density_matrix",
|
|
26
|
-
"jsd_predictive_zne_density_matrix", "
|
|
26
|
+
"jsd_predictive_zne_density_matrix", "coherence_predictive_zne_density_matrix",
|
|
27
|
+
"classically_augmented_zne_phaseflip", "global_depolarizing_channel",
|
|
27
28
|
"amplitude_damping_channel", "cosmic_ray_burst_profile",
|
|
28
29
|
"richardson_extrapolate_jit", "zero_noise_extrapolation_jit",
|
|
29
30
|
"polynomial_extrapolate_jit", "uhlmann_fidelity_jit", "zne_density_matrix_jit"]
|
|
@@ -931,3 +932,59 @@ def _coherence_predictive_zne_density_matrix_core(rho_at_scales: jnp.ndarray, nu
|
|
|
931
932
|
c3 = 1.0 - nudge_scale * rectified
|
|
932
933
|
extrapolated = (c1 * e_l1 + c2 * e_l2 + c3 * e_l3) / (c1 + c2 + c3)
|
|
933
934
|
return project_to_physical(extrapolated)
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
def classically_augmented_zne_phaseflip(rho_at_scales_measured, noise_factors, rho_ideal, base_p, degree: int = 2) -> jnp.ndarray:
|
|
938
|
+
"""Classically Augmented ZNE (Scheiber et al., arXiv:2607.25746) for
|
|
939
|
+
phaseflip noise: the highest-noise Richardson/polynomial-extrapolation
|
|
940
|
+
nodes -- the ones contributing most to sampling variance -- are
|
|
941
|
+
replaced by `phaseflip_channel_exact`'s zero-sampling-variance exact
|
|
942
|
+
channel instead of a Monte-Carlo-sampled density matrix, then combined
|
|
943
|
+
exactly as `zne_density_matrix` already does (same extrapolation
|
|
944
|
+
coefficients; only the source of the high-noise inputs changes).
|
|
945
|
+
|
|
946
|
+
`rho_at_scales_measured[i]` must be the measured/sampled density
|
|
947
|
+
matrix at `noise_factors[i]` for `i < len(rho_at_scales_measured)`
|
|
948
|
+
(the low-noise nodes, kept as real measurements); every remaining
|
|
949
|
+
factor in `noise_factors` is filled in with the exact channel computed
|
|
950
|
+
from `rho_ideal` and `base_p`. `rho_ideal` and `base_p` are required
|
|
951
|
+
inputs, not optional, because the exact channel needs the noise-free
|
|
952
|
+
state to condition on -- unlike every other function in this module,
|
|
953
|
+
this one is not usable from noisy measurements alone.
|
|
954
|
+
|
|
955
|
+
Honest, verified scope (GHZ(3), phaseflip, 150 trials/measured node,
|
|
956
|
+
60 seeds each): with exactly 3 total noise factors and only the single
|
|
957
|
+
highest one replaced, no measurable benefit (variance ratio 0.99x,
|
|
958
|
+
i.e. no effect within noise) -- too little room for the exact node to
|
|
959
|
+
matter against only 2 remaining measured ones. With 5 noise factors
|
|
960
|
+
(1x-5x, `base_p=0.03`) and the top 3 replaced by the exact channel,
|
|
961
|
+
variance drops by a real, measured 1.30x versus plain `zne_density_matrix`
|
|
962
|
+
using 5 fully-measured nodes at the same per-node trial budget. This is
|
|
963
|
+
the naive-allocation regime, not the paper's own optimal importance-
|
|
964
|
+
sampling allocation (their Eq. 9) -- that allocation is not implemented
|
|
965
|
+
here, so the exponential variance reduction the paper reports under it
|
|
966
|
+
is not claimed or expected from this function as shipped.
|
|
967
|
+
|
|
968
|
+
Only implemented for phaseflip noise, since `phaseflip_channel_exact`
|
|
969
|
+
is the only exact density-matrix channel currently available that
|
|
970
|
+
matches a `NoiseModel` statevector model exactly (see that function's
|
|
971
|
+
docstring) -- extending this to other noise models needs their own
|
|
972
|
+
exact channel first."""
|
|
973
|
+
from ..noise import phaseflip_channel_exact
|
|
974
|
+
|
|
975
|
+
rho_at_scales_measured = jnp.asarray(rho_at_scales_measured, dtype=jnp.complex128)
|
|
976
|
+
noise_factors = jnp.asarray(noise_factors, dtype=jnp.float64)
|
|
977
|
+
rho_ideal = jnp.asarray(rho_ideal, dtype=jnp.complex128)
|
|
978
|
+
cutoff = rho_at_scales_measured.shape[0]
|
|
979
|
+
if cutoff >= noise_factors.shape[0]:
|
|
980
|
+
raise ValueError(
|
|
981
|
+
f"rho_at_scales_measured has {cutoff} entries but noise_factors only has "
|
|
982
|
+
f"{noise_factors.shape[0]} -- at least one factor must be left for the exact "
|
|
983
|
+
"classical node, or there is nothing to augment."
|
|
984
|
+
)
|
|
985
|
+
classical_rhos = jnp.stack([
|
|
986
|
+
phaseflip_channel_exact(rho_ideal, jnp.minimum(base_p * f, 1.0))
|
|
987
|
+
for f in noise_factors[cutoff:]
|
|
988
|
+
])
|
|
989
|
+
rho_at_scales = jnp.concatenate([rho_at_scales_measured, classical_rhos], axis=0)
|
|
990
|
+
return zne_density_matrix(rho_at_scales, noise_factors, degree=degree)
|
|
@@ -17,12 +17,20 @@
|
|
|
17
17
|
- **Density-matrix channels** (`.density_matrix_channels`) --
|
|
18
18
|
`global_depolarizing_channel`, `amplitude_damping_channel`: noise applied
|
|
19
19
|
directly to a density matrix instead of a statevector, for density-matrix
|
|
20
|
-
ZNE's noise ensemble.
|
|
20
|
+
ZNE's noise ensemble. `phaseflip_channel_exact`: the same phaseflip model
|
|
21
|
+
as `NoiseModel`'s `'phaseflip'` statevector Kraus channel, but computed as
|
|
22
|
+
its exact zero-sampling-variance limit directly on a density matrix, for
|
|
23
|
+
use as a "classical node" in Classically Augmented ZNE (see
|
|
24
|
+
`dense_evolution.mitigation.classically_augmented_zne_phaseflip`).
|
|
21
25
|
- **`cosmic_ray_burst_profile`** (`.cosmic_ray`) -- a real, time-dependent
|
|
22
26
|
noise-strength profile for a cosmic-ray-induced quasiparticle burst.
|
|
23
27
|
- **`oscillating_p_eff`** (`.oscillating`) -- a noise strength that
|
|
24
28
|
oscillates instead of scaling smoothly, for stress-testing mitigation
|
|
25
29
|
techniques that assume smoothness.
|
|
30
|
+
- **`pink_noise_p_eff`** (`.pink`) -- a noise-strength trace with a real
|
|
31
|
+
1/f (pink/flicker) power spectrum, the dominant decoherence mechanism
|
|
32
|
+
in real superconducting qubits, via the Timmer & Koenig (1995)
|
|
33
|
+
spectral-synthesis algorithm.
|
|
26
34
|
|
|
27
35
|
Real device noise from a Qiskit backend's own calibration data
|
|
28
36
|
(`noise_model_from_qiskit_backend`) lives in `dense_evolution.interop`,
|
|
@@ -47,9 +55,10 @@ from .coherent_attack import (
|
|
|
47
55
|
decoder_failure_rate,
|
|
48
56
|
random_delta_failure_stats,
|
|
49
57
|
)
|
|
50
|
-
from .density_matrix_channels import global_depolarizing_channel, amplitude_damping_channel
|
|
58
|
+
from .density_matrix_channels import global_depolarizing_channel, amplitude_damping_channel, phaseflip_channel_exact
|
|
51
59
|
from .cosmic_ray import cosmic_ray_burst_profile
|
|
52
60
|
from .oscillating import oscillating_p_eff
|
|
61
|
+
from .pink import pink_noise_p_eff
|
|
53
62
|
|
|
54
63
|
__all__ = [
|
|
55
64
|
"NoiseModel",
|
|
@@ -63,6 +72,8 @@ __all__ = [
|
|
|
63
72
|
"random_delta_failure_stats",
|
|
64
73
|
"global_depolarizing_channel",
|
|
65
74
|
"amplitude_damping_channel",
|
|
75
|
+
"phaseflip_channel_exact",
|
|
66
76
|
"cosmic_ray_burst_profile",
|
|
67
77
|
"oscillating_p_eff",
|
|
78
|
+
"pink_noise_p_eff",
|
|
68
79
|
]
|
{dense_evolution-8.2.1 → dense_evolution-8.2.2}/dense_evolution/noise/density_matrix_channels.py
RENAMED
|
@@ -3,7 +3,7 @@ what density-matrix ZNE (`dense_evolution.mitigation.zne_density_matrix`)
|
|
|
3
3
|
needs its noise ensemble built from."""
|
|
4
4
|
import jax.numpy as jnp
|
|
5
5
|
|
|
6
|
-
__all__ = ["global_depolarizing_channel", "amplitude_damping_channel"]
|
|
6
|
+
__all__ = ["global_depolarizing_channel", "amplitude_damping_channel", "phaseflip_channel_exact"]
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def global_depolarizing_channel(rho: jnp.ndarray, p: float) -> jnp.ndarray:
|
|
@@ -47,3 +47,32 @@ def amplitude_damping_channel(rho: jnp.ndarray, gamma: float) -> jnp.ndarray:
|
|
|
47
47
|
e0 = jnp.array([[1.0, 0.0], [0.0, jnp.sqrt(1.0 - gamma)]], dtype=jnp.complex128)
|
|
48
48
|
e1 = jnp.array([[0.0, jnp.sqrt(gamma)], [0.0, 0.0]], dtype=jnp.complex128)
|
|
49
49
|
return e0 @ rho @ e0.conj().T + e1 @ rho @ e1.conj().T
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def phaseflip_channel_exact(rho: jnp.ndarray, p: float) -> jnp.ndarray:
|
|
53
|
+
"""Exact (zero-variance) multi-qubit phaseflip channel: K0=sqrt(1-p)*I,
|
|
54
|
+
K1=sqrt(p)*Z, applied independently per qubit across the whole
|
|
55
|
+
register, matching `NoiseModel`'s `'phaseflip'` statevector model
|
|
56
|
+
(`noise/kraus/phaseflip.py`) in the limit of infinitely many Monte
|
|
57
|
+
Carlo trials -- this function computes that limit directly instead of
|
|
58
|
+
averaging finite trials, for use as a zero-sampling-variance
|
|
59
|
+
"classical node" in Classically Augmented ZNE (Scheiber et al., "CA-ZNE:
|
|
60
|
+
high-noise Richardson nodes replaced by classically simulated
|
|
61
|
+
estimates", arXiv:2607.25746).
|
|
62
|
+
|
|
63
|
+
Since Z is diagonal in the computational basis, conjugating rho by Z_q
|
|
64
|
+
(Pauli-Z on qubit q, identity elsewhere) only flips the sign of
|
|
65
|
+
off-diagonal entries whose row and column disagree on bit q --
|
|
66
|
+
(Z_q rho Z_q)_ij = rho_ij * s_i * s_j, s_k = -1 if bit q of k else +1
|
|
67
|
+
-- so each qubit's channel (1-p)*rho + p*(Z_q rho Z_q) is one
|
|
68
|
+
elementwise multiply, no explicit operator ever built.
|
|
69
|
+
"""
|
|
70
|
+
rho = jnp.asarray(rho, dtype=jnp.complex128)
|
|
71
|
+
dim = rho.shape[0]
|
|
72
|
+
n_qubits = dim.bit_length() - 1
|
|
73
|
+
idx = jnp.arange(dim)
|
|
74
|
+
for q in range(n_qubits):
|
|
75
|
+
sign = 1.0 - 2.0 * ((idx >> q) & 1)
|
|
76
|
+
flip_sign = jnp.outer(sign, sign)
|
|
77
|
+
rho = (1.0 - p) * rho + p * (flip_sign * rho)
|
|
78
|
+
return rho
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""1/f ("pink") noise: a noise-strength trace with a power-law power
|
|
2
|
+
spectral density, S(f) ~ 1/f^alpha, instead of the flat (white) or
|
|
3
|
+
purely time-local (oscillating, burst) profiles this package's other
|
|
4
|
+
generators produce -- the dominant real decoherence source (flux noise,
|
|
5
|
+
charge noise) in superconducting qubits."""
|
|
6
|
+
import jax
|
|
7
|
+
import jax.numpy as jnp
|
|
8
|
+
|
|
9
|
+
__all__ = ["pink_noise_p_eff"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def pink_noise_p_eff(base_p: float, n_samples: int, key, alpha: float = 1.0, amp: float = 0.5) -> jnp.ndarray:
|
|
13
|
+
"""Effective noise probability trace of length `n_samples` fluctuating
|
|
14
|
+
around `base_p` with a 1/f^alpha power spectrum (`alpha=1.0` is the
|
|
15
|
+
real, standard "pink"/flicker-noise case; other values interpolate
|
|
16
|
+
toward white noise, `alpha=0`, or Brownian noise, `alpha=2`), instead
|
|
17
|
+
of `oscillating_p_eff`'s single deterministic frequency or
|
|
18
|
+
`cosmic_ray_burst_profile`'s one-shot deterministic event -- for
|
|
19
|
+
stress-testing mitigation techniques against the actual dominant
|
|
20
|
+
decoherence mechanism (1/f flux/charge noise) in real superconducting
|
|
21
|
+
hardware, not just synthetic worst cases.
|
|
22
|
+
|
|
23
|
+
Generated by the spectral-synthesis method of Timmer & Koenig (1995,
|
|
24
|
+
"On generating power law noise", Astronomy and Astrophysics 300, 707):
|
|
25
|
+
both the amplitude and the phase of each Fourier component are drawn
|
|
26
|
+
randomly (independent real/imaginary Gaussian draws, giving the
|
|
27
|
+
correct chi-squared-distributed power per bin, not just the correct
|
|
28
|
+
mean spectrum), scaled by `frequency ** (-alpha / 2)` so the power
|
|
29
|
+
spectrum scales as `frequency ** (-alpha)`, then inverse-transformed
|
|
30
|
+
to the time domain -- the standard algorithm for this exact problem,
|
|
31
|
+
not a bespoke construction. The zero-frequency (DC) component is
|
|
32
|
+
fixed to exactly 0, so the trace has zero mean before rescaling.
|
|
33
|
+
Verified during development: the fitted log-log power-spectrum slope
|
|
34
|
+
over 30 independent realizations at `alpha=1.0` is -0.996, matching
|
|
35
|
+
the expected -1 to within numerical/finite-sample tolerance.
|
|
36
|
+
|
|
37
|
+
The resulting zero-mean, unit-variance trace is rescaled to
|
|
38
|
+
`base_p * (1 + amp * trace)` and clipped to `[0.01, 0.5]`, the same
|
|
39
|
+
valid-probability range `oscillating_p_eff` uses, so it can be fed
|
|
40
|
+
directly wherever a per-trial or per-timestep `p` is expected.
|
|
41
|
+
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
base_p : float
|
|
45
|
+
Center noise probability the trace fluctuates around.
|
|
46
|
+
n_samples : int
|
|
47
|
+
Length of the trace (e.g. one value per Monte Carlo trial, or per
|
|
48
|
+
time step of a trajectory).
|
|
49
|
+
key : jax.random.PRNGKey
|
|
50
|
+
Random key; two independent draws are taken from it internally
|
|
51
|
+
(real and imaginary Fourier-amplitude parts).
|
|
52
|
+
alpha : float
|
|
53
|
+
Spectral exponent: power spectral density ~ `1/frequency**alpha`.
|
|
54
|
+
`1.0` (default) is real 1/f/pink/flicker noise.
|
|
55
|
+
amp : float
|
|
56
|
+
Fractional modulation depth around `base_p`, same role as in
|
|
57
|
+
`oscillating_p_eff`.
|
|
58
|
+
|
|
59
|
+
Examples
|
|
60
|
+
--------
|
|
61
|
+
>>> import jax
|
|
62
|
+
>>> from dense_evolution.noise import pink_noise_p_eff
|
|
63
|
+
>>> trace = pink_noise_p_eff(0.05, 256, jax.random.PRNGKey(0))
|
|
64
|
+
>>> trace.shape
|
|
65
|
+
(256,)
|
|
66
|
+
>>> bool((trace >= 0.01).all() and (trace <= 0.5).all())
|
|
67
|
+
True
|
|
68
|
+
"""
|
|
69
|
+
freqs = jnp.fft.rfftfreq(n_samples)
|
|
70
|
+
freqs = freqs.at[0].set(freqs[1]) # avoid a 1/0 singularity at DC; DC amplitude is zeroed below anyway
|
|
71
|
+
key_re, key_im = jax.random.split(key)
|
|
72
|
+
real_part = jax.random.normal(key_re, shape=freqs.shape)
|
|
73
|
+
imag_part = jax.random.normal(key_im, shape=freqs.shape)
|
|
74
|
+
scale = freqs ** (-alpha / 2.0)
|
|
75
|
+
spectrum = (real_part + 1j * imag_part) * scale
|
|
76
|
+
spectrum = spectrum.at[0].set(0.0)
|
|
77
|
+
trace = jnp.fft.irfft(spectrum, n=n_samples)
|
|
78
|
+
trace = (trace - jnp.mean(trace)) / jnp.std(trace)
|
|
79
|
+
p = base_p * (1.0 + amp * trace)
|
|
80
|
+
return jnp.clip(p, 0.01, 0.5)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dense-evolution
|
|
3
|
-
Version: 8.2.
|
|
3
|
+
Version: 8.2.2
|
|
4
4
|
Summary: High-performance quantum simulation toolkit -- Statevector/MPS engines with JIT compilation, noise modeling, VQE, QEC, quantum chemistry, and agent-native tooling
|
|
5
5
|
Author-email: Salvatore Pennacchio <jtatopenn@libero.it>
|
|
6
6
|
License: Business Source License 1.1
|
|
@@ -84,6 +84,7 @@ dense_evolution/noise/density_matrix_channels.py
|
|
|
84
84
|
dense_evolution/noise/differentiable.py
|
|
85
85
|
dense_evolution/noise/kraus_channels.py
|
|
86
86
|
dense_evolution/noise/oscillating.py
|
|
87
|
+
dense_evolution/noise/pink.py
|
|
87
88
|
dense_evolution/noise/kraus/__init__.py
|
|
88
89
|
dense_evolution/noise/kraus/amplitude_damping.py
|
|
89
90
|
dense_evolution/noise/kraus/bitflip.py
|
|
@@ -119,13 +120,17 @@ tools/dashboard/core/_gate_tables.py
|
|
|
119
120
|
tools/dashboard/core/band_structure.py
|
|
120
121
|
tools/dashboard/core/circuit_builder_component.py
|
|
121
122
|
tools/dashboard/core/circuit_diagram.py
|
|
123
|
+
tools/dashboard/core/crypto_protocols.py
|
|
122
124
|
tools/dashboard/core/engine.py
|
|
123
125
|
tools/dashboard/core/graphical_builder.py
|
|
124
126
|
tools/dashboard/core/hamiltonians.py
|
|
127
|
+
tools/dashboard/core/mass_decomposition_tool.py
|
|
125
128
|
tools/dashboard/core/mitigation.py
|
|
129
|
+
tools/dashboard/core/native_hf_diagnostics.py
|
|
126
130
|
tools/dashboard/core/noise_tools.py
|
|
127
131
|
tools/dashboard/core/qasm_library.py
|
|
128
132
|
tools/dashboard/core/qmmm.py
|
|
133
|
+
tools/dashboard/core/rag_tool.py
|
|
129
134
|
tools/dashboard/core/state_visuals.py
|
|
130
135
|
tools/dashboard/core/system_limits.py
|
|
131
136
|
tools/dashboard/core/vector_healing.py
|
|
@@ -145,8 +150,10 @@ tools/mcp_server/server.py
|
|
|
145
150
|
tools/mcp_server/tools/__init__.py
|
|
146
151
|
tools/mcp_server/tools/chemistry_tools.py
|
|
147
152
|
tools/mcp_server/tools/circuit_tools.py
|
|
153
|
+
tools/mcp_server/tools/crypto_tools.py
|
|
148
154
|
tools/mcp_server/tools/mitigation_tools.py
|
|
149
155
|
tools/mcp_server/tools/noise_tools.py
|
|
156
|
+
tools/mcp_server/tools/retrieval_tools.py
|
|
150
157
|
tools/mcp_server/tools/system_tools.py
|
|
151
158
|
tools/mcp_server/tools/wormhole_tools.py
|
|
152
159
|
tools/mcp_server/utils/__init__.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dense-evolution"
|
|
7
|
-
version = "8.2.
|
|
7
|
+
version = "8.2.2"
|
|
8
8
|
description = "High-performance quantum simulation toolkit -- Statevector/MPS engines with JIT compilation, noise modeling, VQE, QEC, quantum chemistry, and agent-native tooling"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -606,6 +606,190 @@ def mitigate_matrix(req: MitigateMatrixRequest):
|
|
|
606
606
|
}
|
|
607
607
|
|
|
608
608
|
|
|
609
|
+
@app.post("/api/mitigate_coherence")
|
|
610
|
+
def mitigate_coherence(req: MitigateMatrixRequest):
|
|
611
|
+
"""Coherence-L1-predictive density-matrix ZNE
|
|
612
|
+
(dense_evolution.coherence_predictive_zne_density_matrix): same
|
|
613
|
+
Monte-Carlo construction as /api/mitigate_matrix, but extrapolated via
|
|
614
|
+
a signal that covers phase-type noise (phaseflip, dephasing) the
|
|
615
|
+
classical-JSD signal behind /api/mitigate_matrix is structurally blind
|
|
616
|
+
to (JSD only ever reads the density matrix's diagonal)."""
|
|
617
|
+
try:
|
|
618
|
+
result = dc.run_coherence_zne_mitigation(req.qasm, req.noise_model, req.noise_p, seed=req.seed)
|
|
619
|
+
except Exception as exc:
|
|
620
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
621
|
+
return {
|
|
622
|
+
"n_qubits": result.n_qubits,
|
|
623
|
+
"noise_factors": result.noise_factors,
|
|
624
|
+
"fidelity_raw": result.fidelity_raw,
|
|
625
|
+
"fidelity_corrected": result.fidelity_corrected,
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
class Bb84Request(BaseModel):
|
|
630
|
+
n_rounds: int
|
|
631
|
+
p_channel: float = 0.0
|
|
632
|
+
eve: bool = False
|
|
633
|
+
seed: int | None = None
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
@app.post("/api/crypto/bb84")
|
|
637
|
+
def crypto_bb84(req: Bb84Request):
|
|
638
|
+
"""BB84: prepare -> channel -> measure -> sift -> QBER
|
|
639
|
+
(dense_evolution.protocols.bb84)."""
|
|
640
|
+
try:
|
|
641
|
+
result = dc.run_bb84(req.n_rounds, req.p_channel, eve=req.eve, seed=req.seed)
|
|
642
|
+
except Exception as exc:
|
|
643
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
644
|
+
return {
|
|
645
|
+
"n_rounds": result.n_rounds, "p_channel": result.p_channel, "eve": result.eve,
|
|
646
|
+
"qber": result.qber, "sifted_key_length": result.sifted_key_length,
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
class DiQkdGhzRequest(BaseModel):
|
|
651
|
+
n_rounds: int
|
|
652
|
+
p_dep: float = 0.0
|
|
653
|
+
seed: int | None = None
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
@app.post("/api/crypto/di_qkd_ghz")
|
|
657
|
+
def crypto_di_qkd_ghz(req: DiQkdGhzRequest):
|
|
658
|
+
"""Three-party device-independent conference key agreement via GHZ(3)
|
|
659
|
+
(Ribeiro, Murta & Wehner 2018, arXiv:1708.00798;
|
|
660
|
+
dense_evolution.protocols.di_qkd_ghz)."""
|
|
661
|
+
try:
|
|
662
|
+
result = dc.run_di_qkd_ghz(req.n_rounds, req.p_dep, seed=req.seed)
|
|
663
|
+
except Exception as exc:
|
|
664
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
665
|
+
return {
|
|
666
|
+
"n_rounds": result.n_rounds, "p_dep": result.p_dep,
|
|
667
|
+
"win_rate": result.win_rate, "expected_win_rate": result.expected_win_rate,
|
|
668
|
+
"qber_b1": result.qber_b1, "qber_b2": result.qber_b2,
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
class DickaRequest(BaseModel):
|
|
673
|
+
n_rounds: int
|
|
674
|
+
gamma: float
|
|
675
|
+
beta: float
|
|
676
|
+
p_dep: float = 0.0
|
|
677
|
+
seed: int | None = None
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
@app.post("/api/crypto/dicka")
|
|
681
|
+
def crypto_dicka(req: DickaRequest):
|
|
682
|
+
"""Full multi-round DICKA structure (Appendix Protocol 2 of Ribeiro,
|
|
683
|
+
Murta & Wehner 2018; dense_evolution.protocols.dicka_protocol2). beta
|
|
684
|
+
must sit strictly between the classical bound (0.75) and the quantum
|
|
685
|
+
max (~0.8536) to meaningfully distinguish a device-independent
|
|
686
|
+
channel from a classically-bound one -- the underlying run_protocol
|
|
687
|
+
itself does not enforce this (any beta silently changes only the
|
|
688
|
+
abort decision), so it's checked here instead."""
|
|
689
|
+
from dense_evolution.protocols.dicka_protocol2 import CLASSICAL_BOUND, QUANTUM_MAX
|
|
690
|
+
if not (CLASSICAL_BOUND < req.beta < QUANTUM_MAX):
|
|
691
|
+
raise HTTPException(
|
|
692
|
+
status_code=400,
|
|
693
|
+
detail=f"beta must be strictly between {CLASSICAL_BOUND} and {QUANTUM_MAX}, got {req.beta}",
|
|
694
|
+
)
|
|
695
|
+
try:
|
|
696
|
+
return dc.run_dicka_protocol(req.n_rounds, req.gamma, req.beta, p_dep=req.p_dep, seed=req.seed)
|
|
697
|
+
except Exception as exc:
|
|
698
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
class NativeHfDiagnosticsRequest(BaseModel):
|
|
702
|
+
symbols: list
|
|
703
|
+
geometry: list
|
|
704
|
+
charge: int = 0
|
|
705
|
+
active_electrons: int | None = None
|
|
706
|
+
active_orbitals: int | None = None
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
@app.post("/api/native_hf/diagnose")
|
|
710
|
+
def native_hf_diagnose(req: NativeHfDiagnosticsRequest):
|
|
711
|
+
"""Real Hartree-Fock SCF (dense_evolution.native_hf) plus Dense-Armor
|
|
712
|
+
anomaly diagnostics on the real per-iteration energy trace, instead of
|
|
713
|
+
trusting the final `converged` flag alone. Needs the `armor` extra."""
|
|
714
|
+
if len(req.symbols) != len(req.geometry):
|
|
715
|
+
raise HTTPException(
|
|
716
|
+
status_code=400,
|
|
717
|
+
detail=f"{len(req.symbols)} symbols but {len(req.geometry)} geometry rows",
|
|
718
|
+
)
|
|
719
|
+
try:
|
|
720
|
+
result = dc.run_native_hf_diagnostics(
|
|
721
|
+
req.symbols, req.geometry, charge=req.charge,
|
|
722
|
+
active_electrons=req.active_electrons, active_orbitals=req.active_orbitals,
|
|
723
|
+
)
|
|
724
|
+
except ImportError as exc:
|
|
725
|
+
raise HTTPException(status_code=400, detail=f"missing optional dependency: {exc}")
|
|
726
|
+
except Exception as exc:
|
|
727
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
728
|
+
return {
|
|
729
|
+
"n_qubits": result.n_qubits, "converged": result.converged, "n_iterations": result.n_iterations,
|
|
730
|
+
"electronic_energy_hartree": result.electronic_energy_hartree, "total_energy_hartree": result.total_energy_hartree,
|
|
731
|
+
"n_anomalies_hampel": result.n_anomalies_hampel, "n_anomalies_tukey": result.n_anomalies_tukey,
|
|
732
|
+
"anomaly_fraction_hampel": result.anomaly_fraction_hampel, "anomaly_fraction_tukey": result.anomaly_fraction_tukey,
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
class MassDecompositionRequest(BaseModel):
|
|
737
|
+
formula: str
|
|
738
|
+
target_mass: float
|
|
739
|
+
max_mass: float | None = None
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
@app.post("/api/mass_decomposition")
|
|
743
|
+
def mass_decomposition(req: MassDecompositionRequest):
|
|
744
|
+
"""Check whether target_mass is a chemically valid, reachable
|
|
745
|
+
sub-formula mass of `formula` (dense_evolution.utils.mass_decomposition,
|
|
746
|
+
promoted from CASMI26 spectral-identification work)."""
|
|
747
|
+
try:
|
|
748
|
+
result = dc.run_mass_decomposition(req.formula, req.target_mass, max_mass=req.max_mass)
|
|
749
|
+
except Exception as exc:
|
|
750
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
751
|
+
return {
|
|
752
|
+
"formula_counts": result.formula_counts, "rdbe": result.rdbe,
|
|
753
|
+
"nearest_reachable_mass": result.nearest_reachable_mass,
|
|
754
|
+
"density_at_target": result.density_at_target,
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
class RagSearchRequest(BaseModel):
|
|
759
|
+
documents: list # [[text, source], ...]
|
|
760
|
+
query: str
|
|
761
|
+
top: int = 5
|
|
762
|
+
rerank: bool = True
|
|
763
|
+
exact: bool = False
|
|
764
|
+
regex: bool = False
|
|
765
|
+
max_hits: int = 10
|
|
766
|
+
context: int = 300
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
@app.post("/api/rag_search")
|
|
770
|
+
def rag_search(req: RagSearchRequest):
|
|
771
|
+
"""Build an ephemeral index over the caller's own documents and search
|
|
772
|
+
it in one call (ia_utils.rag) -- nothing persists server-side between
|
|
773
|
+
requests. exact=True switches to substring/regex search over raw
|
|
774
|
+
chunk text instead of semantic search (no embedding, no reranker).
|
|
775
|
+
Needs the `rag` extra for semantic search; exact mode still needs it
|
|
776
|
+
to build the index (TF-IDF), but not to search once built."""
|
|
777
|
+
try:
|
|
778
|
+
documents = [(d[0], d[1]) for d in req.documents]
|
|
779
|
+
except (IndexError, TypeError):
|
|
780
|
+
raise HTTPException(status_code=400, detail="documents must be a list of [text, source] pairs")
|
|
781
|
+
try:
|
|
782
|
+
result = dc.run_rag_search(
|
|
783
|
+
documents, req.query, top=req.top, rerank=req.rerank,
|
|
784
|
+
exact=req.exact, regex=req.regex, max_hits=req.max_hits, context=req.context,
|
|
785
|
+
)
|
|
786
|
+
except ImportError as exc:
|
|
787
|
+
raise HTTPException(status_code=400, detail=f"missing optional dependency: {exc}")
|
|
788
|
+
except Exception as exc:
|
|
789
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
790
|
+
return {"results": result.results}
|
|
791
|
+
|
|
792
|
+
|
|
609
793
|
class CosmicRayBurstRequest(BaseModel):
|
|
610
794
|
baseline_gamma: float
|
|
611
795
|
times_us: Optional[List[float]] = None
|
|
@@ -54,7 +54,14 @@ from .hamiltonians import (
|
|
|
54
54
|
)
|
|
55
55
|
from .mitigation import (
|
|
56
56
|
MitigationResult, run_zne_mitigation, DensityMatrixZNEResult, run_density_matrix_zne,
|
|
57
|
+
CoherenceZNEResult, run_coherence_zne_mitigation,
|
|
57
58
|
)
|
|
59
|
+
from .crypto_protocols import (
|
|
60
|
+
Bb84Result, run_bb84, DiQkdGhzResult, run_di_qkd_ghz, run_dicka_protocol,
|
|
61
|
+
)
|
|
62
|
+
from .native_hf_diagnostics import NativeHfDiagnosticsResult, run_native_hf_diagnostics
|
|
63
|
+
from .mass_decomposition_tool import MassDecompositionResult, run_mass_decomposition
|
|
64
|
+
from .rag_tool import RagSearchResult, run_rag_search
|
|
58
65
|
from .system_limits import max_safe_dense_qubits
|
|
59
66
|
from .vqe import run_vqe, scan_hardware_efficient_energy_landscape
|
|
60
67
|
from .qmmm import (
|
|
@@ -89,6 +96,11 @@ __all__ = [
|
|
|
89
96
|
'linear_chain_geometry', 'ring_geometry', 'mix_hamiltonians',
|
|
90
97
|
'MitigationResult', 'run_zne_mitigation',
|
|
91
98
|
'DensityMatrixZNEResult', 'run_density_matrix_zne',
|
|
99
|
+
'CoherenceZNEResult', 'run_coherence_zne_mitigation',
|
|
100
|
+
'Bb84Result', 'run_bb84', 'DiQkdGhzResult', 'run_di_qkd_ghz', 'run_dicka_protocol',
|
|
101
|
+
'NativeHfDiagnosticsResult', 'run_native_hf_diagnostics',
|
|
102
|
+
'MassDecompositionResult', 'run_mass_decomposition',
|
|
103
|
+
'RagSearchResult', 'run_rag_search',
|
|
92
104
|
'max_safe_dense_qubits',
|
|
93
105
|
'run_vqe', 'scan_hardware_efficient_energy_landscape',
|
|
94
106
|
'ATOMIC_MASSES_AMU',
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Thin wrappers around dense_evolution.protocols (crypto-q, promoted from
|
|
3
|
+
Dense-Evolution-Discovery issue #189) for the Composer kernel -- see
|
|
4
|
+
docs/api/protocols.md for the real, validated numbers behind each
|
|
5
|
+
protocol. Each function here just calls straight into the real protocol
|
|
6
|
+
module and returns a plain dict; no new cryptographic logic lives here.
|
|
7
|
+
"""
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
|
|
10
|
+
from dense_evolution.protocols import bb84 as _bb84
|
|
11
|
+
from dense_evolution.protocols import di_qkd_ghz as _di_qkd_ghz
|
|
12
|
+
from dense_evolution.protocols import dicka_protocol2 as _dicka
|
|
13
|
+
|
|
14
|
+
__all__ = ['Bb84Result', 'run_bb84', 'DiQkdGhzResult', 'run_di_qkd_ghz', 'run_dicka_protocol']
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class Bb84Result:
|
|
19
|
+
n_rounds: int
|
|
20
|
+
p_channel: float
|
|
21
|
+
eve: bool
|
|
22
|
+
qber: float
|
|
23
|
+
sifted_key_length: int
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def run_bb84(n_rounds: int, p_channel: float = 0.0, eve: bool = False, seed=None) -> Bb84Result:
|
|
27
|
+
"""BB84: prepare -> channel -> measure -> sift -> QBER
|
|
28
|
+
(dense_evolution.protocols.bb84.bb84_run). QBER=0 on a perfect
|
|
29
|
+
channel, `2*p_channel/3` under isotropic depolarizing noise,
|
|
30
|
+
`0.25` under an intercept-resend attack (`eve=True`) -- see
|
|
31
|
+
docs/api/protocols.md for the validated numbers this reproduces."""
|
|
32
|
+
qber, sifted_key_length = _bb84.bb84_run(n_rounds, p_channel, eve=eve, seed=seed)
|
|
33
|
+
return Bb84Result(
|
|
34
|
+
n_rounds=n_rounds, p_channel=p_channel, eve=eve,
|
|
35
|
+
qber=float(qber), sifted_key_length=int(sifted_key_length),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass
|
|
40
|
+
class DiQkdGhzResult:
|
|
41
|
+
n_rounds: int
|
|
42
|
+
p_dep: float
|
|
43
|
+
win_rate: float
|
|
44
|
+
expected_win_rate: float
|
|
45
|
+
qber_b1: float
|
|
46
|
+
qber_b2: float
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def run_di_qkd_ghz(n_rounds: int, p_dep: float = 0.0, seed=None) -> DiQkdGhzResult:
|
|
50
|
+
"""Three-party device-independent conference key agreement via GHZ(3)
|
|
51
|
+
(Ribeiro, Murta & Wehner 2018, arXiv:1708.00798;
|
|
52
|
+
dense_evolution.protocols.di_qkd_ghz). `win_rate` is the real,
|
|
53
|
+
simulated Parity-CHSH win rate over `n_rounds` test rounds;
|
|
54
|
+
`expected_win_rate` is the exact theoretical value at this `p_dep`
|
|
55
|
+
(quantum max `0.85355...` at `p_dep=0`) -- comparing the two directly
|
|
56
|
+
checks the simulation against the closed-form prediction, not just
|
|
57
|
+
against itself."""
|
|
58
|
+
win_rate = _di_qkd_ghz.parity_chsh_win_rate(n_rounds, p_dep, seed=seed)
|
|
59
|
+
qber_b1, qber_b2 = _di_qkd_ghz.key_qber(n_rounds, p_dep, seed=seed)
|
|
60
|
+
return DiQkdGhzResult(
|
|
61
|
+
n_rounds=n_rounds, p_dep=p_dep,
|
|
62
|
+
win_rate=float(win_rate), expected_win_rate=float(_di_qkd_ghz.expected_win_rate(p_dep)),
|
|
63
|
+
qber_b1=float(qber_b1), qber_b2=float(qber_b2),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def run_dicka_protocol(n_rounds: int, gamma: float, beta: float, p_dep: float = 0.0, seed=None) -> dict:
|
|
68
|
+
"""Full multi-round DICKA structure (Appendix Protocol 2 of Ribeiro,
|
|
69
|
+
Murta & Wehner 2018; dense_evolution.protocols.dicka_protocol2):
|
|
70
|
+
round selection, parameter estimation, and the abort decision.
|
|
71
|
+
Already returns a plain, JSON-safe dict -- see run_protocol's own
|
|
72
|
+
docstring for exactly what each field means. Deliberately does not
|
|
73
|
+
report a secure key length: Theorem 4's exact value depends on a
|
|
74
|
+
numerical optimization the source paper never reduces to closed form."""
|
|
75
|
+
result = _dicka.run_protocol(n_rounds=n_rounds, gamma=gamma, beta=beta, p_dep=p_dep, seed=seed)
|
|
76
|
+
result["aborted"] = bool(result["aborted"])
|
|
77
|
+
return result
|