vgon 0.0.0__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.
- vgon-0.0.0/PKG-INFO +29 -0
- vgon-0.0.0/README.md +178 -0
- vgon-0.0.0/pyproject.toml +95 -0
- vgon-0.0.0/setup.cfg +4 -0
- vgon-0.0.0/src/vgon/__init__.py +1 -0
- vgon-0.0.0/src/vgon/examples/__init__.py +0 -0
- vgon-0.0.0/src/vgon/examples/gap/__init__.py +9 -0
- vgon-0.0.0/src/vgon/examples/gap/lo.py +46 -0
- vgon-0.0.0/src/vgon/examples/gap/locc.py +57 -0
- vgon-0.0.0/src/vgon/examples/gap/ns.py +44 -0
- vgon-0.0.0/src/vgon.egg-info/PKG-INFO +29 -0
- vgon-0.0.0/src/vgon.egg-info/SOURCES.txt +13 -0
- vgon-0.0.0/src/vgon.egg-info/dependency_links.txt +1 -0
- vgon-0.0.0/src/vgon.egg-info/requires.txt +25 -0
- vgon-0.0.0/src/vgon.egg-info/top_level.txt +1 -0
vgon-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vgon
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Variational Generative Optimization Network (VGON).
|
|
5
|
+
Author: Lingxia Zhang, Xiaodie Lin
|
|
6
|
+
Project-URL: Homepage, https://vgon.funqitang.cn
|
|
7
|
+
Project-URL: Repository, https://github.com/zhangjianjianzz/VGON.git
|
|
8
|
+
Project-URL: Documentation, https://vgon.funqitang.cn
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Provides-Extra: core
|
|
11
|
+
Requires-Dist: torch; extra == "core"
|
|
12
|
+
Requires-Dist: toqito>=1.1.2; extra == "core"
|
|
13
|
+
Requires-Dist: cvxpy>=1.7.2; extra == "core"
|
|
14
|
+
Requires-Dist: cvxpylayers>=0.1.9; extra == "core"
|
|
15
|
+
Requires-Dist: pennylane>=0.42.3; extra == "core"
|
|
16
|
+
Requires-Dist: pennylane-lightning>=0.42.0; extra == "core"
|
|
17
|
+
Provides-Extra: plot
|
|
18
|
+
Requires-Dist: pandas>=2.3.2; extra == "plot"
|
|
19
|
+
Requires-Dist: ptiprince>=0.2.7; extra == "plot"
|
|
20
|
+
Requires-Dist: scipy>=1.16.2; extra == "plot"
|
|
21
|
+
Requires-Dist: seaborn>=0.13.2; extra == "plot"
|
|
22
|
+
Provides-Extra: notebook
|
|
23
|
+
Requires-Dist: ipykernel>=6.30.1; extra == "notebook"
|
|
24
|
+
Provides-Extra: doc
|
|
25
|
+
Requires-Dist: mkdocs-material; extra == "doc"
|
|
26
|
+
Requires-Dist: mkdocs-literate-nav>=0.6.2; extra == "doc"
|
|
27
|
+
Requires-Dist: mdx-truly-sane-lists>=1.3; extra == "doc"
|
|
28
|
+
Provides-Extra: full
|
|
29
|
+
Requires-Dist: vgon[core,doc,notebook,plot]; extra == "full"
|
vgon-0.0.0/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# VGON Environment Setup
|
|
2
|
+
|
|
3
|
+
VGON scripts here require Python version 3.11 and above.
|
|
4
|
+
|
|
5
|
+
This guide provides instructions for setting up the VGON (Variational Generative Optimization Network) environment using either `uv` or `pip`.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Python 3.11 or higher
|
|
10
|
+
- Git
|
|
11
|
+
|
|
12
|
+
## Method 1: Using uv (Recommended)
|
|
13
|
+
|
|
14
|
+
[uv](https://github.com/astral-sh/uv) is a fast Python package manager and project manager, whose installation is simple as [guide](https://docs.astral.sh/uv/#installation)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Setup with uv
|
|
18
|
+
1. Clone the repository to local disk.
|
|
19
|
+
```bash
|
|
20
|
+
git clone https://github.com/zhangjianjianzz/VGON.git && cd VGON
|
|
21
|
+
```
|
|
22
|
+
2. Create virtual environment if it wasn't contained
|
|
23
|
+
```bash
|
|
24
|
+
uv venv .venv
|
|
25
|
+
```
|
|
26
|
+
The python virtual environment will be located at `.venv` fold under root path in default. Linux/macOS users could activate it in shell by typing
|
|
27
|
+
```bash
|
|
28
|
+
source .venv/bin/activate
|
|
29
|
+
```
|
|
30
|
+
3. Install dependecies in `.venv` for VGON scripts
|
|
31
|
+
```bash
|
|
32
|
+
uv sync --extra full
|
|
33
|
+
```
|
|
34
|
+
`plot` and `notebook` groups are optional for VGON itself.
|
|
35
|
+
|
|
36
|
+
4. Running experiments with uv
|
|
37
|
+
```bash
|
|
38
|
+
# Run specific experiments
|
|
39
|
+
uv run python BP/HXXZ/vgon_xxz.py
|
|
40
|
+
uv run python Gap/Mix.py
|
|
41
|
+
uv run python Degeneracy/H232/H232.py
|
|
42
|
+
|
|
43
|
+
# Or activate environment first
|
|
44
|
+
source .venv/bin/activate
|
|
45
|
+
python BP/HXXZ/plot.py
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Method 2: Using pip
|
|
49
|
+
|
|
50
|
+
### Setup with pip
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Clone the repository
|
|
54
|
+
git clone <your-repo-url>
|
|
55
|
+
cd VGON
|
|
56
|
+
|
|
57
|
+
# Create virtual environment
|
|
58
|
+
python -m venv venv
|
|
59
|
+
|
|
60
|
+
# Activate virtual environment
|
|
61
|
+
source venv/bin/activate # On Linux/macOS
|
|
62
|
+
# or
|
|
63
|
+
venv\Scripts\activate # On Windows
|
|
64
|
+
|
|
65
|
+
# Upgrade pip
|
|
66
|
+
pip install --upgrade pip
|
|
67
|
+
|
|
68
|
+
# Install PyTorch (CPU version)
|
|
69
|
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
|
70
|
+
|
|
71
|
+
# For GPU support (CUDA 12.1), use instead:
|
|
72
|
+
# pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
|
73
|
+
|
|
74
|
+
# Install the package with dependencies
|
|
75
|
+
pip install -e .
|
|
76
|
+
|
|
77
|
+
# Install optional dependencies
|
|
78
|
+
pip install -e ".[plot]" # For plotting
|
|
79
|
+
pip install -e ".[dev]" # For development
|
|
80
|
+
pip install -e ".[gpu]" # For GPU acceleration
|
|
81
|
+
pip install -e ".[all]" # Install everything
|
|
82
|
+
|
|
83
|
+
# Manual installation of ptitprince (if needed)
|
|
84
|
+
pip install git+https://github.com/pog87/PtitPrince.git
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Verify Installation
|
|
88
|
+
|
|
89
|
+
Test your installation by running a simple example:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import torch
|
|
93
|
+
import pennylane as qml
|
|
94
|
+
import numpy as np
|
|
95
|
+
|
|
96
|
+
# Test basic functionality
|
|
97
|
+
print(f"PyTorch version: {torch.__version__}")
|
|
98
|
+
print(f"PennyLane version: {qml.__version__}")
|
|
99
|
+
print(f"CUDA available: {torch.cuda.is_available()}")
|
|
100
|
+
|
|
101
|
+
# Test quantum device
|
|
102
|
+
dev = qml.device("default.qubit", wires=2)
|
|
103
|
+
print("✓ PennyLane quantum device created successfully")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Project Structure
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
VGON/
|
|
110
|
+
├── BP/ # Barren Plateau experiments
|
|
111
|
+
│ ├── HXXZ/ # Heisenberg XXZ model
|
|
112
|
+
│ └── Z1Z2/ # Z1Z2 model
|
|
113
|
+
├── Degeneracy/ # Degeneracy detection experiments
|
|
114
|
+
│ ├── H232/ # H232 Hamiltonian
|
|
115
|
+
│ └── MG/ # Graph states
|
|
116
|
+
├── Gap/ # Nonlocality gap experiments
|
|
117
|
+
└── results/ # Experimental results
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Running Experiments
|
|
121
|
+
|
|
122
|
+
### Barren Plateau Experiments
|
|
123
|
+
```bash
|
|
124
|
+
# HXXZ model
|
|
125
|
+
python BP/HXXZ/vgon_xxz.py # Run VGON training
|
|
126
|
+
python BP/HXXZ/vqe_xxz.py # Run VQE baseline
|
|
127
|
+
python BP/HXXZ/plot.py # Generate plots
|
|
128
|
+
|
|
129
|
+
# Z1Z2 model
|
|
130
|
+
python BP/Z1Z2/vgon_z1z2.py
|
|
131
|
+
python BP/Z1Z2/vqe_z1z2.py
|
|
132
|
+
python BP/Z1Z2/plot.py
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Degeneracy Detection
|
|
136
|
+
```bash
|
|
137
|
+
# H232 Hamiltonian
|
|
138
|
+
python Degeneracy/H232/H232.py
|
|
139
|
+
python Degeneracy/H232/plot.py
|
|
140
|
+
|
|
141
|
+
# Graph states
|
|
142
|
+
python Degeneracy/MG/MG.py
|
|
143
|
+
python Degeneracy/MG/plot.py
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Nonlocality Gap
|
|
147
|
+
```bash
|
|
148
|
+
python Gap/Mix.py # Train gap model
|
|
149
|
+
matlab -batch "run('Gap/plotGap.m')" # Generate MATLAB plots
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Troubleshooting
|
|
153
|
+
|
|
154
|
+
### Common Issues
|
|
155
|
+
|
|
156
|
+
1. **CUDA not found**: If you have a GPU but CUDA is not detected, reinstall PyTorch with CUDA support
|
|
157
|
+
2. **PennyLane device errors**: Ensure you have the correct PennyLane plugins installed
|
|
158
|
+
3. **Memory issues**: Reduce batch sizes in the configuration files
|
|
159
|
+
4. **Import errors**: Make sure all dependencies are installed correctly
|
|
160
|
+
|
|
161
|
+
### GPU Setup
|
|
162
|
+
|
|
163
|
+
For GPU acceleration:
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
### Development Setup
|
|
167
|
+
|
|
168
|
+
For contributors:
|
|
169
|
+
|
|
170
|
+
## Support
|
|
171
|
+
|
|
172
|
+
- Paper: [Commun Phys 8, 334 (2025)](https://doi.org/10.1038/s42005-025-02261-4)
|
|
173
|
+
- Issues: Create an issue on the GitHub repository
|
|
174
|
+
- Documentation: See individual module docstrings and comments
|
|
175
|
+
|
|
176
|
+
# [Development Containers](https://containers.dev/)
|
|
177
|
+
DevContainers' configuration in vscode/GitHub Codespace.
|
|
178
|
+
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=65.5.0", "wheel>=0.38.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vgon"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Variational Generative Optimization Network (VGON)."
|
|
9
|
+
authors = [
|
|
10
|
+
{name = "Lingxia Zhang"},
|
|
11
|
+
{name = "Xiaodie Lin"}
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
|
|
15
|
+
dependencies = []
|
|
16
|
+
|
|
17
|
+
[project.optional-dependencies]
|
|
18
|
+
core = [
|
|
19
|
+
"torch",
|
|
20
|
+
"toqito>=1.1.2",
|
|
21
|
+
"cvxpy>=1.7.2",
|
|
22
|
+
"cvxpylayers>=0.1.9",
|
|
23
|
+
"pennylane>=0.42.3",
|
|
24
|
+
"pennylane-lightning>=0.42.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
# uv sync --extra plot --extra notebook -U
|
|
28
|
+
# you could cancle 'plot' block to use basic feature.
|
|
29
|
+
plot = [
|
|
30
|
+
"pandas>=2.3.2",
|
|
31
|
+
"ptiprince>=0.2.7",
|
|
32
|
+
"scipy>=1.16.2",
|
|
33
|
+
"seaborn>=0.13.2",
|
|
34
|
+
]
|
|
35
|
+
notebook = [
|
|
36
|
+
"ipykernel>=6.30.1",
|
|
37
|
+
]
|
|
38
|
+
doc = [
|
|
39
|
+
"mkdocs-material",
|
|
40
|
+
"mkdocs-literate-nav>=0.6.2",
|
|
41
|
+
"mdx-truly-sane-lists>=1.3",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
# All optional dependencies
|
|
45
|
+
full = [
|
|
46
|
+
"vgon[core,plot,notebook,doc]"
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# package-location
|
|
51
|
+
[tool.setuptools]
|
|
52
|
+
package-dir = {"" = "src"}
|
|
53
|
+
include-package-data = true
|
|
54
|
+
# package-name-rule
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
include = ["vgon", "vgon.*"]
|
|
58
|
+
exclude = ["tests", "docs"]
|
|
59
|
+
# package-data-rule
|
|
60
|
+
[tool.setuptools.package-data]
|
|
61
|
+
vgon = ["Examples/**/*.mat", "Examples/**/*.csv", "Examples/**/*.json"]
|
|
62
|
+
[tools.setuptools_scm]
|
|
63
|
+
write_to = "src/vgon/_version.py"
|
|
64
|
+
version_scheme = "guess-next-dev"
|
|
65
|
+
local_scheme = "no-local-version"
|
|
66
|
+
|
|
67
|
+
[project.urls]
|
|
68
|
+
Homepage = "https://vgon.funqitang.cn"
|
|
69
|
+
Repository = "https://github.com/zhangjianjianzz/VGON.git"
|
|
70
|
+
Documentation = "https://vgon.funqitang.cn"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
[tool.uv.sources]
|
|
75
|
+
# "pytorch-cpu", "pytorch-cuda"
|
|
76
|
+
# For users outside of CUDA eco, redirect torch.index to "pytorch-cpu"
|
|
77
|
+
torch = { index = "pytorch-cuda" }
|
|
78
|
+
# dependency-updated repo forked from [pog87/PtitPrince](https://github.com/pog87/PtitPrince.git)
|
|
79
|
+
ptiprince = {git = "https://github.com/leo2www/PtitPrince.git"}
|
|
80
|
+
mkdocs-material = { git = "https://github.com/squidfunk/mkdocs-material.git" }
|
|
81
|
+
|
|
82
|
+
# pennylane = { git = "https://github.com/PennyLaneAI/pennylane.git" }
|
|
83
|
+
# seaborn = {git = "https://github.com/mwaskom/seaborn.git"}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
[[tool.uv.index]]
|
|
88
|
+
name = "pytorch-cpu"
|
|
89
|
+
url = "https://download.pytorch.org/whl/cpu"
|
|
90
|
+
explicit = true
|
|
91
|
+
|
|
92
|
+
[[tool.uv.index]]
|
|
93
|
+
name = "pytorch-cuda"
|
|
94
|
+
url = "https://download.pytorch.org/whl/cu129"
|
|
95
|
+
explicit = true
|
vgon-0.0.0/setup.cfg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from vgon._version import __version__
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import cvxpy as cp
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from .ns import __initialize_Ns__
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def E2Lo():
|
|
8
|
+
rho = cp.Parameter((9, 9))
|
|
9
|
+
e1 = cp.Parameter(1)
|
|
10
|
+
|
|
11
|
+
# parameters
|
|
12
|
+
d = X = A = 3
|
|
13
|
+
size = d**2
|
|
14
|
+
|
|
15
|
+
# formulate sdp
|
|
16
|
+
# variables
|
|
17
|
+
P_lo = cp.Variable((2, X**2 * A**2), nonneg=True) # [gamma, xyab]
|
|
18
|
+
M0_lo = cp.Variable((size, size), hermitian=True)
|
|
19
|
+
M1_lo = cp.Variable((size, size), hermitian=True)
|
|
20
|
+
e2_lo = cp.Variable(1, nonneg=True)
|
|
21
|
+
# construct MC, MU
|
|
22
|
+
Ns = __initialize_Ns__()
|
|
23
|
+
|
|
24
|
+
# reshape in cvxpy rearranges elements column by column, so transpose (.T) is needed
|
|
25
|
+
PU_lo = cp.reshape(P_lo[0], (1, size**2))
|
|
26
|
+
MU_lo = cp.reshape(PU_lo @ Ns, (size, size)).T
|
|
27
|
+
PC_lo = cp.reshape(P_lo[1], (1, size**2))
|
|
28
|
+
MC_lo = cp.reshape(PC_lo @ Ns, (size, size)).T
|
|
29
|
+
|
|
30
|
+
# constraints
|
|
31
|
+
constraints = [M0_lo >> 0, M1_lo >> 0]
|
|
32
|
+
constraints += [
|
|
33
|
+
e1 * np.eye(size, dtype=complex) - MC_lo == M0_lo + cp.partial_transpose(M1_lo, dims=(d, d), axis=1)
|
|
34
|
+
]
|
|
35
|
+
# constraints of P - lo
|
|
36
|
+
Pxy_ab_lo = cp.reshape(cp.sum(P_lo, axis=0), (A**2, X**2)).T
|
|
37
|
+
for i in range(Pxy_ab_lo.shape[1] - 1):
|
|
38
|
+
for j in range(i + 1, Pxy_ab_lo.shape[1]):
|
|
39
|
+
constraints += [Pxy_ab_lo[:, i] - Pxy_ab_lo[:, j] == np.zeros(Pxy_ab_lo.shape[0])]
|
|
40
|
+
constraints += [cp.sum(Pxy_ab_lo[:, 0]) == 1]
|
|
41
|
+
constraints += [e2_lo == cp.real(cp.trace(MU_lo @ rho))]
|
|
42
|
+
|
|
43
|
+
# problem
|
|
44
|
+
parameter = [rho, e1]
|
|
45
|
+
variable = [e2_lo, P_lo, M0_lo, M1_lo]
|
|
46
|
+
return cp.Problem(cp.Minimize(cp.real(cp.trace(MU_lo @ rho))), constraints), parameter, variable
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import cvxpy as cp
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from .ns import __initialize_Ns__
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def E2Locc():
|
|
8
|
+
rho = cp.Parameter((9, 9))
|
|
9
|
+
e1 = cp.Parameter(1)
|
|
10
|
+
|
|
11
|
+
# parameters
|
|
12
|
+
d = X = A = 3
|
|
13
|
+
size = d**2
|
|
14
|
+
|
|
15
|
+
# formulate sdp
|
|
16
|
+
# variables
|
|
17
|
+
P_locc = cp.Variable((2, X**2 * A**2), nonneg=True) # [gamma, xyab]
|
|
18
|
+
M0_locc = cp.Variable((size, size), hermitian=True)
|
|
19
|
+
M1_locc = cp.Variable((size, size), hermitian=True)
|
|
20
|
+
e2_locc = cp.Variable(1, nonneg=True)
|
|
21
|
+
# construct MC, MU
|
|
22
|
+
Ns = __initialize_Ns__()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# reshape in cvxpy rearranges elements clolumn by clolumn, so transpose (.T) is needed
|
|
26
|
+
PU_locc = cp.reshape(P_locc[0], (1, size**2))
|
|
27
|
+
MU_locc = cp.reshape(PU_locc @ Ns, (size, size)).T
|
|
28
|
+
PC_locc = cp.reshape(P_locc[1], (1, size**2))
|
|
29
|
+
MC_locc = cp.reshape(PC_locc @ Ns, (size, size)).T
|
|
30
|
+
|
|
31
|
+
# constraints
|
|
32
|
+
constraints = [M0_locc >> 0, M1_locc >> 0]
|
|
33
|
+
constraints += [
|
|
34
|
+
e1 * np.eye(size, dtype=complex) - MC_locc == M0_locc + cp.partial_transpose(M1_locc, dims=(d, d), axis=1)
|
|
35
|
+
]
|
|
36
|
+
# constraints of P - locc
|
|
37
|
+
Pxya_b_locc = cp.reshape(cp.sum(P_locc, axis=0), (A, X**2 * A)).T
|
|
38
|
+
constraints += [
|
|
39
|
+
Pxya_b_locc[:, 0] - Pxya_b_locc[:, 1] == np.zeros(Pxya_b_locc.shape[0]),
|
|
40
|
+
Pxya_b_locc[:, 0] - Pxya_b_locc[:, 2] == np.zeros(Pxya_b_locc.shape[0])
|
|
41
|
+
]
|
|
42
|
+
P_xy_a_locc = cp.reshape(Pxya_b_locc[:, 0], (A, X**2)).T
|
|
43
|
+
sum_matrix = np.array([[1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1]])
|
|
44
|
+
P_x_a_locc = sum_matrix @ P_xy_a_locc
|
|
45
|
+
constraints += [
|
|
46
|
+
P_x_a_locc[:, 0] - P_x_a_locc[:, 1] == np.zeros(P_x_a_locc.shape[0]),
|
|
47
|
+
P_x_a_locc[:, 0] - P_x_a_locc[:, 2] == np.zeros(P_x_a_locc.shape[0])
|
|
48
|
+
]
|
|
49
|
+
constraints += [cp.sum(P_x_a_locc[:, 0]) == 1]
|
|
50
|
+
constraints += [e2_locc == cp.real(cp.trace(MU_locc @ rho))]
|
|
51
|
+
|
|
52
|
+
# problem
|
|
53
|
+
parameter = [rho, e1]
|
|
54
|
+
variable = [e2_locc, P_locc, M0_locc, M1_locc]
|
|
55
|
+
return cp.Problem(cp.Minimize(cp.real(cp.trace(MU_locc @ rho))), constraints), parameter, variable
|
|
56
|
+
|
|
57
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Ns = None # [xyab, N_xyab.reshape(-1)]
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def __initialize_Ns__():
|
|
8
|
+
global Ns
|
|
9
|
+
if Ns is None:
|
|
10
|
+
# parameters
|
|
11
|
+
X = A = d = 3
|
|
12
|
+
# define measurements
|
|
13
|
+
N_xa = [[] for _ in range(X)] # [x][a]
|
|
14
|
+
# N_xa[0]
|
|
15
|
+
vec = np.array([[1], [0], [0]], dtype=complex)
|
|
16
|
+
N_xa[0].append(vec @ vec.conj().T)
|
|
17
|
+
vec = np.array([[0], [1], [0]], dtype=complex)
|
|
18
|
+
N_xa[0].append(vec @ vec.conj().T)
|
|
19
|
+
vec = np.array([[0], [0], [1]], dtype=complex)
|
|
20
|
+
N_xa[0].append(vec @ vec.conj().T)
|
|
21
|
+
# N_xa[1]
|
|
22
|
+
vec = np.array([[np.exp(1j * 2 * np.pi / 3)], [np.exp(-1j * 2 * np.pi / 3)], [1]], dtype=complex) / np.sqrt(3)
|
|
23
|
+
N_xa[1].append(vec @ vec.conj().T)
|
|
24
|
+
vec = np.array([[np.exp(-1j * 2 * np.pi / 3)], [np.exp(1j * 2 * np.pi / 3)], [1]], dtype=complex) / np.sqrt(3)
|
|
25
|
+
N_xa[1].append(vec @ vec.conj().T)
|
|
26
|
+
vec = np.array([[1], [1], [1]], dtype=complex) / np.sqrt(3)
|
|
27
|
+
N_xa[1].append(vec @ vec.conj().T)
|
|
28
|
+
# N_xa[2]
|
|
29
|
+
vec = np.array([[1], [-1], [0]], dtype=complex) / (-np.sqrt(2))
|
|
30
|
+
N_xa[2].append(vec @ vec.conj().T)
|
|
31
|
+
vec = np.array([[0], [0], [1]], dtype=complex)
|
|
32
|
+
N_xa[2].append(vec @ vec.conj().T)
|
|
33
|
+
vec = np.array([[1], [1], [0]], dtype=complex) / (-np.sqrt(2))
|
|
34
|
+
N_xa[2].append(vec @ vec.conj().T)
|
|
35
|
+
|
|
36
|
+
# calculate final measurement matrix
|
|
37
|
+
Ns = np.zeros((X**2 * A**2, d**4), dtype=complex) # [xyab, N_xyab.reshape(-1)]
|
|
38
|
+
for x in range(X):
|
|
39
|
+
for y in range(X):
|
|
40
|
+
for a in range(A):
|
|
41
|
+
for b in range(A):
|
|
42
|
+
Ns[x * (X * A**2) + y * A**2 + a * A + b, :] = np.kron(N_xa[x][a], N_xa[y][b]).reshape(-1)
|
|
43
|
+
|
|
44
|
+
return Ns
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vgon
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Variational Generative Optimization Network (VGON).
|
|
5
|
+
Author: Lingxia Zhang, Xiaodie Lin
|
|
6
|
+
Project-URL: Homepage, https://vgon.funqitang.cn
|
|
7
|
+
Project-URL: Repository, https://github.com/zhangjianjianzz/VGON.git
|
|
8
|
+
Project-URL: Documentation, https://vgon.funqitang.cn
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Provides-Extra: core
|
|
11
|
+
Requires-Dist: torch; extra == "core"
|
|
12
|
+
Requires-Dist: toqito>=1.1.2; extra == "core"
|
|
13
|
+
Requires-Dist: cvxpy>=1.7.2; extra == "core"
|
|
14
|
+
Requires-Dist: cvxpylayers>=0.1.9; extra == "core"
|
|
15
|
+
Requires-Dist: pennylane>=0.42.3; extra == "core"
|
|
16
|
+
Requires-Dist: pennylane-lightning>=0.42.0; extra == "core"
|
|
17
|
+
Provides-Extra: plot
|
|
18
|
+
Requires-Dist: pandas>=2.3.2; extra == "plot"
|
|
19
|
+
Requires-Dist: ptiprince>=0.2.7; extra == "plot"
|
|
20
|
+
Requires-Dist: scipy>=1.16.2; extra == "plot"
|
|
21
|
+
Requires-Dist: seaborn>=0.13.2; extra == "plot"
|
|
22
|
+
Provides-Extra: notebook
|
|
23
|
+
Requires-Dist: ipykernel>=6.30.1; extra == "notebook"
|
|
24
|
+
Provides-Extra: doc
|
|
25
|
+
Requires-Dist: mkdocs-material; extra == "doc"
|
|
26
|
+
Requires-Dist: mkdocs-literate-nav>=0.6.2; extra == "doc"
|
|
27
|
+
Requires-Dist: mdx-truly-sane-lists>=1.3; extra == "doc"
|
|
28
|
+
Provides-Extra: full
|
|
29
|
+
Requires-Dist: vgon[core,doc,notebook,plot]; extra == "full"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/vgon/__init__.py
|
|
4
|
+
src/vgon.egg-info/PKG-INFO
|
|
5
|
+
src/vgon.egg-info/SOURCES.txt
|
|
6
|
+
src/vgon.egg-info/dependency_links.txt
|
|
7
|
+
src/vgon.egg-info/requires.txt
|
|
8
|
+
src/vgon.egg-info/top_level.txt
|
|
9
|
+
src/vgon/examples/__init__.py
|
|
10
|
+
src/vgon/examples/gap/__init__.py
|
|
11
|
+
src/vgon/examples/gap/lo.py
|
|
12
|
+
src/vgon/examples/gap/locc.py
|
|
13
|
+
src/vgon/examples/gap/ns.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
[core]
|
|
3
|
+
torch
|
|
4
|
+
toqito>=1.1.2
|
|
5
|
+
cvxpy>=1.7.2
|
|
6
|
+
cvxpylayers>=0.1.9
|
|
7
|
+
pennylane>=0.42.3
|
|
8
|
+
pennylane-lightning>=0.42.0
|
|
9
|
+
|
|
10
|
+
[doc]
|
|
11
|
+
mkdocs-material
|
|
12
|
+
mkdocs-literate-nav>=0.6.2
|
|
13
|
+
mdx-truly-sane-lists>=1.3
|
|
14
|
+
|
|
15
|
+
[full]
|
|
16
|
+
vgon[core,doc,notebook,plot]
|
|
17
|
+
|
|
18
|
+
[notebook]
|
|
19
|
+
ipykernel>=6.30.1
|
|
20
|
+
|
|
21
|
+
[plot]
|
|
22
|
+
pandas>=2.3.2
|
|
23
|
+
ptiprince>=0.2.7
|
|
24
|
+
scipy>=1.16.2
|
|
25
|
+
seaborn>=0.13.2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
vgon
|