Spaces:
Runtime error
Runtime error
| from qiskit import QuantumCircuit, transpile, assemble, Aer, execute | |
| from qiskit.visualization import plot_histogram | |
| import gradio as gr | |
| # This is just a placeholder for a basic quantum circuit that shows QFT | |
| def run_basic_qft_demo(N): | |
| try: | |
| N = int(N) | |
| if N <= 0 or N > 8: | |
| return "Please enter a small integer (1–8) for demo." | |
| qc = QuantumCircuit(N) | |
| # Apply Hadamards to all qubits as a trivial QFT placeholder | |
| for i in range(N): | |
| qc.h(i) | |
| backend = Aer.get_backend("aer_simulator") | |
| qc.measure_all() | |
| result = execute(qc, backend, shots=1024).result() | |
| counts = result.get_counts() | |
| return f"Simulated simple QFT-like circuit for {N} qubits.\nResult: {counts}" | |
| except Exception as e: | |
| return str(e) | |
| iface = gr.Interface( | |
| fn=run_basic_qft_demo, | |
| inputs=gr.Number(label="Enter number of qubits (1–8)"), | |
| outputs=gr.Textbox(label="Result"), | |
| title="Modern Qiskit Demo — QFT placeholder", | |
| 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." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() |