> ## Documentation Index
> Fetch the complete documentation index at: https://prod-mint.classiq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quantum Program Constraints

When synthesizing a quantum program, you can pass a maximum width constraint to the generation; for example, requiring that no more than 20 qubits are used.

Pass constraints as follows:

<Tabs>
  <Tab title="SDK">
    ```python theme={null}
    from classiq import *

    constraints = Constraints(max_width=20)


    @qfunc
    def main(res: Output[QBit]) -> None:
        allocate(res)


    synthesize(main, constraints=constraints)
    ```
  </Tab>
</Tabs>

## Optimization Parameter

When synthesizing a quantum program, to optimize the quantum program according to a
parameter, set the `optimization_parameter` field. The possible
parameters are the same parameters that can be constrained.

The following example shows how to remove the width constraint in the quantum program, setting it instead
as the optimization parameter.

<Tabs>
  <Tab title="SDK">
    ```python theme={null}
    from classiq import (
        qfunc,
        Constraints,
        OptimizationParameter,
        Output,
        QBit,
        TranspilerBasisGates,
        allocate,
        set_constraints,
        synthesize,
    )

    constraints = Constraints(
        max_width=20,
        optimization_parameter=OptimizationParameter.DEPTH,
    )


    @qfunc
    def main(res: Output[QBit]) -> None:
        allocate(1, res)


    synthesize(main, constraints=constraints)
    ```
  </Tab>
</Tabs>
