Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
98edf5f
Add QRE code owners for PR review assignment. (#2853)
msoeken Jan 15, 2026
24f5344
Merge branch 'main' into feature/qre
msoeken Jan 27, 2026
413cba3
Types to define ISAs and ISA requirements (#2856)
msoeken Jan 27, 2026
dcc53ed
Enumerate ISAs with transforms and queries (#2894)
msoeken Jan 30, 2026
0fae825
Initial commit; hypergraph module added (#2909)
brad-lackey Feb 2, 2026
c0308e9
Data types for traces, transforms, Pareto frontiers (#2907)
msoeken Feb 3, 2026
4c706d4
Magnets: added greedy edge coloring method, and two simple 1d lattice…
brad-lackey Feb 3, 2026
50d9bbc
Magnets: Base classes for Trotter-Suzuki expansions (#2913)
brad-lackey Feb 3, 2026
c8b973a
Base class for magnet models (#2914)
brad-lackey Feb 3, 2026
29c03ba
Magnets: more basic geometries (#2919)
brad-lackey Feb 6, 2026
ecd7e23
ISA queries, trace queries, and enumeration. (#2916)
msoeken Feb 7, 2026
aee65fa
Magnets: changed implementation of edge coloring (#2925)
brad-lackey Feb 9, 2026
b3f5198
Magnets: refactored Trotter step classes and added Suzuki and Yoshida…
brad-lackey Feb 9, 2026
b026182
New ISA and ISARequirements function (#2923)
msoeken Feb 10, 2026
289a181
Track instruction origin (#2933)
msoeken Feb 13, 2026
80ec786
Refactor trace and result properties (#2952)
msoeken Feb 17, 2026
bcc31d0
Brlackey/magnets ising model (#2955)
brad-lackey Feb 18, 2026
e19e6a1
Magnets: added utilities (#2965)
brad-lackey Feb 20, 2026
511c953
Various RE models and some API enhancements (#2963)
msoeken Feb 25, 2026
696f0dc
Merge branch 'main' into feature/qre
msoeken Feb 26, 2026
41bf7b5
Magnets: revisions to (hypergraph) coloring (#2972)
brad-lackey Feb 26, 2026
674124f
Minor changes to colorings and term representation; added Heisenberg …
brad-lackey Feb 27, 2026
1040016
More edits to functionality
brad-lackey Mar 5, 2026
739d087
Merge branch 'feature/qre' of github.com:microsoft/qdk into feature/qre
brad-lackey Mar 5, 2026
df1f2c2
Fix magnet tests (#3006)
msoeken Mar 10, 2026
bdddb70
Resource estimation results table (#2973)
msoeken Mar 11, 2026
a7d15c9
Refactor property keys from string to integer and add estimation impr…
msoeken Mar 16, 2026
8b1b520
QIR interop in QRE (#3018)
msoeken Mar 16, 2026
5ce010a
Split Yoked SC model into two codes (#3019)
msoeken Mar 17, 2026
0c86dbb
Use Rust parallelism for estimation with post processing (#3025)
msoeken Mar 17, 2026
dcadb5c
Fixes bucketing logic to distribute rotations to match the right dept…
msoeken Mar 23, 2026
317ff6a
Graph-based ISA pruning for resource estimation (#3031)
msoeken Mar 23, 2026
5de8ec1
Magnets: modified Trotter expansion classes and added Cirq output. (#…
brad-lackey Mar 23, 2026
1d5b568
Two small fixes to QRE 3 (#3041)
msoeken Mar 23, 2026
cd308a9
Return ISA as a pandas data frame (#3042)
msoeken Mar 23, 2026
8597d0a
Temporary plotting for estimation results (#3043)
msoeken Mar 23, 2026
232df87
Get the name of a known property ID as a string (#3044)
msoeken Mar 23, 2026
f1ceab8
Trace properties for logical qubits (#3045)
msoeken Mar 23, 2026
9d87a9c
Expose ISA requirements of a trace (#3046)
msoeken Mar 23, 2026
dabfa32
Trace ISA requirements (#3050)
msoeken Mar 25, 2026
c22cf5c
Plot multiple estimation tables in single plot (#3054)
msoeken Mar 25, 2026
0b92123
Create QRE traces from cirq circuits (#3060)
msoeken Mar 27, 2026
bc9a3c7
Merge branch 'main' into feature/qre
msoeken Mar 27, 2026
358171d
File missing from previous merge.
msoeken Mar 27, 2026
8f08a2b
Reorganize files and spit up large files in QRE (#3069)
msoeken Mar 30, 2026
c1bc4fc
Complete and consistent docs for QRE (#3077)
msoeken Apr 2, 2026
556e8a4
Remove matplotlib from tests (#3078)
msoeken Apr 2, 2026
cf70736
Adjust pruning logic for graph based search (#3089)
msoeken Apr 2, 2026
04f1e46
Merge branch 'main' into feature/qre
msoeken Apr 2, 2026
e5708d1
Fix CODEOWNERS file.
msoeken Apr 2, 2026
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
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/source/compiler/qsc_partial_eval @idavis @swernli
/source/compiler/qsc_rca @idavis @swernli
/source/compiler/qsc_rir @idavis @swernli
/source/fuzz @billti @idavis @swernli
/source/fuzz @billti @idavis @swernli
/katas @billti @swernli
/source/jupyterlab @billti @idavis @minestarks
/source/language_service @billti @idavis @minestarks @ScottCarda-MS
Expand All @@ -19,7 +19,9 @@
/library @swernli @orpuente-MS
/source/npm @billti @minestarks @ScottCarda-MS
/source/pip @billti @idavis @minestarks
/source/pip/qsharp/qre @msoeken @brad-lackey @jwhogabo
/source/playground @billti @minestarks
/source/qre @msoeken @brad-lackey @jwhogabo
/source/resource_estimator @billti @swernli
/samples @minestarks @swernli
/source/vscode @billti @idavis @minestarks
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"source/language_service",
"source/simulators",
"source/pip",
"source/qre",
"source/resource_estimator",
"source/samples_test",
"source/wasm",
Expand Down
1 change: 1 addition & 0 deletions source/pip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ num-traits = { workspace = true }
qsc = { path = "../compiler/qsc" }
qdk_simulators = { path = "../simulators" }
resource_estimator = { path = "../resource_estimator" }
qre = { path = "../qre" }
miette = { workspace = true, features = ["fancy"] }
rustc-hash = { workspace = true }
serde = { workspace = true, features = ["derive"] }
Expand Down
106 changes: 106 additions & 0 deletions source/pip/benchmarks/bench_qre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import timeit
from dataclasses import dataclass, KW_ONLY, field
from qsharp.qre import linear_function, generic_function
from qsharp.qre._architecture import _make_instruction
from qsharp.qre.models import GateBased, SurfaceCode
from qsharp.qre._enumeration import _enumerate_instances


def bench_enumerate_instances():
# Measure performance of enumerating instances with a large domain
@dataclass
class LargeDomain:
_: KW_ONLY
param1: int = field(default=0, metadata={"domain": range(1000)})
param2: bool

number = 100

duration = timeit.timeit(
"list(_enumerate_instances(LargeDomain))",
globals={
"_enumerate_instances": _enumerate_instances,
"LargeDomain": LargeDomain,
},
number=number,
)

print(f"Enumerating instances took {duration / number:.6f} seconds on average.")


def bench_enumerate_isas():
import os
import sys

# Add the tests directory to sys.path to import test_qre
# TODO: Remove this once the models in test_qre are moved to a proper module
sys.path.append(os.path.join(os.path.dirname(__file__), "../tests/qre/"))
from conftest import ExampleLogicalFactory, ExampleFactory # type: ignore

ctx = GateBased(gate_time=50, measurement_time=100).context()

# Hierarchical factory using from_components
query = SurfaceCode.q() * ExampleLogicalFactory.q(
source=SurfaceCode.q() * ExampleFactory.q()
)

number = 100
duration = timeit.timeit(
"list(query.enumerate(ctx))",
globals={
"query": query,
"ctx": ctx,
},
number=number,
)

print(f"Enumerating ISAs took {duration / number:.6f} seconds on average.")


def bench_function_evaluation_linear():
fl = linear_function(12)

inst = _make_instruction(42, 0, None, 1, fl, None, 1.0, {})
number = 1000
duration = timeit.timeit(
"inst.space(5)",
globals={
"inst": inst,
},
number=number,
)

print(
f"Evaluating linear function took {duration / number:.6f} seconds on average."
)


def bench_function_evaluation_generic():
def func(arity: int) -> int:
return 12 * arity

fg = generic_function(func)

inst = _make_instruction(42, 0, None, 1, fg, None, 1.0, {})
number = 1000
duration = timeit.timeit(
"inst.space(5)",
globals={
"inst": inst,
},
number=number,
)

print(
f"Evaluating linear function took {duration / number:.6f} seconds on average."
)


if __name__ == "__main__":
bench_enumerate_instances()
bench_enumerate_isas()
bench_function_evaluation_linear()
bench_function_evaluation_generic()
22 changes: 22 additions & 0 deletions source/pip/qsharp/magnets/geometry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Geometry module for representing quantum system topologies.

This module provides hypergraph data structures for representing the
geometric structure of quantum systems, including lattice topologies
and interaction graphs.
"""

from .complete import CompleteBipartiteGraph, CompleteGraph
from .lattice1d import Chain1D, Ring1D
from .lattice2d import Patch2D, Torus2D

__all__ = [
"CompleteBipartiteGraph",
"CompleteGraph",
"Chain1D",
"Ring1D",
"Patch2D",
"Torus2D",
]
187 changes: 187 additions & 0 deletions source/pip/qsharp/magnets/geometry/complete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Complete graph geometries for quantum simulations.

This module provides classes for representing complete graphs and complete
bipartite graphs as hypergraphs. These structures are useful for quantum
systems with all-to-all or bipartite all-to-all interactions.
"""

from qsharp.magnets.utilities import (
Hyperedge,
Hypergraph,
HypergraphEdgeColoring,
)


class CompleteGraph(Hypergraph):
"""A complete graph where every vertex is connected to every other vertex.

In a complete graph K_n, there are n vertices and n(n-1)/2 edges,
with each pair of distinct vertices connected by exactly one edge.

Attributes:
n: Number of vertices in the graph.

Example:

.. code-block:: python
>>> graph = CompleteGraph(4)
>>> graph.nvertices
4
>>> graph.nedges
6
"""

def __init__(self, n: int, self_loops: bool = False) -> None:
"""Initialize a complete graph.

Args:
n: Number of vertices in the graph.
self_loops: If True, include self-loop edges on each vertex
for single-site terms.
"""
if self_loops:
_edges = [Hyperedge([i]) for i in range(n)]
else:
_edges = []

# Add all pairs of vertices
for i in range(n):
for j in range(i + 1, n):
_edges.append(Hyperedge([i, j]))
super().__init__(_edges)

self.n = n

def edge_coloring(self) -> HypergraphEdgeColoring:
"""Compute edge coloring for this complete graph."""
coloring = HypergraphEdgeColoring(self)
for edge in self.edges():
if len(edge.vertices) == 1:
coloring.add_edge(edge, -1)
else:
if self.n % 2 == 0:
i, j = edge.vertices
m = self.n - 1
if j == m:
coloring.add_edge(edge, i)
elif (j - i) % 2 == 0:
coloring.add_edge(edge, (j - i) // 2)
else:
coloring.add_edge(edge, (j - i + m) // 2)
else:
m = self.n
i, j = edge.vertices
if (j - i) % 2 == 0:
coloring.add_edge(edge, (j - i) // 2)
else:
coloring.add_edge(edge, (j - i + m) // 2)
return coloring


class CompleteBipartiteGraph(Hypergraph):
"""A complete bipartite graph with two vertex sets.

In a complete bipartite graph K_{m,n} (m <= n), there are m + n
vertices partitioned into two sets of sizes m and n. Every vertex
in the first set is connected to every vertex in the second set,
giving m * n edges total.

Vertices 0 to m-1 form the first set, and vertices m to m+n-1
form the second set.

Attributes:
m: Number of vertices in the first set.
n: Number of vertices in the second set.

Requires:
m <= n

Example:

.. code-block:: python
>>> graph = CompleteBipartiteGraph(2, 3)
>>> graph.nvertices
5
>>> graph.nedges
6
"""

def __init__(self, m: int, n: int, self_loops: bool = False) -> None:
"""Initialize a complete bipartite graph.

Args:
m: Number of vertices in the first set (vertices 0 to m-1).
n: Number of vertices in the second set (vertices m to m+n-1).
self_loops: If True, include self-loop edges on each vertex
for single-site terms.
"""
assert m <= n, "Require m <= n for CompleteBipartiteGraph."
total_vertices = m + n

if self_loops:
_edges = [Hyperedge([i]) for i in range(total_vertices)]

else:
_edges = []

# Connect every vertex in first set to every vertex in second set
for i in range(m):
for j in range(m, m + n):
_edges.append(Hyperedge([i, j]))
super().__init__(_edges)

self.m = m
self.n = n

def edge_coloring(self) -> HypergraphEdgeColoring:
"""Compute edge coloring for this complete bipartite graph."""
coloring = HypergraphEdgeColoring(self)
m = self.m
n = self.n
for edge in self.edges():
if len(edge.vertices) == 1:
coloring.add_edge(edge, -1)
else:
i, j = edge.vertices
coloring.add_edge(edge, (i + j - m) % n)
return coloring

# Color edges based on the second vertex index to create n parallel partitions
# for i in range(m):
# for j in range(m, m + n):
# self.color[(i, j)] = (
# i + j - m
# ) % n # Color edges based on second vertex index

# Edge coloring for parallel updates
# The even case: n-1 colors are needed
# if n % 2 == 0:
# m = n - 1
# for i in range(m):
# self.color[(i, n - 1)] = (
# i # Connect vertex n-1 to all others with unique colors
# )
# for j in range(1, (m - 1) // 2 + 1):
# a = (i + j) % m
# b = (i - j) % m
# if a < b:
# self.color[(a, b)] = i
# else:
# self.color[(b, a)] = i

# The odd case: n colors are needed
# This is the round-robin tournament scheduling algorithm for odd n
# Set m = n for ease of reading
# else:
# m = n
# for i in range(m):
# for j in range(1, (m - 1) // 2 + 1):
# a = (i + j) % m
# b = (i - j) % m
# if a < b:
# self.color[(a, b)] = i
# else:
# self.color[(b, a)] = i
Loading
Loading