@@ -222,7 +222,9 @@ def get_backend(self) -> str:
222222 pass
223223
224224 @abstractmethod
225- def set_backend (self , backend : str , inplace : bool ) -> Optional [Self ]:
225+ def set_backend (
226+ self , backend : str , inplace : bool , * , switch_operation : Optional [str ] = None
227+ ) -> Optional [Self ]:
226228 """
227229 Set the backend of this object.
228230
@@ -231,9 +233,13 @@ def set_backend(self, backend: str, inplace: bool) -> Optional[Self]:
231233 backend : str
232234 The new backend.
233235
234- inplace : bool, default False
236+ inplace : bool, default: False
235237 Whether to update the object in place.
236238
239+ switch_operation : Optional[str], default: None
240+ The name of the operation that triggered the set_backend call.
241+ Internal argument used for displaying progress bar information.
242+
237243 Returns
238244 -------
239245 Optional[Self]
@@ -463,7 +469,11 @@ def cast_to_qc(arg: Any) -> Any:
463469 and arg .get_backend () != result_backend
464470 ):
465471 return arg
466- arg .set_backend (result_backend , inplace = True )
472+ arg .set_backend (
473+ result_backend ,
474+ inplace = True ,
475+ switch_operation = f"{ class_of_wrapped_fn } .{ function_name } " ,
476+ )
467477 return arg
468478
469479 return result_backend , cast_to_qc
@@ -538,7 +548,8 @@ def _maybe_switch_backend_post_op(
538548 class_of_wrapped_fn = class_of_wrapped_fn ,
539549 function_name = function_name ,
540550 arguments = arguments ,
541- )
551+ ),
552+ switch_operation = f"{ class_of_wrapped_fn } .{ function_name } " ,
542553 )
543554 return result
544555
@@ -923,7 +934,9 @@ def cast_to_qc(arg):
923934 and arg .get_backend () != result_backend
924935 ):
925936 return arg
926- cast = arg .set_backend (result_backend )
937+ cast = arg .set_backend (
938+ result_backend , switch_operation = f"{ class_of_wrapped_fn } .{ name } "
939+ )
927940 inplace_update_trackers .append (
928941 InplaceUpdateTracker (
929942 input_castable = arg ,
0 commit comments