Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,39 +1,36 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
from qiskit import QuantumInstance
|
| 4 |
-
from qiskit.algorithms import Shor
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
def
|
| 9 |
try:
|
| 10 |
N = int(N)
|
| 11 |
-
if N
|
| 12 |
-
return
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
except Exception as e:
|
| 28 |
return str(e)
|
| 29 |
|
| 30 |
-
# Gradio interface
|
| 31 |
iface = gr.Interface(
|
| 32 |
-
fn=
|
| 33 |
-
inputs=gr.Number(label="Enter
|
| 34 |
outputs=gr.Textbox(label="Result"),
|
| 35 |
-
title="
|
| 36 |
-
description="
|
| 37 |
)
|
| 38 |
|
| 39 |
if __name__ == "__main__":
|
|
|
|
| 1 |
+
from qiskit import QuantumCircuit, transpile, assemble, Aer, execute
|
| 2 |
+
from qiskit.visualization import plot_histogram
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
# This is just a placeholder for a basic quantum circuit that shows QFT
|
| 6 |
+
def run_basic_qft_demo(N):
|
| 7 |
try:
|
| 8 |
N = int(N)
|
| 9 |
+
if N <= 0 or N > 8:
|
| 10 |
+
return "Please enter a small integer (1–8) for demo."
|
| 11 |
+
|
| 12 |
+
qc = QuantumCircuit(N)
|
| 13 |
+
# Apply Hadamards to all qubits as a trivial QFT placeholder
|
| 14 |
+
for i in range(N):
|
| 15 |
+
qc.h(i)
|
| 16 |
+
|
| 17 |
+
backend = Aer.get_backend("aer_simulator")
|
| 18 |
+
qc.measure_all()
|
| 19 |
+
|
| 20 |
+
result = execute(qc, backend, shots=1024).result()
|
| 21 |
+
counts = result.get_counts()
|
| 22 |
+
|
| 23 |
+
return f"Simulated simple QFT-like circuit for {N} qubits.\nResult: {counts}"
|
| 24 |
+
|
| 25 |
except Exception as e:
|
| 26 |
return str(e)
|
| 27 |
|
|
|
|
| 28 |
iface = gr.Interface(
|
| 29 |
+
fn=run_basic_qft_demo,
|
| 30 |
+
inputs=gr.Number(label="Enter number of qubits (1–8)"),
|
| 31 |
outputs=gr.Textbox(label="Result"),
|
| 32 |
+
title="Modern Qiskit Demo — QFT placeholder",
|
| 33 |
+
description="Modern Qiskit 1.x example: runs a trivial circuit to show basic QFT structure. For real Shor, you’d build modular exponentiation + QFT manually."
|
| 34 |
)
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|