Skip to content

Commit e89f4ad

Browse files
authored
Merge pull request #66 from qBraid/vinayswamik-Bug-Fixes
Refactor: Restructure qBraid-Algorithms, update docs, and fix functionality
2 parents f1d54fa + e939ebd commit e89f4ad

62 files changed

Lines changed: 2603 additions & 1037 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/algorithm-implementation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ assignees: ''
88
---
99

1010
**Required functions to implement:**
11-
- [ ] `load_program()` - Load complete executable circuit
12-
- [ ] `generate_subroutine()` - Generate reusable subroutine
11+
- [ ] `generate_program()` - Load complete executable circuit
12+
- [ ] `save_to_qasm()` - Generate reusable subroutine
1313
- [ ] Additional functions: _______________
1414

1515
**CLI integration needed:**

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ you can generate .qasm files to use them as subroutines in your own circuits.
6565

6666
### Loading Algorithms as PyQASM Modules
6767

68-
To load an algorithm as a PyQASM module, use the `load_algorithm` function from the `qbraid_algorithms` package, passing algorithm-specific parameters. For example, to load the Quantum Fourier Transform (QFT) algorithm:
68+
To load an algorithm as a PyQASM module, use the `generate_program` function from the `qbraid_algorithms` package, passing algorithm-specific parameters. For example, to load the Quantum Fourier Transform (QFT) algorithm:
6969

7070
```python
7171
from qbraid_algorithms import qft
7272

73-
qft_module = qft.load_algorithm(3) # Load QFT for 3 qubits
73+
qft_module = qft.generate_program(3) # Load QFT for 3 qubits
7474
```
7575

7676
Now, you can perform operations with the PyQASM module, such as unrolling, and
@@ -84,15 +84,15 @@ qasm_str = pyqasm.dumps(qft_module)
8484
### Loading Algorithms as `.qasm` Files
8585

8686
In order to utilize algorithms as subroutines in your own circuits, use the
87-
`generate_subroutine` function for your desired algorithm. By passing algorithm-specific parameters, and optionally a desired output path, you can
87+
`save_to_qasm` function for your desired algorithm. By passing algorithm-specific parameters, and optionally a desired output path, you can
8888
generate a .qasm file containing a subroutine for the paramterized circuit. For
8989
example, to generate a QFT subroutine for 4 qubits:
9090

9191
```python
9292
from qbraid_algorithms import qft, iqft
9393
path = "path/to/output" # Specify your desired output path
94-
qft.generate_subroutine(4) # Generate 4-qubit QFT in the current directory
95-
iqft.generate_subroutine(4, path=path) # Generate 4-qubit IQFT in specified path
94+
qft.save_to_qasm(4) # Generate 4-qubit QFT in the current directory
95+
iqft.save_to_qasm(4, path=path) # Generate 4-qubit IQFT in specified path
9696

9797
```
9898

@@ -101,7 +101,7 @@ To utilize the generated subroutine in your own circuit, include the generated
101101
when generating the subroutine. For example, after running
102102

103103
```python
104-
qft.generate_subroutine(4)
104+
qft.save_to_qasm(4)
105105
```
106106

107107
you can append `include "qft.qasm";` to your OpenQASM file, and call the

docs/_static/css/custom.css

Lines changed: 146 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717
--font-color4: #ffffff;
1818
--brand-color0: #46096f;
1919
--brand-color1: #df0982;
20-
--active-gradient0: linear-gradient(
21-
45deg,
22-
var(--brand-color1),
23-
var(--brand-color0)
24-
);
25-
--active-gradient1: linear-gradient(
26-
rgb(135, 0, 202) -41.11%,
27-
rgba(216, 164, 250, 0.92) 197.13%
28-
);
20+
--active-gradient0: linear-gradient(45deg,
21+
var(--brand-color1),
22+
var(--brand-color0));
23+
--active-gradient1: linear-gradient(rgb(135, 0, 202) -41.11%,
24+
rgba(216, 164, 250, 0.92) 197.13%);
2925
}
3026

3127
.wy-body-for-nav {
@@ -44,14 +40,14 @@
4440
color: var(--font-color0);
4541
}
4642

47-
.wy-side-nav-search > a {
43+
.wy-side-nav-search>a {
4844
color: var(--font-color0);
4945
display: flex;
5046
align-items: center;
5147
justify-content: center;
5248
}
5349

54-
.wy-side-nav-search > a::before {
50+
.wy-side-nav-search>a::before {
5551
content: "";
5652
background-image: url(../logo.png);
5753
background-size: contain;
@@ -64,7 +60,7 @@
6460
color: var(--font-color2) !important;
6561
}
6662

67-
.wy-menu-vertical li.current > a,
63+
.wy-menu-vertical li.current>a,
6864
.wy-menu-vertical li.on a {
6965
background-image: var(--active-gradient0);
7066
background-size: 150%;
@@ -73,14 +69,14 @@
7369
transition: background-position 150ms ease;
7470
}
7571

76-
.wy-menu-vertical li.current > a:hover,
72+
.wy-menu-vertical li.current>a:hover,
7773
.wy-menu-vertical li.on a:hover {
7874
background-image: var(--active-gradient0);
7975
background-size: 150%;
8076
background-position: right;
8177
}
8278

83-
.wy-menu-vertical li.current > a:hover button.toctree-expand,
79+
.wy-menu-vertical li.current>a:hover button.toctree-expand,
8480
.wy-menu-vertical li.on a:hover button.toctree-expand {
8581
color: var(--font-color3);
8682
}
@@ -104,7 +100,7 @@
104100
}
105101

106102
/* headers */
107-
.rst-content .toctree-wrapper > p.caption,
103+
.rst-content .toctree-wrapper>p.caption,
108104
h1,
109105
h2,
110106
h3,
@@ -117,12 +113,22 @@ legend {
117113
color: var(--brand-color0);
118114
}
119115

116+
117+
/* Style h1 headers only on API and stubs pages */
118+
html[data-content_root="../"] h1 {
119+
opacity: 0.5 !important;
120+
color: #000000 !important;
121+
font-size: 100% !important;
122+
font-weight: normal !important;
123+
font-style: italic !important;
124+
}
125+
120126
.wy-menu-vertical header,
121127
.wy-menu-vertical p.caption {
122128
color: var(--brand-color0);
123129
}
124130

125-
.wy-menu-vertical li.current > a button.toctree-expand,
131+
.wy-menu-vertical li.current>a button.toctree-expand,
126132
.wy-menu-vertical li.on a button.toctree-expand {
127133
color: var(--font-color4);
128134
}
@@ -137,7 +143,7 @@ legend {
137143
transition: transform 150ms ease;
138144
}
139145

140-
.card > h3 {
146+
.card>h3 {
141147
color: var(--font-color0);
142148
}
143149

@@ -221,17 +227,6 @@ legend {
221227
font-family: "Source Sans Pro", sans-serif;
222228
}
223229

224-
/* Foot note */
225-
.rst-content .seealso .admonition-title {
226-
background: var(--active-gradient0);
227-
}
228-
229-
.rst-content .seealso {
230-
background: var(--layout-color0);
231-
border-radius: 8px;
232-
overflow: hidden;
233-
}
234-
235230
/* common elements */
236231
.rst-content p a {
237232
-webkit-text-fill-color: transparent;
@@ -241,7 +236,7 @@ legend {
241236
background-clip: text;
242237
}
243238

244-
.wy-breadcrumbs > li.wy-breadcrumbs-aside > a {
239+
.wy-breadcrumbs>li.wy-breadcrumbs-aside>a {
245240
-webkit-text-fill-color: transparent;
246241
text-fill-color: transparent;
247242
background: var(--active-gradient0);
@@ -267,3 +262,125 @@ a .rst-content tt {
267262
-webkit-text-fill-color: var(--brand-color0);
268263
text-fill-color: var(--brand-color0);
269264
}
265+
266+
/* =============================================================================
267+
ADMONITION BOXES STYLING
268+
============================================================================= */
269+
270+
/* Shared border radius for enhanced elements */
271+
.rst-content .note-enhanced,
272+
.rst-content .seealso,
273+
.rst-content .seealso table.autosummary {
274+
border-radius: 10px;
275+
}
276+
277+
/* Note Enhanced Boxes */
278+
.rst-content .note-enhanced {
279+
font-size: 1.5em;
280+
background: white;
281+
box-shadow: 0 4px 18px rgba(70, 9, 111, 0.50);
282+
}
283+
284+
.rst-content .note-enhanced .admonition-title {
285+
border-radius: 10px 10px 0 0;
286+
background: var(--active-gradient0);
287+
color: #ffffff !important;
288+
font-weight: bold;
289+
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
290+
padding: 12px 16px;
291+
}
292+
293+
.rst-content .note-enhanced .admonition-title::before {
294+
display: none !important;
295+
}
296+
297+
/* Seealso Boxes */
298+
.rst-content .seealso {
299+
font-size: 1.1em;
300+
background: white;
301+
box-shadow: 0 4px 18px rgba(70, 9, 111, 0.50);
302+
}
303+
304+
/* Reduce line spacing in formulation sections */
305+
.rst-content .seealso p {
306+
margin-bottom: 0.5em;
307+
line-height: 1.3;
308+
}
309+
310+
.rst-content .seealso ol,
311+
.rst-content .seealso ul {
312+
margin-bottom: 0.5em;
313+
}
314+
315+
.rst-content .seealso li {
316+
margin-bottom: 0.3em;
317+
line-height: 1.3;
318+
}
319+
320+
.rst-content .seealso .math {
321+
margin: 0.2em 0;
322+
line-height: 1.2;
323+
}
324+
325+
.rst-content .seealso .admonition-title {
326+
border-radius: 10px 10px 0 0;
327+
padding-top: 16px;
328+
background: white;
329+
color: var(--brand-color0) !important;
330+
font-weight: bold;
331+
}
332+
333+
.rst-content .seealso.note-enhanced-size .admonition-title::before,
334+
.rst-content .left-box .admonition-title::before,
335+
.rst-content .right-box .admonition-title::before {
336+
display: none !important;
337+
}
338+
339+
.rst-content .seealso.note-enhanced-size>.admonition-title {
340+
font-weight: bold;
341+
text-align: center;
342+
}
343+
344+
/* Tables */
345+
.rst-content .seealso table.autosummary {
346+
border-collapse: separate;
347+
border-spacing: 0;
348+
border-width: 2px !important;
349+
}
350+
351+
/* =============================================================================
352+
SIDE-BY-SIDE ALGORITHM LAYOUT
353+
============================================================================= */
354+
355+
/* Container Layout */
356+
.side-by-side {
357+
display: flex;
358+
}
359+
360+
.left-box,
361+
.right-box {
362+
flex-direction: column;
363+
}
364+
365+
/* Algorithm Boxes */
366+
.rst-content .left-box .note,
367+
.rst-content .right-box .note {
368+
background: white !important;
369+
overflow: hidden !important;
370+
}
371+
372+
/* Algorithm Titles */
373+
.left-box .admonition-title,
374+
.right-box .admonition-title {
375+
text-align: center;
376+
font-size: 1em !important;
377+
}
378+
379+
/* =============================================================================
380+
PAGE-SPECIFIC FIXES
381+
============================================================================= */
382+
383+
/* Hide duplicate title on all qbraid_algorithms submodule pages */
384+
section[id^="module-qbraid_algorithms."]>p:first-of-type {
385+
display: none;
386+
}

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"sphinx.ext.autodoc",
2626
"sphinx_autodoc_typehints",
2727
"sphinx.ext.autosummary",
28-
"sphinx_copybutton"
28+
"sphinx_copybutton",
2929
]
3030

3131
autodoc_mock_imports = ["qbraid", "pyqasm"]
@@ -52,4 +52,4 @@
5252
html_favicon = "_static/favicon.ico"
5353
html_show_sphinx = False
5454

55-
html_css_files = ["css/s4defs-roles.css"]
55+
html_css_files = ["css/s4defs-roles.css", "css/custom.css"]

docs/index.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<span style="color:#808080"> | algorithms</span>
5252
</h1>
5353
<p style="text-align:center;font-style:italic;color:#808080">
54-
Use and build quantum algorithms with qBraid.
54+
Build Quantum Algorithms with qBraid.
5555
</p>
5656
</body>
5757
</html>
@@ -61,10 +61,21 @@
6161
:Release: |release|
6262

6363
Overview
64-
---------
64+
--------
6565

66-
Python package for utilizing, implementing, and building quantum algorithms in OpenQASM 3.
66+
`qBraid Algorithms <https://docs.qbraid.com/qbraid-algorithms/user-guide/overview>`_ is a Python package designed for quantum algorithm development, implementation, and execution. Built on the `OpenQASM3 <https://openqasm.com/>`_ standard, this library provides researchers, developers, and quantum computing enthusiasts with a robust toolkit for exploring and deploying quantum algorithms across various domains.
6767

68+
**Key Features:**
69+
70+
* **Comprehensive Algorithm Library**: Implementation of fundamental quantum algorithms including Grover's search, Quantum Fourier Transform (QFT), Quantum Phase Estimation (QPE), and advanced techniques like amplitude amplification and Hamiltonian evolution.
71+
72+
* **OpenQASM 3 Integration**: Native support for OpenQASM 3, enabling seamless integration with modern quantum hardware and simulators while maintaining compatibility with the evolving quantum computing ecosystem.
73+
74+
* **Modular Architecture**: Clean, modular design that allows for easy extension, customization, and integration into existing quantum computing workflows.
75+
76+
* **Research-Ready Implementation**: Optimized for both educational purposes and cutting-edge research, with implementations suitable for near-term quantum devices (NISQ era) and fault-tolerant quantum computers.
77+
78+
* **Hardware Agnostic**: Designed to work across different quantum computing platforms and simulators, providing flexibility in deployment and testing.
6879

6980
Installation
7081
-------------
@@ -77,7 +88,7 @@ qbraid-algorithms requires Python 3.11 or greater, and can be installed with pip
7788
7889
7990
Install from Source
80-
^^^^^^^^^^^^^^^^^^^^
91+
--------------------
8192

8293
You can also install from source by cloning this repository and running a pip install command in the root directory of the repository:
8394

0 commit comments

Comments
 (0)