diff --git a/python/dune/perftool/sumfact/geometry.py b/python/dune/perftool/sumfact/geometry.py
index a0f593a99e2111dbd733ef8ff7edb2a512383aeb..25225ba2c248b7aeae3e8004d615c2a1ef7b9f3c 100644
--- a/python/dune/perftool/sumfact/geometry.py
+++ b/python/dune/perftool/sumfact/geometry.py
@@ -26,6 +26,7 @@ from dune.perftool.pdelab.localoperator import (name_ansatz_gfs_constructor_para
                                                 lop_template_range_field,
                                                 )
 from dune.perftool.pdelab.restriction import restricted_name
+from dune.perftool.sumfact.accumulation import basis_sf_kernels
 from dune.perftool.sumfact.basis import construct_basis_matrix_sequence
 from dune.perftool.sumfact.quadrature import (additional_inames,
                                               default_quadrature_inames)
@@ -153,6 +154,12 @@ def pymbolic_spatial_coordinate_multilinear(do_predicates, visitor):
                        )
     vsf = attach_vectorization_info(sf)
 
+    # If this sum factorization kernel was not used in the dry run we
+    # just return 0
+    if vsf == 0:
+        visitor.indices = None
+        return 0
+
     # Add a sum factorization kernel that implements the evaluation of
     # the basis functions at quadrature points (stage 1)
     var, _ = realize_sum_factorization_kernel(vsf)
@@ -525,6 +532,12 @@ def _name_jacobian(i, j, restriction, visitor):
                        )
     vsf = attach_vectorization_info(sf)
 
+    # If this sum factorization kernel was not used in the dry run we
+    # just return 0
+    if vsf == 0:
+        visitor.indices = None
+        return 0
+
     # Add a sum factorization kernel that implements the evaluation of
     # the basis functions at quadrature points (stage 1)
     var, _ = realize_sum_factorization_kernel(vsf)
@@ -557,6 +570,13 @@ def define_jacobian_inverse(name, restriction, visitor):
                         )
             names_jacobian.append(name_jacobian)
 
+            # The sum factorization kernels from the geometry evaluation of the
+            # jacobians will never appear in the expression for the input of
+            # stage 3. This way the SumfactCollectMapper will never see them
+            # and they will be marked as inactive. Here we explicitly mark the
+            # as used.
+            basis_sf_kernels(expression.aggregate)
+
     # Calculate the inverse of the jacobian of the geometry mapping and the
     # determinant by calling a c++ function. Note: The result will be column
     # major -> fortran style.
diff --git a/test/sumfact/poisson/poisson_2d_unstructured.mini b/test/sumfact/poisson/poisson_2d_unstructured.mini
index bca80233015f166dbad795b48de6a3f87256f74f..b7de167f8b04294285f3e75ff7553ec872b56e38 100644
--- a/test/sumfact/poisson/poisson_2d_unstructured.mini
+++ b/test/sumfact/poisson/poisson_2d_unstructured.mini
@@ -9,7 +9,7 @@ deg_suffix = deg{formcompiler.ufl_variants.degree}
 {deg_suffix} == deg1 | exclude
 {diff_suffix} == numdiff | exclude
 {quadvec_suffix} == quadvec | exclude
-{gradvec_suffix} == gradvec | exclude
+# {gradvec_suffix} == gradvec | exclude
 
 lowerleft = 0.0 0.0
 upperright = 1.0 1.0
diff --git a/test/sumfact/poisson/poisson_3d_unstructured.mini b/test/sumfact/poisson/poisson_3d_unstructured.mini
index 5e9eae243b8d608ad1dbe01ea73fd76f03777f56..0d8b46901303b6a2889ef52ab82c389c9f4c2ead 100644
--- a/test/sumfact/poisson/poisson_3d_unstructured.mini
+++ b/test/sumfact/poisson/poisson_3d_unstructured.mini
@@ -9,7 +9,7 @@ deg_suffix = deg{formcompiler.ufl_variants.degree}
 {deg_suffix} == deg1 | exclude
 {diff_suffix} == numdiff | exclude
 {quadvec_suffix} == quadvec | exclude
-{gradvec_suffix} == gradvec | exclude
+# {gradvec_suffix} == gradvec | exclude
 
 lowerleft = 0.0 0.0 0.0
 upperright = 1.0 1.0 1.0
diff --git a/test/sumfact/poisson/poisson_dg_2d_unstructured.mini b/test/sumfact/poisson/poisson_dg_2d_unstructured.mini
index fec1c93d095eb90dcbfc1a40e11f01af58ecced0..a09c2dc7d093b16043cbac2b0768bfa57ea10261 100644
--- a/test/sumfact/poisson/poisson_dg_2d_unstructured.mini
+++ b/test/sumfact/poisson/poisson_dg_2d_unstructured.mini
@@ -9,7 +9,7 @@ deg_suffix = deg{formcompiler.ufl_variants.degree}
 {deg_suffix} == deg1 | exclude
 {diff_suffix} == numdiff | exclude
 {quadvec_suffix} == quadvec | exclude
-{gradvec_suffix} == gradvec | exclude
+# {gradvec_suffix} == gradvec | exclude
 
 lowerleft = 0.0 0.0
 upperright = 1.0 1.0
diff --git a/test/sumfact/poisson/poisson_dg_3d_unstructured.mini b/test/sumfact/poisson/poisson_dg_3d_unstructured.mini
index 271b1f54d533db26bf7a205ff0df772ae0254b0c..20aa0adfdeb1169b637ac70ae719b540861519c2 100644
--- a/test/sumfact/poisson/poisson_dg_3d_unstructured.mini
+++ b/test/sumfact/poisson/poisson_dg_3d_unstructured.mini
@@ -9,7 +9,7 @@ deg_suffix = deg{formcompiler.ufl_variants.degree}
 # {deg_suffix} == deg1 | exclude
 {diff_suffix} == numdiff | exclude
 {quadvec_suffix} == quadvec | exclude
-{gradvec_suffix} == gradvec | exclude
+# {gradvec_suffix} == gradvec | exclude
 
 lowerleft = 0.0 0.0 0.0
 upperright = 1.0 1.0 1.0