{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "7acdb263-fde4-4ff3-a13d-c499a2ba77e4",
      "metadata": {},
      "source": [
        "---\n",
        "title: Specify Executor options\n",
        "description: Specify options when building with the Executor primitive.\n",
        "---\n",
        "\n",
        "# Specify Executor options\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "73e3d6f4",
      "metadata": {
        "tags": [
          "version-info"
        ]
      },
      "source": [
        "{/*\n",
        "  DO NOT EDIT THIS CELL!!!\n",
        "  This cell's content is generated automatically by a script. Anything you add\n",
        "  here will be removed next time the notebook is run. To add new content, create\n",
        "  a new cell before or after this one.\n",
        "  */}\n",
        "\n",
        "<Accordion>\n",
        "  <AccordionItem title=\"Package versions\">\n",
        "    The code on this page was developed using the following requirements.\n",
        "    We recommend using these versions or newer.\n",
        "\n",
        "    ```\n",
        "    qiskit-ibm-runtime~=0.46.1\n",
        "    ```\n",
        "  </AccordionItem>\n",
        "</Accordion>\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "513837ac-8853-4f45-8d8f-1a8297d5ab68",
      "metadata": {},
      "source": [
        "You can use options to customize the Executor primitive.\n",
        "\n",
        "<Admonition type=\"note\" title=\"Notes\">\n",
        "  * You can see the available options and update option values during or after primitive initialization.\n",
        "  * Use the `update()` method to apply changes to the `options` attribute.\n",
        "  * The `options` attribute is the `dataclass` Python type.  You can use the built-in `asdict` method to convert it to a dictionary.\n",
        "</Admonition>\n",
        "\n",
        "<span id=\"pass-options\" />\n",
        "\n",
        "## Set Executor options\n",
        "\n",
        "If an option is specified both during and after primitive initialization, the value set after initializing the primitive is used.\n",
        "\n",
        "### Primitive initialization\n",
        "\n",
        "You can pass in an instance of the options class or a dictionary when initializing Executor, which then makes a copy of those options. Thus, changing the original dictionary or options instance doesn't affect the options owned by the primitive.\n",
        "\n",
        "#### Options class\n",
        "\n",
        "When creating an instance of the `Executor` class, you can pass in an instance of the options class. Those options are then applied when you use `run()` to perform the calculation.  Specify the options in this format:  `options.option.sub-option.sub-sub-option = choice`.  For example: `options.environment.log_level = INFO`.\n",
        "\n",
        "Example:\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "id": "948f4e75-3079-4c18-ba38-ce536b3f99b5",
      "metadata": {},
      "outputs": [],
      "source": [
        "from qiskit_ibm_runtime import QiskitRuntimeService, Executor\n",
        "from qiskit_ibm_runtime.options import ExecutorOptions\n",
        "\n",
        "service = QiskitRuntimeService()\n",
        "backend = service.least_busy(operational=True, simulator=False)\n",
        "\n",
        "options = ExecutorOptions(\n",
        "    environment={\"log_level\": \"INFO\"},\n",
        "    execution={\"init_qubits\": True},\n",
        ")\n",
        "\n",
        "# or use the following instead:\n",
        "\n",
        "options = ExecutorOptions()\n",
        "options.environment.log_level = \"INFO\"\n",
        "options.execution.init_qubits = True\n",
        "\n",
        "executor = Executor(mode=backend, options=options)"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "ba2f5146-2781-49da-9fa2-8a22647225d0",
      "metadata": {},
      "source": [
        "#### Dictionary\n",
        "\n",
        "You can specify options as a dictionary when initializing Executor.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "id": "cf4359c2-c97a-475c-998d-518dc05a445e",
      "metadata": {},
      "outputs": [],
      "source": [
        "from qiskit_ibm_runtime import QiskitRuntimeService, Executor\n",
        "\n",
        "service = QiskitRuntimeService()\n",
        "backend = service.least_busy(operational=True, simulator=False)\n",
        "\n",
        "# Setting options during primitive initialization\n",
        "executor = Executor(\n",
        "    backend,\n",
        "    options={\n",
        "        \"environment\": {\"log_level\": \"INFO\"},\n",
        "        \"execution\": {\"init_qubits\": True},\n",
        "    },\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "b981eda7-bd9b-4d1e-959a-12cfc35fc2a1",
      "metadata": {},
      "source": [
        "<span id=\"options-table\" />\n",
        "\n",
        "## Available options\n",
        "\n",
        "The following table documents options from the latest version of `qiskit-ibm-runtime`. To see older option versions, visit the [`qiskit-ibm-runtime` API reference](/docs/api/qiskit-ibm-runtime) and select a previous version.\n",
        "\n",
        "<Accordion>\n",
        "  <AccordionItem title=\"`environment`\">\n",
        "    [`environment` API documentation](/docs/api/qiskit-ibm-runtime/options-sampler-options#environment)\n",
        "\n",
        "    <Accordion>\n",
        "      <AccordionItem title=\"`environment.job_tags`\">\n",
        "        List of tags.\n",
        "\n",
        "        **Choices**: None\n",
        "\n",
        "        **Default**: None\n",
        "      </AccordionItem>\n",
        "\n",
        "      <AccordionItem title=\"`environment.log_level`\">\n",
        "        **Choices**: DEBUG, INFO, WARNING, ERROR, CRITICAL\n",
        "\n",
        "        **Default**: WARNING\n",
        "      </AccordionItem>\n",
        "\n",
        "      <AccordionItem title=\"`environment.private`\">\n",
        "        **Choices**: `True`, `False`\n",
        "\n",
        "        **Default**: `False`\n",
        "      </AccordionItem>\n",
        "\n",
        "      <AccordionItem title=\"`environment.max_execution_time`\">\n",
        "        **Choices**: Integer number of seconds in the range \\[1, 10800]\n",
        "\n",
        "        **Default**: 10800 (3 hours)\n",
        "      </AccordionItem>\n",
        "    </Accordion>\n",
        "  </AccordionItem>\n",
        "\n",
        "  <AccordionItem title=\"`execution`\">\n",
        "    [`execution` API documentation](/docs/api/qiskit-ibm-runtime/options-sampler-options#execution)\n",
        "\n",
        "    <Accordion>\n",
        "      <AccordionItem title=\"`execution.init_qubits`\">\n",
        "        Whether to reset the qubits to the ground state for each shot.\n",
        "\n",
        "        **Choices**: `True`, `False`\n",
        "\n",
        "        **Default**: `True`\n",
        "      </AccordionItem>\n",
        "\n",
        "      <AccordionItem title=\"`execution.rep_delay`\">\n",
        "        The delay between a measurement and the subsequent quantum circuit.\n",
        "\n",
        "        **Choices**: Value in the range supplied by `backend.rep_delay_range`\n",
        "\n",
        "        **Default**: Given by `backend.default_rep_delay`\n",
        "      </AccordionItem>\n",
        "\n",
        "      <AccordionItem title=\"`execution.meas_type`\">\n",
        "        **Choices**: `classified`, `kerneled`, `avg_kerneled`\n",
        "\n",
        "        **Default**: `classified`\n",
        "      </AccordionItem>\n",
        "    </Accordion>\n",
        "  </AccordionItem>\n",
        "\n",
        "  <AccordionItem title=\"`experimental`\">\n",
        "    Experimental options, when available.\n",
        "  </AccordionItem>\n",
        "</Accordion>\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "867d346a-3382-4e53-9d96-e3be06f5554b",
      "metadata": {},
      "source": [
        "<span id=\"options-compatibility-table\" />\n",
        "\n",
        "## Feature compatibility\n",
        "\n",
        "Certain runtime features cannot be used together in a single job. Click the appropriate tab for a list of features that are incompatible with the selected feature:\n",
        "\n",
        "<Tabs>\n",
        "  <TabItem value=\"Dynamic\" label=\"Dynamic circuits\">\n",
        "    Incompatible with:\n",
        "\n",
        "    * Gate-folding ZNE\n",
        "    * PEA\n",
        "    * PEC\n",
        "    * Dynamical decoupling\n",
        "\n",
        "    Other notes:\n",
        "\n",
        "    * Gate twirling can be applied to dynamic circuits, but only to gates not inside conditional blocks. Measurement twirling can only be applied to terminal measurements.\n",
        "    * Compatible with fractional gates when using `qiskit-ibm-runtime` v0.42.0 or later.\n",
        "  </TabItem>\n",
        "\n",
        "  <TabItem value=\"DD\" label=\"Dynamical decoupling\">\n",
        "    Incompatible with dynamic circuits.\n",
        "  </TabItem>\n",
        "\n",
        "  <TabItem value=\"Fractional\" label=\"Fractional gates\">\n",
        "    Incompatible with:\n",
        "\n",
        "    * Gate twirling\n",
        "    * PEA\n",
        "    * PEC\n",
        "\n",
        "    Compatible with dynamic circuits when using `qiskit-ibm-runtime` v0.42.0 or later.\n",
        "  </TabItem>\n",
        "\n",
        "  <TabItem value=\"ZNE\" label=\"Gate-folding ZNE\">\n",
        "    Incompatible with:\n",
        "\n",
        "    * Dynamic circuits\n",
        "    * PEA\n",
        "    * PEC\n",
        "\n",
        "    Might not work when using custom gates.\n",
        "  </TabItem>\n",
        "\n",
        "  <TabItem value=\"Twirling\" label=\"Gate twirling\">\n",
        "    Incompatible with fractional gates or with stretches.\n",
        "\n",
        "    Other notes:\n",
        "\n",
        "    * Gate twirling can be applied to dynamic circuits, but only to gates not inside conditional blocks. Measurement twirling can only be applied to terminal measurements.\n",
        "    * Does not work with non-Clifford entanglers.\n",
        "  </TabItem>\n",
        "\n",
        "  <TabItem value=\"PEA\" label=\"PEA\">\n",
        "    Incompatible with:\n",
        "\n",
        "    * Dynamic circuits\n",
        "    * Fractional gates\n",
        "    * Gate-folding ZNE\n",
        "    * PEC\n",
        "  </TabItem>\n",
        "\n",
        "  <TabItem value=\"PEC\" label=\"PEC\">\n",
        "    Incompatible with:\n",
        "\n",
        "    * Dynamic circuits\n",
        "    * Fractional gates\n",
        "    * Gate-folding ZNE\n",
        "    * PEA\n",
        "  </TabItem>\n",
        "</Tabs>\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "9b86001b-718a-4d72-b3b5-4a67eabf0a45",
      "metadata": {},
      "source": [
        "## Next steps\n",
        "\n",
        "<Admonition type=\"tip\" title=\"Recommendations\">\n",
        "  * Review the [ExecutionOptionsV2](/docs/api/qiskit-ibm-runtime/options-execution-options-v2) API documentation.\n",
        "  * Review the [EnvironmentOptions](/docs/api/qiskit-ibm-runtime/options-environment-options) API documentation.\n",
        "</Admonition>\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "id": "a1b8767d",
      "source": "© IBM Corp., 2017-2026"
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}