Spaces:
Runtime error
Runtime error
Download src/scripts/run_error_mitigation.py from QuantumGenAI/ErrorMitigation: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/QuantumGenAI/ErrorMitigation/resolve/main/src/scripts/run_error_mitigation.py
- Command line
-
hf download hf://spaces/QuantumGenAI/ErrorMitigation/src/scripts/run_error_mitigation.py
-
curl -L -o run_error_mitigation.py https://huggingface.co/spaces/QuantumGenAI/ErrorMitigation/resolve/main/src/scripts/run_error_mitigation.py
1.42 kB
| import json | |
| from pathlib import Path | |
| import duckdb | |
| from quantum_circuits.circuit_error_mitigator import process_circuit | |
| from utils.qasm_utils import get_qasm_circuit_depth | |
| def main(): | |
| # Connect to the database file | |
| database_location = ( | |
| Path(__file__).parent.parent / "database" / "quantum_circuits.duckdb" | |
| ) | |
| con = duckdb.connect(database_location) | |
| # Read data from a table (replace 'your_table' with the actual table name) | |
| df = con.execute("SELECT * FROM circuits LIMIT 1000").fetchdf() | |
| for i, row in enumerate(df.itertuples()): | |
| try: | |
| circuit_depth = get_qasm_circuit_depth(df.qasm[i]) | |
| if i >= 100 and circuit_depth <= 10: | |
| res_qwen = process_circuit(i, df, model="qwen2.5:14b") | |
| res_phi = process_circuit(i, df, model="phi4") | |
| result = { | |
| "qwen": res_qwen.model_dump(), | |
| "phi": res_phi.model_dump(), | |
| "db_index": i, | |
| "circuit_depth": circuit_depth, | |
| } | |
| with open("output.jsonl", "a", encoding="utf-8") as f: | |
| f.write(json.dumps(result) + "\n") | |
| except Exception as e: | |
| with open("output.jsonl", "a", encoding="utf-8") as f: | |
| f.write(json.dumps({"error": str(e), "db_index": i}) + "\n") | |
| con.close() | |
| if __name__ == "__main__": | |
| main() | |