mindquantum.core.gates.ParameterGate#

class mindquantum.core.gates.ParameterGate(pr: ParameterResolver, name, n_qubits, *args, obj_qubits=None, ctrl_qubits=None, **kwargs)#

Gate that is parameterized.

Parameters:
  • pr (ParameterResolver) – the parameter for parameterized gate.

  • name (str) – the name of this parameterized gate.

  • n_qubits (int) – the qubit number of this parameterized gate.

  • args (list) – other arguments for quantum gate.

  • obj_qubits (Union[int, List[int]]) – the qubit that this gate act on. Default: None.

  • ctrl_qubits (Union[int, List[int]]) – the control qubit of this gate. Default: None.

  • kwargs (dict) – other arguments for quantum gate.

get_parameters() List[ParameterResolver]#

Return a list of parameters of parameterized gate.

no_grad()#

Mark all parameters as not requiring gradient calculations.

no_grad_part(*names)#

Set certain parameters that do not need grad. Inplace operation.

Parameters:

names (tuple[str]) – Parameters that not requires grad.

Returns:

BasicGate, with some part of parameters not need to update gradient.

requires_grad()#

Mark all parameters as requiring gradient calculations.

requires_grad_part(*names)#

Set certain parameters that need grad. Inplace operation.

Parameters:

names (tuple[str]) – Parameters that requires grad.

Returns:

BasicGate, with some part of parameters need to update gradient.