Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish qemcmc to PyPI

on:
push:
tags:
- "v*"

jobs:
publish:
runs-on: ubuntu-latest

environment:
name: pypi

permissions:
id-token: write # for trusted publishing

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install build tool
run: pip install build

- name: Build
run: python -m build

- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 3 additions & 0 deletions docs/source/github.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Github

The source code for QeMCMC can be found at [https://github.com/Stuartferguson00/QeMCMC](https://github.com/Stuartferguson00/QeMCMC). Contributions are welcome, and you can submit issues or pull requests to help improve the project. Please refer to the repository's README and contribution guidelines for more information on how to get involved.
1 change: 1 addition & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ api/index
:maxdepth: 2
:caption: Development

github
license
authors
```
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[project]
name = "qemcmc"
version = "0.0.0"
# version = "0.0.0"
dynamic = ["version"]
description = "Quantum enhanced Markov Chain Monte Carlo sampler simulated using PennyLane"
readme = "README.md"
authors = [{ name = "Stuart Ferguson" }, { name = "Feroz Hassan" }]
license = { text = "MIT" }
requires-python = ">=3.13"
dependencies = [
"joblib>=1.5.0",
Expand All @@ -26,5 +28,10 @@ dependencies = [
qemcmc = "qemcmc:main"

[build-system]
requires = ["setuptools>=61.0", "wheel"]
requires = ["setuptools>=61.0", "wheel", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[tool.setuptools.packages.find]
where = ["src"]
8 changes: 6 additions & 2 deletions src/qemcmc/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_problem_hamiltonian(self, couplings, sign=-1):
if order == 0:
continue
spin_sign = (-1) ** order

non_zero_indices = np.transpose(np.nonzero(coupling_tensor))
for index_tuple in non_zero_indices:
index_tuple = tuple(int(i) for i in index_tuple)
Expand Down Expand Up @@ -102,14 +103,17 @@ def get_mixer_hamiltonian(self, num_wires: int = None):

def get_state_vector(self, s: str) -> str:
"""Return the state vector."""
num_wires = len(s)
dev = self._get_device(num_wires)

# Coefficients
alpha = self.model.calculate_alpha(couplings=self.local_couplings)
coeff_mixer = self.gamma
coeff_problem = -(1 - self.gamma) * alpha

H_total = qml.Hamiltonian([coeff_mixer] + [1.0], [self.get_mixer_hamiltonian(), self.get_problem_hamiltonian(couplings=self.local_couplings, sign=coeff_problem)])
H_total = qml.Hamiltonian([coeff_mixer] + [1.0], [self.get_mixer_hamiltonian(num_wires), self.get_problem_hamiltonian(couplings=self.local_couplings, sign=coeff_problem)])

@qml.qnode(self.dev)
@qml.qnode(dev)
def quantum_evolution(input_string):
for i, bit in enumerate(input_string):
if bit == "1":
Expand Down
Loading