---
title: group_wise (latest version)
description: API reference for qiskit_fermions.transpiler.passes.synthesis.group_wise in the latest version of qiskit-fermions
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-fermions/transpiler-passes-synthesis-group-wise
---

# group\_wise

`group_wise(mapper_fn)`

Wraps a mapper function so that it maps an operator one group at a time.

Rather than mapping the operator in one go, the wrapped function maps each of its [`groups`](/docs/api/qiskit-fermions/operators-operator-trait#groups "qiskit_fermions.operators.OperatorTrait.groups") separately and sums the results (see [Group operator terms: use the operator structure](/docs/addons/qiskit-fermions/guides/grouping#grouping-explanation)). The sum is the same operator either way, but its Pauli terms come out grouped: the terms of one group are adjacent instead of interleaved with everybody else’s.

That matters because a product formula synthesizes the terms in the order it receives them. Where the terms of a group act on disjoint qubits, having them adjacent lets them be scheduled in parallel, which can reduce the two-qubit depth substantially at an unchanged gate count.

Use it to wrap any `MapperFunction`:

```python
MapperFnEvolutionSynthesis(group_wise(jordan_wigner))
```

An operator without groups is mapped in one go, exactly as `mapper_fn` would on its own.

> **Note**
>
> Composing this with [`simplify()`](/docs/api/qiskit-fermions/transpiler-passes-synthesis-simplify "qiskit_fermions.transpiler.passes.synthesis.simplify") defeats the purpose, since simplifying re-sorts the terms into a canonical order and so discards the grouping this produces.

**Parameters**

**mapper\_fn** ([*Callable*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)*\[\[*[*OperatorTrait*](/docs/api/qiskit-fermions/operators-operator-trait "qiskit_fermions.operators.operator_trait.OperatorTrait")*,* [*int*](https://docs.python.org/3/builtins/functions.html#int)*],* [*SparseObservable*](/docs/api/qiskit/qiskit.quantum_info.SparseObservable)*]*) – the mapper function to wrap.

**Returns**

A mapper function that maps `mapper_fn` over the operator’s groups and sums the results.

**Return type**

[*Callable*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)\[\[[*OperatorTrait*](/docs/api/qiskit-fermions/operators-operator-trait "qiskit_fermions.operators.operator_trait.OperatorTrait"), [int](https://docs.python.org/3/builtins/functions.html#int)], [*SparseObservable*](/docs/api/qiskit/qiskit.quantum_info.SparseObservable)]
