{"uid":"cap_1hW8cjqXD1Um-yrwTx45H","slug":"quantum-circuit-local-gate-optimizer-34674a59","name":"Quantum Circuit Local Gate Optimizer","description":"Cancels adjacent identical self-inverse gates on identical ordered targets and folds adjacent RX, RY or RZ rotations on identical targets. It preserves only these local identities; it does not commute gates, model hardware topology, synthesize arbitrary unitaries or prove global optimality.","url":"https://quantum.halowerk.com/v1/circuit-optimize","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"gates":{"type":"array","items":{"type":"object","required":["gate","targets"],"properties":{"gate":{"enum":["X","Y","Z","H","CNOT","CZ","SWAP","RX","RY","RZ"],"type":"string"},"targets":{"type":"array","items":{"type":"integer","maximum":127,"minimum":0},"maxItems":2,"minItems":1,"uniqueItems":true},"angle_rad":{"type":"number","maximum":1000000,"minimum":-1000000}},"additionalProperties":false},"maxItems":10000,"minItems":1},"qubit_count":{"type":"integer","maximum":128,"minimum":1}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.004","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.004/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_wsJp4GsobEXfqr1iyrkkn","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.004","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Cancels adjacent identical self-inverse gates on the same qubits and merges adjacent RX/RY/RZ rotation gates on identical targets into single rotations.","exampleAgentPrompt":"Optimize this quantum circuit for me — it has 6 qubits and the gate list is: H on qubit 0, H on qubit 0, RX(0.5) on qubit 1, RX(0.3) on qubit 1, CNOT on qubits 0 and 1. Cancel any redundant adjacent gates and fold the rotations.","exampleUseCases":[{"title":"Cancel redundant Hadamard pairs","prompt":"I have a 4-qubit circuit where H is applied twice in a row on qubit 2 — can you optimize it and remove those redundant gates? The full gate list is: H on qubit 0, CNOT on qubits 0 and 1, H on qubit 2, H on qubit 2, RZ(1.57) on qubit 3."},{"title":"Fold accumulated rotation angles","prompt":"I've built up a sequence of RY rotations on qubit 0 — RY(0.3), RY(0.7), RY(0.5) — and I want them folded into a single gate. The circuit has 2 qubits, can you merge those into one RY?"},{"title":"Pre-process circuit before hardware submission","prompt":"Before I submit this 8-qubit circuit to the hardware backend, can you do a local gate optimization pass to cancel any adjacent self-inverse gates and merge consecutive RX or RZ rotations on the same qubit? Here's the gate list: X on qubit 0, X on qubit 0, RZ(0.4) on qubit 1, RZ(0.9) on qubit 1, CZ on qubits 2 and 3."}],"resultDescription":"Returns the optimized gate sequence with adjacent self-inverse gate pairs removed and consecutive same-axis rotation angles folded into single gates, reducing overall gate count while preserving the circuit's unitary operation.","failureModes":["Gate list exceeds 10000 gates — request rejected","Qubit index exceeds qubit_count or exceeds maximum of 127","RX/RY/RZ gate missing required angle_rad field","Invalid gate type not in supported enum","angle_rad outside allowed range [-1000000, 1000000]","Empty gate list submitted"],"whenToPreferThis":"Use this endpoint when you need fast, local gate count reduction on a quantum circuit — specifically to cancel adjacent self-inverse gates (X, H, CNOT, etc.) or merge consecutive same-axis rotations (RX, RY, RZ). It is ideal as a lightweight preprocessing step before hardware submission. Do not use it if you need commutativity-based reordering, hardware topology mapping, arbitrary unitary synthesis, or global optimality guarantees.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T12:46:16.316Z","isFirstParty":false}