Skip to content

Commit 39806da

Browse files
Merge genQC v0.2.4 (#9)
* update to new model version cirdit_multimodal_compile_3to5qubit_v1.1 * fix huggingface_hub download
1 parent 498a964 commit 39806da

21 files changed

Lines changed: 274 additions & 206 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include settings.ini
2-
include LICENSE
2+
include LICENSE.txt
33
include CONTRIBUTING.md
44
include README.md
55
recursive-exclude * __pycache__

README.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ QFT.](https://github.com/FlorianFuerrutter/genQC/blob/main/src/webpage/assets/qf
2323

2424
## 📰 News
2525

26-
- 🔥 \[2025-06-02\] Paper release: [Synthesis of discrete-continuous quantum circuits with multimodal diffusion models](https://www.arxiv.org/abs/2506.01666).
26+
- 🔥 \[2025-06-02\] Paper release: [Synthesis of discrete-continuous
27+
quantum circuits with multimodal diffusion
28+
models](https://www.arxiv.org/abs/2506.01666).
2729
- 🔥 \[2025-06-01\] *Discrete-continuous circuits with multimodal
2830
diffusion* - model released on [Hugging Face:
2931
huggingface.co/collections/Floki00](https://huggingface.co/collections/Floki00/discrete-continuous-circuits-with-multimodal-diffusion-6839c4e4553e56b957bbd5bf).
@@ -67,10 +69,9 @@ from genQC.benchmark.bench_compilation import SpecialUnitaries
6769
from genQC.platform.simulation import Simulator, CircuitBackendType
6870

6971
device = infer_torch_device()
70-
set_seed(0)
7172

7273
pipeline = MultimodalDiffusionPipeline_ParametrizedCompilation.from_pretrained(
73-
repo_id="Floki00/cirdit_multimodal_compile_3to5qubit",
74+
repo_id="Floki00/cirdit_multimodal_compile_3to5qubit_v1.1",
7475
device=device)
7576

7677
pipeline.scheduler.set_timesteps(40)
@@ -91,20 +92,44 @@ out_tensor, params = generate_compilation_tensors(pipeline,
9192
```
9293

9394
``` python
94-
vocabulary = {g:i+1 for i, g in enumerate(pipeline.gate_pool)}
95+
vocabulary = {g:i+1 for i, g in enumerate(pipeline.gate_pool)}
9596
tokenizer = CircuitTokenizer(vocabulary)
96-
simulator = Simulator(CircuitBackendType.QISKIT)
97+
simulator = Simulator(CircuitBackendType.CUDAQ)
9798

9899
qc_list, _ = decode_tensors_to_backend(simulator, tokenizer, out_tensor, params)
99-
qc_list[0].draw("mpl")
100+
101+
simulator.backend.draw(qc_list[0], num_qubits=4)
100102
```
101103

102-
![](https://github.com/FlorianFuerrutter/genQC/blob/main/get_started_files/figure-commonmark/cell-3-output-1.png?raw=true)
104+
»
105+
q0 : ────────────────────────●────────────────────●───────────●───────╳─»
106+
│ ╭───╮ │ ╭────┴─────╮ │ »
107+
q1 : ────────────────────────┼───────╳─┤ h ├──────┼──────┤ r1(1.25) ├─┼─»
108+
│ │ ╰───╯╭─────┴─────╮╰──────────╯ │ »
109+
q2 : ───────────●────────────┼───────╳──────┤ r1(6.253) ├─────────────┼─»
110+
╭───╮╭─────┴─────╮╭─────┴─────╮ ╰───────────╯ │ »
111+
q3 : ┤ h ├┤ r1(1.571) ├┤ r1(7.191) ├──────────────────────────────────╳─»
112+
╰───╯╰───────────╯╰───────────╯ »
113+
114+
################################################################################
115+
116+
117+
─────────────────
118+
119+
─────●───────────
120+
╭────┴─────╮╭───╮
121+
┤ r1(1.59) ├┤ h ├
122+
╰──┬───┬───╯╰───╯
123+
───┤ h ├─────────
124+
╰───╯
103125

104126
#### Further examples
105127

106-
More detailed examples and tutorial notebooks are provided on the
107-
project page
128+
A detailed tutorial on the application with `CUDA-Q` is available on the
129+
[CUDA-Q
130+
documentation](https://nvidia.github.io/cuda-quantum/latest/applications/python/unitary_compilation_diffusion_models.html).
131+
132+
More examples and tutorial notebooks are provided on the project page
108133
[\[tutorials\]](https://florianfuerrutter.github.io/genQC/examples/tutorials.html)
109134
or in the directory `src/examples/`.
110135

genQC/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.2"
1+
__version__ = "0.2.4"

genQC/pipeline/multimodal_diffusion_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ def train_step(self, data, train, **kwargs):
400400
mse_loss_weight_h = (1.0 - alphas_cumprod_h) * F.sigmoid(SNR_h.log())
401401

402402
SNR_w = alphas_cumprod_w / (1.0-alphas_cumprod_w+1e-8) + 1e-8
403-
403+
mse_loss_weight_w = (1.0 - alphas_cumprod_w) * F.sigmoid(SNR_w.log() + np.log(3.0 * np.pi**2))
404+
404405
#comp mse
405406
mse_flat = lambda out, target: (out-target).square().mean(dim=list(range(1, len(out.shape))))
406407
loss_h = mse_flat(model_output[..., :self.embedder.clr_dim], pred_target_h.detach()) * mse_loss_weight_h.squeeze().detach()

genQC/pipeline/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def store_pipeline(self, config_path: str, save_path: str):
7575
def from_config_file(config_path, device: torch.device, save_path: str=None): return None
7676

7777
@classmethod
78-
def from_pretrained(cls, repo_id: str, device: torch.device, use_auth_token: bool = False, **kwargs):
78+
def from_pretrained(cls, repo_id: str, device: torch.device, **kwargs):
7979
"""Load a model pipeline directly from Huggingface."""
80-
model_path = snapshot_download(repo_id=repo_id, repo_type="model", allow_patterns=["*.pt", "*.yaml", "*.safetensors"], use_auth_token=use_auth_token, **kwargs)
80+
model_path = snapshot_download(repo_id=repo_id, repo_type="model", allow_patterns=["*.pt", "*.yaml", "*.safetensors"], **kwargs)
8181
pipeline = cls.from_config_file(model_path+"/", device)
8282
return pipeline
8383

genQC/platform/backends/circuits_cudaq.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,15 @@ def get_unitary(self, parametrizedCudaqKernel: ParametrizedCudaqKernel, num_qubi
193193

194194
return U
195195

196-
def draw(self, kernel: cudaq.kernel, num_qubits: int, **kwargs) -> None:
196+
def draw(self, parametrizedCudaqKernel: ParametrizedCudaqKernel, num_qubits: int, return_str: bool = False, **kwargs) -> None:
197197
"""Draw the given `cudaq.kernel` using cudaq."""
198+
199+
kernel, thetas = parametrizedCudaqKernel.kernel, parametrizedCudaqKernel.params
200+
198201
c = [0] * (2**num_qubits)
199202
c[0] = 1
200-
print(cudaq.draw(kernel, c))
203+
204+
s = cudaq.draw(kernel, c, thetas)
205+
if return_str:
206+
return s
207+
print(s)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name="genQC"
7-
requires-python=">=3.12"
7+
requires-python=">=3.10"
88
dynamic = [ "keywords", "description", "version", "dependencies", "optional-dependencies", "readme", "license", "authors", "classifiers", "entry-points", "scripts", "urls"]
99

1010
[tool.uv]

settings.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
### Python library ###
44
repo = genQC
55
lib_name = %(repo)s
6-
version = 0.2.2
7-
min_python = 3.12
6+
version = 0.2.4
7+
min_python = 3.10
88
license = apache2
99
black_formatting = False
1010

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from configparser import ConfigParser
33

44
import setuptools
5-
from pkg_resources import parse_version
65

7-
assert parse_version(setuptools.__version__)>=parse_version('36.2')
6+
#from pkg_resources import parse_version
7+
#assert parse_version(setuptools.__version__)>=parse_version('36.2')
88

99
# note: all settings are in settings.ini; edit there, not here
1010
config = ConfigParser(delimiters=['='])
@@ -26,7 +26,7 @@
2626
}
2727
statuses = [ '0 - Pre-Planning', '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
2828
'4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ]
29-
py_versions = '3.7 3.8 3.9 3.10 3.12 3.13'.split()
29+
py_versions = '3.10 3.11 3.12 3.13'.split()
3030

3131
requirements = ['packaging']
3232
requirements += shlex.split(cfg.get('requirements', ''))

src/_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ website:
2525
favicon: "webpage/assets/logo.png"
2626
open-graph: true
2727
repo-actions: [issue, source]
28+
repo-subdir: "src"
2829
back-to-top-navigation: true
2930
page-navigation: true
3031

0 commit comments

Comments
 (0)