Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0ff0caf
changed LICENSE
FlorianFuerrutter Aug 26, 2024
11c9fe3
add cudaq_export
FlorianFuerrutter Aug 26, 2024
5753262
added pre-trained load from huggingface_hub, fixed torch wanring, upd…
FlorianFuerrutter Aug 26, 2024
b647557
updated index.ipynb and README.md
FlorianFuerrutter Aug 26, 2024
11359f9
rm metadata
FlorianFuerrutter Aug 26, 2024
bb3a683
update RELEASES.md
FlorianFuerrutter Aug 26, 2024
ed12199
Merge remote-tracking branch 'remotes/origin/main' into dev
FlorianFuerrutter May 29, 2025
9458fd9
update nbdev setup
FlorianFuerrutter May 30, 2025
f3c8428
update imports.py
FlorianFuerrutter May 30, 2025
f78cca3
clean binary
FlorianFuerrutter May 30, 2025
b6ddb2b
update webpage
FlorianFuerrutter May 30, 2025
3f0b034
update src/dataset/
FlorianFuerrutter Jun 1, 2025
181ac8e
add src/benchmark/
FlorianFuerrutter Jun 1, 2025
0b1182c
add+up src/inference/
FlorianFuerrutter Jun 1, 2025
ebdb123
add src/models/embedding/
FlorianFuerrutter Jun 1, 2025
8a65342
add src/models/clip/
FlorianFuerrutter Jun 1, 2025
4ee8b74
add src/models/transformers/
FlorianFuerrutter Jun 1, 2025
d9ee02c
update src/models/
FlorianFuerrutter Jun 1, 2025
0f899aa
add+up src/pipeline
FlorianFuerrutter Jun 1, 2025
68fc196
add+update src/platform/
FlorianFuerrutter Jun 1, 2025
3113c60
update src/schedule/
FlorianFuerrutter Jun 1, 2025
5f4d694
add src/utils
FlorianFuerrutter Jun 1, 2025
78e4f5a
add+update src/examples
FlorianFuerrutter Jun 1, 2025
7c5eca2
up index.qmd;
FlorianFuerrutter Jun 1, 2025
42e5757
update genQC/
FlorianFuerrutter Jun 1, 2025
2b32506
update README.md
FlorianFuerrutter Jun 1, 2025
fe98492
up index.qmd
FlorianFuerrutter Jun 1, 2025
06ab381
up version
FlorianFuerrutter Jun 30, 2025
7f56e3e
update to new model version cirdit_multimodal_compile_3to5qubit_v1.1
FlorianFuerrutter Nov 20, 2025
c161915
fix huggingface_hub download
FlorianFuerrutter Nov 20, 2025
6a300aa
Merge branch 'main' into dev
FlorianFuerrutter Nov 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include settings.ini
include LICENSE
include LICENSE.txt
include CONTRIBUTING.md
include README.md
recursive-exclude * __pycache__
43 changes: 34 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ QFT.](https://github.com/FlorianFuerrutter/genQC/blob/main/src/webpage/assets/qf

## 📰 News

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

device = infer_torch_device()
set_seed(0)

pipeline = MultimodalDiffusionPipeline_ParametrizedCompilation.from_pretrained(
repo_id="Floki00/cirdit_multimodal_compile_3to5qubit",
repo_id="Floki00/cirdit_multimodal_compile_3to5qubit_v1.1",
device=device)

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

``` python
vocabulary = {g:i+1 for i, g in enumerate(pipeline.gate_pool)}
vocabulary = {g:i+1 for i, g in enumerate(pipeline.gate_pool)}
tokenizer = CircuitTokenizer(vocabulary)
simulator = Simulator(CircuitBackendType.QISKIT)
simulator = Simulator(CircuitBackendType.CUDAQ)

qc_list, _ = decode_tensors_to_backend(simulator, tokenizer, out_tensor, params)
qc_list[0].draw("mpl")

simulator.backend.draw(qc_list[0], num_qubits=4)
```

![](https://github.com/FlorianFuerrutter/genQC/blob/main/get_started_files/figure-commonmark/cell-3-output-1.png?raw=true)
»
q0 : ────────────────────────●────────────────────●───────────●───────╳─»
│ ╭───╮ │ ╭────┴─────╮ │ »
q1 : ────────────────────────┼───────╳─┤ h ├──────┼──────┤ r1(1.25) ├─┼─»
│ │ ╰───╯╭─────┴─────╮╰──────────╯ │ »
q2 : ───────────●────────────┼───────╳──────┤ r1(6.253) ├─────────────┼─»
╭───╮╭─────┴─────╮╭─────┴─────╮ ╰───────────╯ │ »
q3 : ┤ h ├┤ r1(1.571) ├┤ r1(7.191) ├──────────────────────────────────╳─»
╰───╯╰───────────╯╰───────────╯ »

################################################################################


─────────────────

─────●───────────
╭────┴─────╮╭───╮
┤ r1(1.59) ├┤ h ├
╰──┬───┬───╯╰───╯
───┤ h ├─────────
╰───╯

#### Further examples

More detailed examples and tutorial notebooks are provided on the
project page
A detailed tutorial on the application with `CUDA-Q` is available on the
[CUDA-Q
documentation](https://nvidia.github.io/cuda-quantum/latest/applications/python/unitary_compilation_diffusion_models.html).

More examples and tutorial notebooks are provided on the project page
[\[tutorials\]](https://florianfuerrutter.github.io/genQC/examples/tutorials.html)
or in the directory `src/examples/`.

Expand Down
2 changes: 1 addition & 1 deletion genQC/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.2"
__version__ = "0.2.4"
3 changes: 2 additions & 1 deletion genQC/pipeline/multimodal_diffusion_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ def train_step(self, data, train, **kwargs):
mse_loss_weight_h = (1.0 - alphas_cumprod_h) * F.sigmoid(SNR_h.log())

SNR_w = alphas_cumprod_w / (1.0-alphas_cumprod_w+1e-8) + 1e-8

mse_loss_weight_w = (1.0 - alphas_cumprod_w) * F.sigmoid(SNR_w.log() + np.log(3.0 * np.pi**2))

#comp mse
mse_flat = lambda out, target: (out-target).square().mean(dim=list(range(1, len(out.shape))))
loss_h = mse_flat(model_output[..., :self.embedder.clr_dim], pred_target_h.detach()) * mse_loss_weight_h.squeeze().detach()
Expand Down
4 changes: 2 additions & 2 deletions genQC/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def store_pipeline(self, config_path: str, save_path: str):
def from_config_file(config_path, device: torch.device, save_path: str=None): return None

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

Expand Down
11 changes: 9 additions & 2 deletions genQC/platform/backends/circuits_cudaq.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,15 @@ def get_unitary(self, parametrizedCudaqKernel: ParametrizedCudaqKernel, num_qubi

return U

def draw(self, kernel: cudaq.kernel, num_qubits: int, **kwargs) -> None:
def draw(self, parametrizedCudaqKernel: ParametrizedCudaqKernel, num_qubits: int, return_str: bool = False, **kwargs) -> None:
"""Draw the given `cudaq.kernel` using cudaq."""

kernel, thetas = parametrizedCudaqKernel.kernel, parametrizedCudaqKernel.params

c = [0] * (2**num_qubits)
c[0] = 1
print(cudaq.draw(kernel, c))

s = cudaq.draw(kernel, c, thetas)
if return_str:
return s
print(s)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

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

[tool.uv]
Expand Down
4 changes: 2 additions & 2 deletions settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
### Python library ###
repo = genQC
lib_name = %(repo)s
version = 0.2.2
min_python = 3.12
version = 0.2.4
min_python = 3.10
license = apache2
black_formatting = False

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from configparser import ConfigParser

import setuptools
from pkg_resources import parse_version

assert parse_version(setuptools.__version__)>=parse_version('36.2')
#from pkg_resources import parse_version
#assert parse_version(setuptools.__version__)>=parse_version('36.2')

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

requirements = ['packaging']
requirements += shlex.split(cfg.get('requirements', ''))
Expand Down
1 change: 1 addition & 0 deletions src/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ website:
favicon: "webpage/assets/logo.png"
open-graph: true
repo-actions: [issue, source]
repo-subdir: "src"
back-to-top-navigation: true
page-navigation: true

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
"from genQC.pipeline.diffusion_pipeline import DiffusionPipeline\n",
"from genQC.inference.infer_srv import convert_tensors_to_srvs, schmidt_rank_vector\n",
"import genQC.platform.qcircuit_dataset_construction as data_const\n",
"from genQC.platform.simulation.qcircuit_sim import instruction_name_to_qiskit_gate\n",
"# import genQC.util as util\n",
"# from qiskit.quantum_info import DensityMatrix"
"from genQC.platform.simulation.qcircuit_sim import instruction_name_to_qiskit_gate"
]
},
{
Expand Down Expand Up @@ -97,31 +95,7 @@
"execution_count": null,
"id": "e5d60c23-9514-4432-bc82-622c088fced6",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a1c55308f7c94327b24b9df417f05117",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Fetching 2 files: 0%| | 0/2 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO]: `genQC.models.unet_qc.QC_Cond_UNet` instantiated from given config on cuda.\n",
"[INFO]: `genQC.models.frozen_open_clip.CachedFrozenOpenCLIPEmbedder` instantiated from given config on cuda.\n",
"[INFO]: `genQC.models.frozen_open_clip.CachedFrozenOpenCLIPEmbedder`. No save_path` provided. No state dict loaded.\n"
]
}
],
"outputs": [],
"source": [
"pipeline = DiffusionPipeline.from_pretrained(\"Floki00/qc_srv_3to8qubit\", device)"
]
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/examples/tutorials.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ listing:

#### Welcome to the `genQC` Tutorials.

Here you can familiarize yourself with basics concepts and modules. Tutorials show how to reproduce some figures and results of the corresponding [research papers](../webpage/research.qmd).
Here you can familiarize yourself with basics concepts and modules. The tutorials show how to reproduce some figures and results of the corresponding [research papers](../webpage/research.qmd).

<br>

Expand Down
49 changes: 34 additions & 15 deletions src/get_started.ipynb

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ from genQC.platform.simulation import Simulator, CircuitBackendType
device = infer_torch_device()

pipeline = MultimodalDiffusionPipeline_ParametrizedCompilation.from_pretrained( # <1>
repo_id="Floki00/cirdit_multimodal_compile_3to5qubit", # <1>
repo_id="Floki00/cirdit_multimodal_compile_3to5qubit_v1.1", # <1>
device=device) # <1>

pipeline.scheduler.set_timesteps(40) # <2>
Expand All @@ -112,17 +112,18 @@ out_tensor, params = generate_compilation_tensors(pipeline, # <4>

vocabulary = {g:i+1 for i, g in enumerate(pipeline.gate_pool)} # <5>
tokenizer = CircuitTokenizer(vocabulary) # <5>
simulator = Simulator(CircuitBackendType.QISKIT) # <5>
simulator = Simulator(CircuitBackendType.CUDAQ) # <5>

qc_list, _ = decode_tensors_to_backend(simulator, tokenizer, out_tensor, params) # <5>

qc_list[0].draw("mpl")
simulator.backend.draw(qc_list[0], num_qubits=4) # <6>
```
1. Load a pre-trained Diffusion model.
2. Set inference parameters.
3. Specify QFT unitary.
4. Generate tokenized circuits.
5. Decode tensors to circuits.
6. Plot a generated circuit.
:::

:::
Expand Down
3 changes: 2 additions & 1 deletion src/pipeline/multimodal_diffusion_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@
" mse_loss_weight_h = (1.0 - alphas_cumprod_h) * F.sigmoid(SNR_h.log())\n",
"\n",
" SNR_w = alphas_cumprod_w / (1.0-alphas_cumprod_w+1e-8) + 1e-8\n",
"\n",
" mse_loss_weight_w = (1.0 - alphas_cumprod_w) * F.sigmoid(SNR_w.log() + np.log(3.0 * np.pi**2))\n",
" \n",
" #comp mse\n",
" mse_flat = lambda out, target: (out-target).square().mean(dim=list(range(1, len(out.shape))))\n",
" loss_h = mse_flat(model_output[..., :self.embedder.clr_dim], pred_target_h.detach()) * mse_loss_weight_h.squeeze().detach()\n",
Expand Down
4 changes: 2 additions & 2 deletions src/pipeline/pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@
" def from_config_file(config_path, device: torch.device, save_path: str=None): return None \n",
"\n",
" @classmethod\n",
" def from_pretrained(cls, repo_id: str, device: torch.device, use_auth_token: bool = False, **kwargs): \n",
" def from_pretrained(cls, repo_id: str, device: torch.device, **kwargs): \n",
" \"\"\"Load a model pipeline directly from Huggingface.\"\"\"\n",
" model_path = snapshot_download(repo_id=repo_id, repo_type=\"model\", allow_patterns=[\"*.pt\", \"*.yaml\", \"*.safetensors\"], use_auth_token=use_auth_token, **kwargs) \n",
" model_path = snapshot_download(repo_id=repo_id, repo_type=\"model\", allow_patterns=[\"*.pt\", \"*.yaml\", \"*.safetensors\"], **kwargs) \n",
" pipeline = cls.from_config_file(model_path+\"/\", device) \n",
" return pipeline"
]
Expand Down
17 changes: 12 additions & 5 deletions src/platform/backends/circuits_cudaq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,18 @@
" \n",
" return U\n",
"\n",
" def draw(self, kernel: cudaq.kernel, num_qubits: int, **kwargs) -> None:\n",
" def draw(self, parametrizedCudaqKernel: ParametrizedCudaqKernel, num_qubits: int, return_str: bool = False, **kwargs) -> None:\n",
" \"\"\"Draw the given `cudaq.kernel` using cudaq.\"\"\" \n",
"\n",
" kernel, thetas = parametrizedCudaqKernel.kernel, parametrizedCudaqKernel.params\n",
" \n",
" c = [0] * (2**num_qubits)\n",
" c[0] = 1\n",
" print(cudaq.draw(kernel, c))"
"\n",
" s = cudaq.draw(kernel, c, thetas)\n",
" if return_str:\n",
" return s\n",
" print(s)"
]
},
{
Expand Down Expand Up @@ -333,7 +340,7 @@
"q2 : ┤ ry(0.1) ├──●───╳───────────────────────\n",
" ╰─────────╯ \n",
"\n",
"Measurement distribution:{ 000:85 010:401 100:85 110:429 }\n",
"Measurement distribution:{ 000:76 010:419 100:89 101:1 110:415 }\n",
"\n"
]
}
Expand Down Expand Up @@ -425,8 +432,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Timeit target='qpp-cpu': 1.08 ms ± 58.9 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n",
"Timeit target='nvidia': 13.5 ms ± 3.14 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
"Timeit target='qpp-cpu': 1.04 ms ± 102 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n",
"Timeit target='nvidia': 13.6 ms ± 1.02 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
]
}
],
Expand Down
Loading