Developer documentation
Build on 4colors from your own code
Python clients and Qiskit and dimod integrations for the Quantum Compiler and the Optimizer for QUBO. Pick your product and start from a working example.
The same four API endpoints serve the Quantum Compiler and the Optimizer for QUBO.
Products
Choose your product
Both products run from Python and one hosted API. Quantum teams can also stay in Qiskit or dimod.
Workflow
One workflow for every product
Prepare the model
Describe the problem in a supported format: a circuit and its target, or a QUBO or Ising model.
Submit with a time budget
The search returns a first answer quickly and better ones as it runs. Stop as soon as one is good enough.
Inspect and validate
Read the status, the metrics and the best result, then check it in your application before it drives a decision.
Quantum Compiler
4colors Quantum Compiler
Compile circuits for IBM, IQM and Rigetti devices or a custom target. Keep writing circuits the way you do now and add one call.
Existing code
Qiskit plugin
Drop it into your Qiskit workflow as a pass manager.
Explore Quantum Compilerfrom fourcolors.quantum.compiler import generate_pass_managerpm = generate_pass_manager(backend, time_budget_s=30)compiled = pm.run(qc)Scripts and notebooks
Python module
Submit a job and follow each better circuit as it arrives.
Start a free trialfrom fourcolors.quantum import compiler, targetstarget = targets.design_lattice("heavy_hex_156_cz") # a real device: targets.from_qiskit(backend)job = compiler.submit(open("circuit.qasm").read(), target, time_budget_s=30)for res in job.incumbents(): print(res.metrics["two_qubit_gates"], res.metrics["depth"])print(res.circuit)QUBO solver
4colors Optimizer for QUBO
Solve QUBO and Ising models with a time budget. Keep your models as they are and add one call.
Scripts and notebooks
Python module
Submit a model and follow each better solution as it arrives.
Start a free trialimport fourcolorsQ = {(0, 1): 2, (1, 2): 2, (2, 3): 2, (0, 3): -3}job = fourcolors.qubo.submit(Q, time_limit_s=30, linear=[-1, -1, -1, -1])for res in job.incumbents(): print(res.objective)print(res.solution)Existing code
dimod
Use it as a dimod sampler, on the binary quadratic models you already have.
Explore Optimizer for QUBOimport dimodfrom fourcolors import FourColorsSamplerbqm = dimod.generators.ran_r(1, 50, seed=1) # or your own BinaryQuadraticModelsampleset = FourColorsSampler().sample(bqm, time_limit_s=30)print(sampleset.first.energy)print(sampleset.first.sample)API
One hosted API for every product
The same four endpoints serve the Quantum Compiler and the Optimizer for QUBO, so one integration covers both.
Example request
Submit and follow a job
Send a job with a time budget, then stream each better result as the search finds it.
Plans and limits# options.target is a description of the device (qubits, two-qubit gate, couplers, calibration), never a name.# The Python client builds one from a real device: fourcolors.quantum.targets.from_qiskit(backend).curl https://api.4colors-research.com/v1/jobs \ -H "Authorization: Bearer $FOURCOLORS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "solver": "quantum.compiler", "input": {"circuit": "OPENQASM 3.0; include \"stdgates.inc\"; qubit[3] q; h q[0]; cx q[0], q[1]; cx q[1], q[2];"}, "options": { "target": {"format_version": 2, "n_qubits": 3, "two_qubit_gate": "cz", "couplers": [[0, 1], [1, 2]]}, "time_budget_s": 15 } }'curl -N https://api.4colors-research.com/v1/jobs/JOB_ID/events \ -H "Authorization: Bearer $FOURCOLORS_API_KEY"Any language or pipeline
Direct API
Submit from any language, follow results live, and stop early when the answer is good enough.
Discuss technical integration- POST /v1/jobs
- Submit a circuit or model with a time budget
- GET /v1/jobs/{id}/events
- Follow each better result live
- GET /v1/jobs/{id}
- Read the final result and its metrics
- POST /v1/jobs/{id}/stop
- Stop early and keep the best result
Measure on representative instances
Start with a small instance you can check, then compare on your own models and settings.