File size: 1,419 Bytes
e0d7f28
 
b925346
 
e0d7f28
 
 
b925346
 
e0d7f28
 
 
b925346
 
 
 
 
 
 
e0d7f28
f0f7dac
b925346
 
e0d7f28
 
 
 
 
 
 
b925346
 
e0d7f28
b925346
 
 
 
e0d7f28
b925346
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()