# ============================================================================ #
# Copyright (c) 2022 - 2026 NVIDIA Corporation & Affiliates.                   #
# All rights reserved.                                                         #
#                                                                              #
# This source code and the accompanying materials are made available under     #
# the terms of the Apache License 2.0 which accompanies this distribution.     #
# ============================================================================ #

name: "quantum_machines"
description: "CUDA-Q target for Quantum Machines."

config:
  # Tell DefaultQuantumPlatform what QPU subtype to use
  platform-qpu: remote_rest
  # Add the rest-qpu library to the link list
  link-libs: ["-lcudaq-rest-qpu"]
  # Tell NVQ++ to generate glue code to set the target backend name
  gen-target-backend: true
  # Add preprocessor defines to compilation
  preprocessor-defines: ["-D CUDAQ_QUANTUM_DEVICE"]
  # Define the JIT lowering pipeline
  jit-high-level-pipeline: "func.func(add-measurements),expand-measurements"
  jit-mid-level-pipeline: "func.func(add-dealloc,expand-control-veqs,combine-quantum-alloc,canonicalize,cc-loop-normalize,cc-loop-unroll{unroll-only-wire-blocking-loops=true},canonicalize,cse,factor-quantum-alloc,dqe,cable-rough-in,canonicalize,memtoreg),canonicalize,cse,add-wireset,func.func(assign-wire-indices),qubit-mapping{device=bypass},decomposition{basis=h,s,t,r1,rx,ry,rz,x,y,z,z(1),x(1)}"
  jit-low-level-pipeline: "symbol-dce"
  # Tell the rest-qpu that the required output format is quake.
  codegen-emission: nop
  # Library mode is only for simulators, physical backends must turn this off
  library-mode: false

target-arguments:
  - key: url
    required: true
    type: string
    platform-arg: url
    help-string: "Specify Quantum Machine base server url."
  - key: executor
    required: false
    type: string
    platform-arg: executor
    help-string: "Specify the executor to run. Default is mock"
  - key: qubit_mapping_mode
    required: false
    platform-arg: qubit_mapping_mode
    type: string
    help-string: "'local_file': manually edited file located at <>, 'local_get_latest': use the local SABRE mapping algorithm, get the latest qpu config from the backend, 'backend': assign qubits in the backend, as part of the compilation process. Default is 'local_get_latest'."
  - key: api_key
    required: false
    type: string
    platform-arg: api_key
    help-string: "An API key to access the Qoperator server"
  - key: api_key_file
    required: false
    type: string
    platform-arg: api_key_file
    help-string: "Path to a file containing an API key to access the Qoperator server"
  - key: simulator_duration
    required: false
    type: string
    platform-arg: simulator_duration
    help-string: "The duration of simulation. Relevant only if the executor is set to 'simulator'."
  - key: extra-payload-provider
    required: false
    type: string
    platform-arg: extra_payload_provider
    help-string: "Specify the extra payload provider if any."
