Supersymmetric partition functions and the three-dimensional A-twist

We study three-dimensional $\mathcal{N}=2$ supersymmetric gauge theories on $\mathcal{M}_{g,p}$, an oriented circle bundle of degree $p$ over a closed Riemann surface, $\Sigma_g$. We compute the $\mathcal{M}_{g,p}$ supersymmetric partition function and correlation functions of supersymmetric loop operators. This uncovers interesting relations between observables on manifolds of different topologies. In particular, the familiar supersymmetric partition function on the round $S^3$ can be understood as the expectation value of a so-called"fibering operator"on $S^2 \times S^1$ with a topological twist. More generally, we show that the 3d $\mathcal{N}=2$ supersymmetric partition functions (and supersymmetric Wilson loop correlation functions) on $\mathcal{M}_{g,p}$ are fully determined by the two-dimensional A-twisted topological field theory obtained by compactifying the 3d theory on a circle. We give two complementary derivations of the result. We also discuss applications to F-maximization and to three-dimensional supersymmetric dualities.


Introduction
Supersymmetric partition functions are useful to explore strongly-coupled theories with various amounts of supersymmetry-see e.g. [1,2,3,4,5,6]. This is particularly true in three dimensions, where there are fewer non-perturbative tools available than in even dimensions. For instance, in three-dimensional conformal field theories (CFT), the quantity where Z S 3 is the partition function on the round three-sphere, 1 is a fundamental quantity analogous to the central charge a in even dimensions [7,8,9]. In threedimensional theories with N = 2 supersymmetry, we can often compute (1.1) exactly by supersymmetric localization in a gauge-theory UV completion of the CFT [2,3,4].
In this work, we consider N = 2 gauge theories with an R-symmetry U (1) R . We study them on a three-manifold M g,p , a U (1) principal bundle over a Riemann surface: This family of geometries is indexed by two integers, g ∈ Z ≥0 , the genus of the Riemann surface Σ g , and p ∈ Z, the first Chern number of the principal bundle. It includes the round three-sphere and the product spaces Σ g × S 1 : We derive general formulas for the supersymmetric partition functions Z Mg,p and for expectation values of supersymmetric Wilson loops (and other loop operators) wrapped on an S 1 fiber. We heavily exploit the fact that the supersymmetric background on M g,p is a pull-back of the two-dimensional topological A-twist on Σ g [10,11]. Note that a very similar computation was performed in [12] for theories with N ≥ 3 supersymmetry. 2 An interesting upshot of our analysis is that the S 3 partition function can be viewed as the expectation value of a particular loop operator F wrapped on S 1 in the topologically-twisted theory on S 2 × S 1 -that is: (1.4) We call F the fibering operator. Its insertion along an S 1 fiber in M g,p corresponds to shifting the Chern number of the total space, replacing p by p + 1. The relation (1.4) is a generalization to N = 2 theories of a similar relation in Chern-Simons theory [13]. We will compute the fibering operator explicitly for N = 2 supersymmetric Yang-Mills-Chern-Simons-matter theories. Note that the relation (1.4) only holds for theories with integer-quantized R-charges, because the R-charges are integer-quantized on S 2 × S 1 . However, the S 3 result can be analytically continued to real R-charges in a canonical fashion [4,14].
In the rest of this introduction, we summarize our main results and discuss relations to previous works.

Seifert manifolds, three-dimensional A-twist and the Coulomb branch
For 3d N = 2 theories with an R-symmetry, the three-dimensional backgrounds that allow for some supersymmetry were classified in [11]. In order to preserve two supercharges of opposite R-charges, the three-manifold M 3 must admit a nowhere-vanishing Killing vector K µ . There are two distinct possibilities: • K µ is real. Then M 3 must be an (orientable) Seifert manifold-an S 1 bundle over a two-dimensional orbifoldΣ g .
• K µ is complex and generates two isometries. The only known example is the "untwisted" S 2 ×S 1 background of [15]. The corresponding partition function computes the so-called superconformal index [16,15].
In this work, we focus on the simplest supersymmetric Seifert-manifold backgrounds satisfying two additional conditions: 1) the orbits of K µ are the Seifert fibers; 2) the base space is a smooth closed Riemann surface Σ g (without orbifold points). Condition 1) could be waived in the case of a baseΣ g with genus g = 0 or 1. For g = 0, this corresponds to turning on a 'squashing' parameter-this is often denoted by b = 1 on lens space backgrounds-see e.g. [17,18,19]. It will be essential to our story that we do not allow any such squashing deformation. Condition 2) is not essential to our story but it is assumed for simplicity. We hope to report on the case of general Seifert manifolds in future work.
These two conditions imply that the supersymmetric background on M g,p is a pullback of the ordinary A-twist for two-dimensional N = (2, 2) theories on the Riemann surface Σ g . 3 In this language, localization on M g,p becomes a simple generalization of a recent localization computation on Σ g × S 1 [20,21,22].
As we will show, the supersymmetric partition functions on the A-twisted M g,p can be constructed in terms of the low-energy theory on the Coulomb branch of the flatspace theory on R 2 ×S 1 . We may view the three-dimensional theory on a circle of radius β as a two-dimensional N = (2, 2) supersymmetric theory with an infinite number of fields. This theory has a classical Coulomb branch spanned by the coordinates u = iβ(σ + ia 0 ), where σ is the real scalar in the 3d N = 2 vector multiplet and a 0 is the holonomy of the gauge field on S 1 (along the Cartan of the gauge group). The low-energy dynamics on the Coulomb branch is governed by the effective twisted superpotential W(u). We will discuss this function in depth, paying particular attention to the effect of the Chern-Simons terms. Schematically, it is given by: Li 2 (e 2πiQ i (u) ) . (1.5) The first term is the gauge CS term, the second term is a gravitational CS term, and the last term is the contribution of chiral fields Φ i with gauge charges Q i . Note that we assign a physical significance to the constant piece of W, which is identified with the gravitational CS level k g in three dimensions. The coupling of this effective theory to curved space is governed by the so-called effective dilaton, which takes the schematic form: Here k R and k RR are mixed U (1) R -gauge and U (1) R CS levels, respectively. The other terms are the contribution of the chiral multiplets (with R-charges r i ) and of the W-bosons. These two functions were derived in [23,24]; in addition, we included the contribution of the U (1) R and gravitational supersymmetric CS terms of [25]. From (1.5) and (1.6), we construct two well-defined Coulomb-branch operators. The handle-gluing operator is given by [24]: . (1.7) It corresponds to adding a handle to the base Σ g , shifting g to g + 1. The fibering operator introduced above is a simple function of the twisted superpotential: This is our main result. The formula (1.8) will be made more precise in the main text.
Consider a theory such that the "Bethe vacua" (the abelian Coulomb branch vacua, which are the gauge-inequivalent solutions to the Bethe equations [26] of the theory) are distinct. This always happens, for instance, in theories with enough flavor symmetries and with generic fugacities. In that case, the find the simple result: (1. 9) with S BE the set of Bethe vacua. For p = 0, this is the so-called twisted index on M g,0 ∼ = Σ g × S 1 [24,21,22]. In particular, the partition function on M 1,0 ∼ = T 3 computes the 3d Witten index studied in [27]. For p = 1, g = 0, on the other hand, we have the familiar S 3 partition function, and the relation (1.4) directly follows. More generally, we have: for the expectation value of a supersymmetric Wilson loop W wrapped on the S 1 fiber. We do not specify the insertion points on Σ g since the 2d theory is topological. We may view H and F as particular defect loop operators in the 3d N = 2 gauge theory, given by (1.7) and (1.8) on the Coulomb branch.

Localization formula
Another formula for the partition function Z Mg,p can be obtained by supersymmetric localization in the UV. We follow the abelianization method of Blau and Thompson [28,13] adapted to the supersymmetric context. From that point of view, the partition function for p = 0 can be written as: The sum is over flat torsion bundles for the Cartan subgroup of the gauge group G. The meromorphic integrand I g,p,m (u) contains classical contributions (the Chern-Simons terms and FI parameters) and one-loop contributions from all the matter fields. The contour integral is taken along a particular "Jeffrey-Kirwan (JK) contour" on a multiple cover of the Coulomb branch (with u ∈ C rk(G) ). Using gauge invariance, one may also write (1.11) as: where the sum is over all GNO-quantized fluxes of G, while the u variables are gaugefixed to 0 ≤ Re(u) < 1. The expression (1.12) is also valid at p = 0 [21,22], in agreement with the relations (1.10). By resuming the fluxes in (1.12), one can obtain the Bethe-vacua formula (1.9). Here we should note that we only rigorously derived the JK contour in (1.11) or (1.12) in the rank-one case. The higher-rank formula should be considered as a well-motivated conjecture. (It also follows in good part from earlier results relating supersymmetric localization [29,30,20,31] to JK residues [32,33].) For p = 0, the JK contour in (1.11) can be deformed to a simple "σ-contour" which lies along the imaginary u axis-that is, we have an integral over real σ: (1.13) in some appropriate region of parameter space. This is the familiar integral over real σ on S 3 [2]. For generic fugacities, the contour along σ generally has to be deformed, so that it always "separates" the singularities of the integrand in the same way. For pure N = 2 supersymmetric Chern-Simons theory, we may also rotate the contour to lie along the real axis in the u plane; such a theory is equivalent to ordinary Chern-Simons theory (up to a shift of the CS level), and (1.13) indeed reproduces the known integral formula over the holonomies a 0 in that case [13].

Parity anomalies, contact terms and Chern-Simons levels
As is well known, a three-dimensional Dirac fermion coupled to gauge fields suffers from the so-called parity anomaly; one cannot quantize the fermion while preserving both gauge invariance and three-dimensional parity [34,35,36]. Throughout this work, we choose a gauge-invariant regularization of the 3d N = 2 chiral multiplet. After integrating out the matter fields, the lack of parity invariance of the vector multiplet effective action (both for dynamical gauge fields and background gauge fields for global symmetries) is encoded in certain parity-odd contact terms in two-points functions of the corresponding conserved currents. We denote these contact terms by κ. Unlike ordinary contact terms, which are generated by local terms in the effective action and are therefore ambiguous, the contact terms κ correspond to Chern-Simons terms in the action, whose couplings k-the CS levels-are integer-quantized for compact gauge groups. The contact terms κ, therefore, are physically meaningful modulo integer shifts, κ → κ + k [25]. In this work, we are careful in distinguishing between κ and k. Unless otherwise specified, the CS levels k are always integer-quantized, while chiral multiplets contributes certain half-integers to κ. For instance, a single chiral multiplet coupled to a U (1) (background) gauge field with charge 1 will be quantized with a contact term κ = − 1 2 for that U (1). This is sometimes referred to as a "U (1) − 1 2 quantization". This distinction is not only pedantic. It is crucial in order to compute partition functions, including all dynamical and background Chern-Simons terms, in a consistent manner. This resolves some confusions about "sign ambiguities" that appeared in [20,21,22]-there are no sign ambiguities except for the ones encoded in CS terms for global symmetries. Relatedly, we will correct some signs that arise from classical CS actions for abelian gauge groups. (See in particular Appendix C.)

Dualities and on-shell superpotential
Many 3d N = 2 supersymmetric gauge theories are related by infrared dualities. On general grounds, the partition function (and other N = 2 supersymmetric observables) of two dual theories T and T D should agree on any supersymmetric background: (1.14) The Bethe-vacua formula (1.9) for Z Mg,p is particularly convenient to check these duality relations. The duality relations (1.14), and similar relations for loop operator insertions, can be rephrased as a statement about matching Bethe vacua in a one-toone fashion. The duality statement is that the handle-gluing and fibering operators of the dual theories agree "on-shell", that is, when evaluated on a dual pair of Bethe vacua, u =û and u D =û D . Equivalently, one can state the duality relations in terms of the effective twisted superpotential: The twisted superpotentials of the dual theories must agree on-shell: on any pair of dual vacua 4 (and similarly for the so-called on-shell effective dilaton, that we will define later). Interestingly, the relations (1.15) for gauge-theory dualities often follow from known dilogarithm identities [37]. We should emphasize that, even in the case of the S 3 partition functions, this provides a simpler derivation of the duality in future work, along with generic Seifert manifolds. Pure Chern-Simons theory on a restricted class of Seifert manifolds was considered in [48,49]. The formula (1.9) for the supersymmetric partition functions is reminiscent of the surgery prescription for pure CS theory [50]. Here we have a potentially richer quasitopological structure that depends holomorphically on various parameters. It would be very interesting to explore that point of view further.
Another construction of supersymmetric partition functions is in terms of holomorphic blocks [51]. They are partition functions on D 2 × S 1 , with D 2 a disk, which are in one-to-one correspondence with the Bethe vacua. Despite the similarities, that approach seems somewhat orthogonal to the one of the present paper, especially since the squashing parameter (or Ω-deformation on D 2 ) plays such an important role in [51], while we set it to zero throughout. Nonetheless, it would be very interesting to understand better the relation between the two approaches. Relatedly, our results should be of interest in the context of the 3d/3d correspondence [52,53,54]. In particular, one might ask what kind of topological field theory can be obtained by compactifying M5-branes on the supersymmetric background M g,p ; progress on understanding such systems has been made recently in [55,56].
Finally, let us mention that results completely analogous to the ones of this paper can be obtained for four-dimensional N = 1 theories on M g,p × S 1 [57].
This paper is organized as follows. In Section 2, we explore the two-dimensional A-model point of view and we derive the Bethe-vacua formula (1.9). In Section 3, we summarize important aspects of curved-space supersymmetry on M g,p . In Section 4, we discuss supersymmetric localization and we obtain the localization formula (1.11). In Section 5, we compute the S 3 partition function with the Bethe-vacua formula, and we present some non-trivial examples of F -maximization. In Section 6, we study the matching of supersymmetric partition function across gauge-theory dualities. Additional material is contained in various appendices.

The partition function as a sum over Bethe vacua
In this section, we start by reviewing some relevant results about two-dimensional N = (2, 2) gauge theories. We then consider three-dimensional N = 2 gauge theories on a circle as a two-dimensional N = (2, 2) theory and discuss in detail the low-energy theory on the Coulomb branch. We argue that the partition function on M g,p can be obtained as a sum over "Coulomb branch vacua" (Bethe vacua) by a simple modification of the formula for the Σ g × S 1 twisted indices discussed in [24,22,21]. We will give a microscopic derivation of this result in Section 4.

The Bethe-vacua formula in two dimensions
As a preliminary, consider a two-dimensional N = (2, 2) gauge theory with gauge group G and chiral multiplets Φ i in representations R i of g = Lie(G). From the vector multiplet V, one can build a g-valued twisted chiral multiplet Σ = −iD − D + V with components: Here we follow the A-twist conventions of [31]. In particular, the gauginos Λ 1 , Λ1 are (1, 0)-and (0, 1)-forms after the twist, respectively. 6 See also Appendix B. Let us denote by G F the flavor symmetry group (the non-R global symmetry group) of the theory. It is natural to couple the flavor currents to a background vector multiplet V F . The so-called twisted masses corresponds to constant expectations values σ F = m F for its complex scalar component. A particular chiral multiplet Φ i has twisted mass m i = ω i (m F ), where ω i is a weight of the flavor representation.
At a generic point on the classical Coulomb branch, the gauge group is broken to the Cartan subgroup H ⊂ G, and the massive chiral multiplets and W-bosons can be integrated out. The low-energy dynamics on the Coulomb branch is governed by the effective twisted superpotential [58,23,26]: 2) The first term in (2.2) is the contribution from the two-dimensional complexified Fayet-Iliopoulos (FI) parameters, with τ a projection on the free abelian subgroup I U (1) I ⊂ G. The second term in (2.2) is the contribution from the chiral multiplets Φ i , with ρ i the weights of the representation R i . The last term in (2.2) is the contribution from the W-bosons and their superpartners, with a sum over the positive roots of g. In the following, it will be useful to pick a basis e a of the Cartan H of G, and a basis e α F of the Cartan of G F , such that: We choose a basis {e a } that generates the coweight lattice Λ cw , so that ρ(e a ) ≡ ρ a ∈ Z for all weights ρ ∈ Λ w , and similarly for the flavor group. We view the low energy theory on the Coulomb branch as an A-twisted Landau-Ginzburg (LG) model [59] with twisted superpotential W for the twisted chiral multiplets Σ a . However, we see from (2.1) that the highest component of Σ a is an abelian field strength. We may treat f 11 as the fundamental variable if we also impose flux quantization by hand [26]: on any compact space. Relatedly, the twisted superpotential (2.2) suffers from branch cut ambiguities due to the logarithms: The quantization condition (2.4) ensures that (2.5) only shifts the effective action by an integer multiple of 2πi, so that the path integral remains well-defined. When looking for the vacua of the theory, we have to take the ambiguity (2.5) into account. This leads to the so-called Bethe equations [26]: Note the left-hand side is independent of the branch-cut ambiguity-in fact, it is a rational function of σ a and m i . If G is abelian, the solutions to (2.6) correspond directly to the vacua of the theory. In a non-abelian theory, we must divide by the action of the Weyl group of G, W G . In addition, solutions which are not acted on freely by the Weyl symmetry correspond to putative vacua with unbroken non-abelian gauge symmetry, wherein the derivation of (2.2) is unreliable. Following [60], we will exclude these solutions, which are believed not to correspond to physical vacua. (See also [61] for a related recent discussion.) Thus the set of vacua of the Coulomb branch theory is given by: 7 We refer to the solutionsσ = (σ a ) (modulo the Weyl symmetry) as the "Bethe vacua".

Coulomb branch correlation functions
The Coulomb branch operators are the twisted chiral ring operators given by gaugeinvariant polynomials P (σ) in the scalar field σ ⊂ V. On the classical Coulomb branch, they correspond to Weyl-invariant polynomials in the variables σ a . The effective twisted superpotential provides us with twisted chiral ring quantum relations.
Let us consider the N = (2, 2) theory on a closed orientable Riemann surface Σ g with the topological A-twist. The low energy topological field theory for the twisted chiral multiplets Σ a has an effective action: up to Q-exact terms. The first term in (2.8) depends on the effective twisted superpotential W, and it is explicitly topological (since f 11 and Λ1Λ 1 are naturally 2-forms). The second term involves R the Ricci scalar, and it is topological for the constant modes of σ a due to the Gauss-Bonnet theorem. It corresponds to the "improvement" Lagrangian of [62]. The holomorphic function Ω(σ) is the effective dilaton which governs the coupling of the theory to the A-twist background. In our two-dimensional N = (2, 2) gauge theory, it is given by [23,24]: up to an arbitrary constant. Here r i ∈ Z denote the R-charges of the chiral multiplets Φ i , which should be integers so that the theory can be defined on any Σ g . The correlation functions of Coulomb branch operators can be computed as a sum over the Bethe vacua, by a direct generalization of Vafa's formula for ordinary topological LG models (LG) [59]. One finds [24]: with the so-called handle-gluing operator. The first factor in (2.11) comes from the last term in (2.8) evaluated on the Coulomb branch, and the Hessian determinant of the superpotential arises because of the gaugino zero-modes on Σ g . One can also obtain (2.10) by supersymmetric localization in the UV [21]. There is an important caveat to this discussion: we have assumed that the Bethe vacua are isolated. This generally happens in theories with enough flavor symmetries and with generic twisted masses. Many important two-dimensional theories do not satisfy this condition, however-for instance, any GLSM that flows to a Calabi-Yau NLSM in the IR has a degenerate W; on the other hand, such theories can still be studied by localization methods, at least at genus g = 0 [63,31]. Isomorphic comments apply in three dimensions.

Flux operators
In the presence of a flavor symmetry group G F , it is natural to turn on supersymmetric background fluxes for the gauge field in V F , 12) in addition to the twisted masses σ α = m α . This adds a term: to the topological effective action (2.8). We are free to choose the background gauge field at will. In particular, we may consider the addition of a δ-function flux at a point for each U (1) α ⊂ G F . In this case, we have: Therefore, the insertion of a unit of U (1) α background flux on Σ g can be viewed as the insertion of a local operator Π α at x = x 0 . We will call such operators the flux operators.
Incidentally, the handle-gluing operator (2.11) can itself be thought of as a flux operator for the vector-like R-symmetry. On the A-twist background, the R-symmetry background flux is: 16) in order to preserve supersymmetry. Therefore, adding a handle has the same effect as adding one unit of U (1) R flux.

Three-dimensional N = 2 gauge theories on a circle
Let us now consider a three-dimensional N = 2 supersymmetric gauge theory compactified on a circle S 1 β of radius β. We view this theory as a two-dimensional N = (2, 2) theory with an infinite number of fields, corresponding to the Kaluza-Klein (KK) modes of each three-dimensional field.
At finite β, the complex scalar in any U (1) vector multiplet is cylinder-valued due to large gauge transformations. We introduce the notation: for the scalar fields in the Cartan of G×G F . Here σ and m are real scalars in 3d N = 2 vector multiplets, and a 0 denotes the holonomy along S 1 . We have the identifications u a ∼ u a + 1 and ν α ∼ ν α + 1 under large gauge transformations. The dimensionless quantity u in (2.17) is related to the two-dimensional complex scalar of Section 2.1 by u = βσ (2d) . It is often convenient to work with the single-valued fugacities: x a = e 2πiua , y α = e 2πiνα . (2.18) The low energy theory on the Coulomb branch (with coordinates u a ) is still governed by the topological effective action (2.8), but the twisted superpotential W(u) and the effective dilaton Ω(u) have new features intimately related to three-dimensional physics. In the following, it will be convenient to rescale W according to W 3d = βW 2d , so that both W and Ω are dimensionless quantities.

The three-dimensional twisted superpotential
The classical part of the twisted superpotential is related to Chern-Simons interactions in three dimensions. Consider any U (1) a vector multiplet. A Chern-Simons interaction with level k aa ∈ Z contributes to the twisted superpotential as: This can be derived by direct evaluation of the Chern-Simons functional on Σ g × S 1 , for instance, as we will explain in Section 4. The quadratic piece is essentially a mass term, corresponding to the well-known fact that the CS interaction lifts the three-dimensional Coulomb branch classically. The linear piece in (2.19) is related to the subtle signs alluded to in the introduction (see also Section 4 and Appendix C). Although this is not single-valued, it may only shift by terms of the form (2.5), which do not affect the path-integral. For future reference, we may rewrite (2.19) as a function of x a : with a branch cut along the positive real axis x a ∈ [0, ∞). (Here the log is on its principal branch, so that log(−x) = log x + πi.) Similarly, a mixed CS term between U (1) a and U (1) b contributes: (2.21) In addition, we claim that the supersymmetric gravitational Chern-Simons term [25] contributes a constant term: with k g ∈ Z. We will give several justifications for this claim below. In total, the contribution of all the gauge, flavor and gravitational CS terms to the twisted superpotential read: where all the levels are integer-quantized. For any simple group G γ ⊂ G, we have k a b = h a b k γ with h a b the Killing form of G γ (and a , b running over its Cartan subgroup). Consider next the one-loop contribution of the three-dimensional chiral multiplets. A chiral multiplet Φ with charge 1 under some U (1) symmetry contributes: with u the effective twisted mass of Φ and x = e 2πiu ; the U (1) symmetry could be dynamical, flavor or a combination of both. The first equality in (2.24) gives W Φ as a formal sum over KK modes. Upon regulating that expression, we obtain the dilogarithm of x. As we will explain in Section 4, we have implicitly chosen a regularization scheme that preserves gauge invariance at the expense of "parity". This is often stated as a "U (1) − 1 2 quantization" of the chiral multiplet, wherein we turn on a "half-integer CS level to cancel the parity anomaly". In this work, we never consider "half-integer" CS levels since they are not well-defined. The quantization of the chiral multiplet implicit in (2.24) is gauge-invariant and includes a contact term κ = − 1 2 for the U (1) current two-point function [25]. We also have a gravitational contact term κ g = −1. The only scheme ambiguity is in shifting κ by an integer CS level k (and κ g by an integer k g ), corresponding to which would correspond to a "U (1) − 1 2 +k quantization". An important consistency check of the twisted superpotential (2.24) is that it reproduces the correct decoupling limits at large value of the three-dimensional real mass σ. We have: For large positive σ, we obtain an empty theory and the twisted superpotential vanishes, while at large negative σ we are left with the background U (1) and gravitational CS levels k = −1 and k g = −2, as we can see by comparing (2.26) to (2.20) and (2.22). This gives a first consistency check of the detailed form of (2.23). We can easily generalize this consistency check to chiral multiplets coupled to arbitrary background gauge fields. We refer to Section 4.3.2 for additional discussions of our treatment of the chiral multiplets. As another consistency check, let us consider a pair of two chiral multiplets Φ 1 , Φ 2 of U (1) charges ±1. Since this allows for a superpotential mass term W = Φ 1 Φ 2 , the low energy theory should be empty. More precisely, it is empty if we consider two multiplets with opposite contact terms, which amount to adding CS level k = 1 and k g = 2, with our choice of quantization. We then have: Here we have used the dilogarithm identity: In Section 6, we will relate other dilograrithm identities to non-trivial dualities between different gauge theories. Finally, we should consider the effect of the W-bosons and their superpartners on the Coulomb branch, which contribute like chiral multiplets W α of gauge charges α and R-charge 2. For every pair of roots α, −α, we choose the "symmetric" quantization, with opposite contact terms for W α and W −α . Therefore, due to the identity (2.29), the W-bosons do not contribute at all to the effective twisted superpotential in three dimensions.
For general N = 2 Chern-Simons-Yang-Mills matter theories with gauge group G and chiral multiplets Φ i in representations R i of G, we have the twisted superpotential: where the classical contribution W CS is given by (2.23). Here we introduced the shorthand notation: where ω i is the flavor charge of Φ i (that is, a weight of the flavor group). Note that this twisted superpotential is only defined modulo the branch-cut ambiguities: W → W + n a u a + n α ν α + n 0 , n a , n α , n 0 ∈ Z . (2.32) However, all the physical observables that we will define are free from such ambiguities.

Flux operators and Bethe equations
As in two dimensions, we may define the flux operators: for the gauge and flavor symmetries, respectively. This is obviously invariant under (2.32). One can check that these operators are rational functions of the fugacities x a and y α . The three-dimensional flux operators are loop operators supported along the S 1 direction. They can be identified with the vortex loops discussed in [64,65]. The Bethe vacua are given by: In particular, they are rational equations for the single-valued variables x a .

The effective dilaton and the handle-gluing operator
If we couple the 3d N = 2 theory to a Σ g × S 1 background with the A-twist along Σ g , the effective dilaton Ω can be computed like in two dimensions [24]. As we will further discuss in Section 4, the classical Chern-Simons terms for the U (1) R background gauge field [25] contributes: Here k aR , k αR denote mixed R-gauge and R-flavor CS levels, and k RR is the U (1) R CS level. All these levels are integer-quantized. A chiral multiplet Φ of U (1) gauge charge 1 and R-charge r ∈ Z contributes: This corresponds to the same "U (1) − 1 2 quantization" discussed above, which includes the contact terms κ R = − 1 2 (r − 1) and κ RR = − 1 2 (r − 1) 2 for the gauge-R and R-R conserved-current two-point functions, respectively. The limits reproduce the correct shifts of the U (1) R CS terms upon integrating out a chiral multiplet. 8 The W-bosons contributes similarly like chiral multiplets of R-charge r = 2.
Due to our choice of "symmetric quantization" mentioned above, we also have a shift of k RR by 1 2 dim(g/h). In total, the effective dilaton of our 3d N = 2 supersymmetric gauge theory compactified on S 1 reads: with r i ∈ Z the R-charge of Φ i . The three-dimensional handle-gluing operator is given by: This directly leads to an expression for the Σ g × S 1 twisted index as a sum over Bethe vacua [24,22,20]. Note that we accounted for the effect of the CS level k RR in (2.38). This leads to a subtle sign (−1) k RR in (2.39), which was previously overlooked.

Induced charges of monopole operators
For future reference, let us consider the induced charges of the bare monopole operators T a± . These operators are associated with the limit σ a → ∓∞ on the classical Coulomb branch. We define their induced charges by: for their gauge, flavor and R-charges, respectively. One can easily check that these formula reproduce the standard one-loop formula for the induces charges; see e.g. [22]. By construction, the charges (2.40) are always integers.

The fibering operator in three dimensions
In addition to the three-dimensional flavor symmetry group G F , the effective twodimensional theory has a U (1) KK symmetry whose charge is the KK momentum. We may turn on a supersymmetric background vector multiplet V KK for U (1) KK . It originates from the three-dimensional N = 2 "new-minimal" supergravity multiplet-see e.g. [25,66]-which decomposes into a supergravity and a vector multiplet upon KK reduction to two dimensions. The twisted mass associated to V KK is m KK = 1 β . Indeed, the twisted masses for the KK tower of any 3d chiral multiplet takes the form σ 2d + n β , with n ∈ Z the KK momenta.
In any three-dimensional N = 2 theory, there must exist a distinguished flux operator for U (1) KK , which we denote by F. The insertion of F at a point on Σ g has the effect of introducing one unit of flux for U (1) KK , which is nothing but a shift of the first Chern class of the U (1) principal bundle over Σ g . In particular, the partition function of M g,p can be written in terms of p insertions of F on Σ g × S 1 : Since F introduces a non-trivial fibration of the circle over Σ g , we call it the fibering operator. Reinstating dimensions, we have: with the dimensionless W(u, ν) given by (2.30). This gives us the explicit form of the fibering operator for any 3d N = 2 gauge theory: We immediately see that (2.43) is insensitive to the branch-cut ambiguities (2.32) of the twisted superpotential. On the other hand, it transforms non-trivially under large gauge transformations u ∼ u + 1 or ν ∼ ν + 1 (for either the gauge or flavor group). We find: where Π a , Π α are the flux operators defined in (2.33).

The Chern-Simons and chiral multiplet fibering operator
For future reference, we note that the effect of the classical CS terms (2.23) on the fibering operator is: Similarly, a chiral multiplet of charge 1 under some U (1) contributes: This defines a meromorphic function of u on the complex plane, as the branch cuts of the dilogarithm and logarithm cancel each other. The function (2.46) has poles of order n at u = −n, n ∈ Z >0 and zeros of order n at u = n, n ∈ Z >0 . (This is proven e.g. by proposition 5.1 of [67].) It is closely related to the chiral multiplet one-loop determinant on S 3 , as we discuss further in Section 5.1. We note that the Chern-Simons and chiral fibering operators satisfy: where "k" denotes all Chern-Simons levels and contact terms in the theory, including the gravitational Chern-Simons level and the contact terms appearing in the quantization of the chiral multiplet. This operation thus has the same effect as taking p → −p.
As discussed further in Section 4.3.2, this reflects the fact that the M g,p and M g,−p backgrounds are related by a parity transformation.

Partition function and loop-operator correlation functions
Combining all the ingredients introduced so far, we can write the supersymmetric partition function on M g,p as: Here we introduced generic background fluxes n α for the flavor symmetry. As we discussed, we can also view these background fluxes as inserting flux operators Π α at points on Σ g . (A constant background flux is then viewed as a "smeared" flux operator.) Note that, in the presence of any abelian flavor symmetry U (1) F , we may shift the Rsymmetry by R → R + tF , where t is quantized to preserve the Dirac quantization of the R-charge. The net effect on the partition function is to shift the background flux n F → n F + (g − 1)t. This amounts to a shift: in the topological effective action (2.8). The partition function (2.48) is unaffected if we shift the R-symmetry current by any abelian gauge current. We are also interested in supersymmetric Wilson loop operators along the S 1 fiber. Any such Wilson loop correspond to a Weyl-invariant Laurent polynomial in the fugacities x a , For a Wilson loop in a representation R of G, we have: where ψ the fiber coordinate. We then have the expectation value: From this formula, we can read off the quantum algebra of Wilson loops, which is an S 1 uplift of the 2d N = (2, 2) twisted chiral ring [41,22]. The quantum relations are the relations satisfied by solutions to the Bethe equations (2.34). Let us briefly comment on the defect operators Π α . They enter in (2.52) in the same way as the Wilson loops, in agreement with their interpretation as operators supported along S 1 at a particular point on the base Σ g . These line operators can be identified with the vortex loop operators discussed in [64,65]. In principle, one can insert fractional flux at points on Σ g as long as the total flux is integer. The effect of such operators is to impose that matter fields charged under the flavor symmetry induce a non-trivial holonomy as they wind around the vortex loop. The Bethe equations imply relations satisfied by flux operators, just like for Wilson loops.

Gauging flavor symmetries and the on-shell twisted superpotential
Given a flavor symmetry, it is natural to gauge it, by promoting background vector multiplets to dynamical ones. This is an important operation for producing new theories from old ones, and we would like to perform it at the level of the partition function (2.48). This can be done most conveniently by working with the "on-shell" effective twisted superpotentials and effective dilatons, , (2.53) which are evaluated at solutionsû l to the Bethe equations. The functions (2.53) are particularly useful because we can use them to construct all of the ingredients in the partition function (2.48), even if one does not have access to a Lagrangian description of the theory. As described above, the supersymmetric vacua of the theory are determined by solutions to the Bethe equation (2.34). For generic-enough mass parameters ν α , this has a finite number of solutions, It is important to stress that the functionsû l a (ν) generically have branch points, where two or more solutions become equal, and branch cuts, where the solutions are permuted.
Thus it is more natural to think ofû l a (ν) as functions on an |S BE |-fold branched cover of the space of the ν α 's.
To any Bethe vacua, we may associate the "on-shell" effective twisted superpotential and effective dilaton (2.53), which we consider as a function on the |S BE |-fold branched cover of the parameter space. Nonetheless, the twisted superpotential W l is not yet well-defined due to branch cut ambiguities of W itself. To partially fix this ambiguity, we impose a "physical branch" condition: 9 ∂W ∂u a (u l a (ν), ν) = 0 , a = 1, ..., rk(G) . (2.55) This function will still have branch cut ambiguities associated to the background gauge multiplets, i.e., it is defined only up to shifts W l → W l + m α ν α + m 0 , m α , m 0 ∈ Z, but it will not have any branch cuts associated to shifts by the dynamical gauge field. This must be the case, as the dynamical gauge field should play no role in the low energy effective theory. Up to these shifts, the on-shell effective twisted superpotential is a physically-meaningful observable of the low-energy theory. In particular, it should match across dualities. Similar statements hold for the on-shell effective dilaton. If one has access to the on-shell effective twisted superpotentials of a theory, one may construct the on-shell flux and fibering operators, even if the theory lacks a known Lagrangian description. They are given by: We can easily see that this agrees with the gauge-theory definitions (2.33) and (2.43) upon using (2.55). Similarly, the on-shell handle-gluing operator is simply defined by: which obviously agrees with (2.39).
Using the on-shell twisted superpotential, it is straightforward to gauge a flavor symmetry. For instance, suppose we want to gauge a subgroup of the flavor group G F , with parameters {ν a } ⊂ {ν α }. We simply write the Bethe equation for ν a in terms of W l , namely: These equations should be solved for each l, and may have zero, one, or several solutions for each l. The vacua of the new gauge theory is the union of these solutions for all l, and the resulting on-shell twisted superpotential can be used to construct the M g,p partition function of the new theory. This procedure is described in more detail in Appendix E. We will see an example of this procedure in Section 6.

3.
A-twisted supersymmetric theories on M g,p In this section, we study curved-space rigid supersymmetry on M g,p . We introduce a particular three-dimensional supergravity background which realizes the "three-dimensional A-twist" in a precise sense. We also discuss curved-space supermultiplets and Lagrangians on this background, following the general results of [11,19].

Supersymmetric background on M g,p
Consider the three-manifold M g,p , a principal U (1) bundle of first Chern number p ∈ Z over a closed oriented Riemann surface Σ g of genus g: This is a simple example of a Seifert fibration. The topology of M g,p is fully specified by the two integer p ∈ Z and g ∈ Z ≥0 . In particular, if p = 0 we have the second cohomology: which includes the torsion subgroup Z p . A more detailed account of the topology and geometry of M g,p is provided in Appendix A. Let us consider the metric with ψ ∈ [0, 2π) the fiber coordinate, and z a complex coordinate on the base Σ g (in a given patch). The principal bundle connection C has field strength: We normalize the volume of the base to vol(Σ g ) = π, so that C has flux on Σ g . The metric (3.3) admits a Killing vector K whose orbits are the S 1 fibers. The dual one-form η determines a transversely holomorphic foliation (THF) of M g,p . We define: Note that K µ η µ = 1. We also define the tensor: which acts as a three-dimensional 'complex structure'. (We summarize important aspects of this geometric structure in Appendix A.) The complex coordinates ψ, z,z introduced above are coordinates adapted to the THF. In order to preserve half of the flat-space supersymmetry on M g,p , we turn on additional background fields in the three-dimensional 'new minimal' N = 2 supergravity multiplet [68,69,11]. This includes a scalar H and a U (1) R gauge field A (R) µ : with g the metric determinant. The complete supergravity background is spelled out in Appendix B. The expression for A (R) µ in (3.8) is only valid in the adapted coordinates ψ, z,z. Let us also define the adapted frame: Any one-form α can be decomposed into 'vertical', 'holomorphic' and 'anti-holomorphic' components: and similarly for any tensor. (In the following, we will mostly use the frame basis.) The holomorphic component α z in (3.10) transforms as a section of a "canonical line bundle" on M g,p , denoted by K, which is the pull-back of the canonical line bundle on the Riemann surface Σ g through the projection π in (3.1). Its first Chern class is given by: where Z p is the torsion subgroup in (3.2). It is very natural to introduce a modified Levi-Civita connection∇ µ that preserves the decomposition (3.10). Following [11], we define the modified spin connection: with ω µνρ the standard spin connection. In particular, we have: The price to pay is that the modified connection has torsion, with the torsion tensor T µ νρ = 2iH η µ Φ νρ proportional to H.
The supergravity background (3.3)-(3.8) preserves two (generalized) Killing spinors ζ and ζ, of R-charge 1 and −1, respectively, which satisfy: with A (R) µ given above. The holonomy of the modified connection∇ µ is contained in U (1), therefore it can be "twisted" away by a compensating U (1) R transformation. The Killing spinors are then essentially constant in the adapted frame: This is the three-dimensional version of the A-twist. Geometrically, it corresponds to choosing the U (1) R line bundle L (R) such that: This is a torsion line bundle with first Chern class: with the connection A (R) µ given by (3.8). It follows that the R-charges must be integers in general. More precisely, we have the Dirac quantization condition: with r the R-charge of any field. Note that the U (1) R bundle is topologically trivial if and only if g − 1 = 0 mod p. For instance, this is the case for the three-sphere The function s in (3.8) and (3.15) corresponds to a U (1) R gauge transformation. The Killing spinors (3.15) are globally well-defined if we choose s = 0. We may call this choice the "A-twist gauge". More generally, we can choose a gauge s = −nψ, where n is any integer; we will come back to this point below.
Note also that the Killing vector K and the covector η are built out of the Killing spinors (3.15) according to: with η µ = K µ in our background. All the background fields are invariant under the isometry generated by K. The compatibility condition (3.13) directly follows from (3.14) and (3.19).

Background vector multiplets
In addition to the background supergravity fields (3.3)-(3.8), we may also turn on background vector multiplets: for any flavor symmetry of the theory. To preserve the same supersymmetry as the geometric background, we take: a constant, which is the real mass associated to the flavor symmetry, and: and H given in (3.8). This implies that a (F ) µ is the connection of a holomorphic vector bundle over M g,p [19]. In particular, let us choose a holomorphic line bundle L (F ) associated to a U (1) F flavor symmetry. Its first Chern class has to lie in the torsion subgroup of the second cohomology (3.2): assuming p = 0. (See [22] for the p = 0 case.) Let us also define: is taken to be constant. The quantity (3.24) has a nice geometric interpretation as a complex modulus of the holomorphic line bundle L (F ) [19]. Under a large gauge transformation along the circle fiber, the parameters ν (F ) and n (F ) transform as: This must be an invariance of any physical observable.

U (1) R vector multiplet
From the supergravity multiplet, one can also construct an abelian vector multiplet for the R-symmetry [14]. In terms of the supersymmetric background (3.3)-(3.8), it is given by: where R is the Ricci scalar of g µν . In particular, one can check that the supersymmetry conditions (3.22) are satisfied: It follows that L (R) is a holomorphic line bundle, which is determined by its torsion flux (3.17) and by the modulus: Interestingly, ν (R) is fully determined by the supergravity background. A large U (1) R gauge transformation along the circle fiber corresponds to: Note that we can set ν (R) = 0, but it is sometimes useful to keep track of ν (R) as a formal parameter, together with the U (1) R gauge redundancy (3.29).

Parameter dependence and R-charge dependence
Supersymmetric observables on M g,p depend explicitly on the discrete parameters p and g as well as on the torsion fluxes n (F ) for flavor symmetries. They are also locally holomorphic functions of the complex parameters ν (F ) [19,14]. Note that a line bundle L (F ) generally has additional moduli, corresponding to flat connections along the one-cycles from Σ g . In our two-supercharge background, however, these additional moduli couple to Q-exact operators and supersymmetric observables are completely independent of them [19]. We can similarly understand the dependence of supersymmetric observables on the choice of R-symmetry [14]. In a theory with abelian flavor symmetries, the R-symmetry current can mix with flavor currents. Let us consider: for some parameter t, which shifts the R-charge by the U (1) F charge according to R → R + t F . (The flavor charge F is integer quantized by assumption.) This is equivalent to a shift of the U (1) F vector multiplet by the U (1) R vector multiplet: On our geometric background, the shift (3.30) is only allowed if it preserves the Dirac quantization condition (3.18). This implies that t ∈ Z in general. On the other hand, if L (R) is topologically trivial (that is, if g − 1 = 0 mod p), there is no restriction on the R-charge and we can take t ∈ R. Geometrically, the shift (3.31) is a tensor product of line bundles: with t integer or real, respectively. This corresponds to a shift of parameters: The partition function (or any supersymmetric observable) shifts accordingly. Note that the complex modulus ν (F ) stays invariant in the "A-twist gauge" ν (R) = 0. This is the gauge that we used implicitly in Section 2. When L (R) is topologically trivial, another particularly interesting gauge is: In such a case, the dependence of supersymmetric observables on the R-charge is entirely through the combination: with t ∈ R. Let us note that, in the case M 0,1 ∼ = S 3 , the supersmmetric background considered in [2,3,4] has ν (F ) = iσ (setting β = 1 for simplicity) and therefore the dependence on the R-charge is holomorphic in the parameter σ−it [4,14]. As we can see from (3.35), that property generalizes to any M g,p background admitting continuous R-charges.

Comparison with three-sphere and lens space backgrounds
It is interesting to compare our family of curved-space backgrounds to the ones previously studied in the literature. The genus zero case, g = 0, corresponds to the lens space M 0,p ∼ = S 3 /Z p . For instance, we can consider the metric: with the angular coordinates θ ∈ [0, π] and This is the total space of a degree p U (1) bundle over the round S 2 , written down on the "northern patch" θ ∈ [0, 2π). 10 If we choose β = 1 p , we obtain the round metric on the S 3 /Z p quotient, and the remaining supergravity fields (see Appendix B) are: For p = 1, we can set A (R) µ = 0 by a large gauge transformation. This background is related to the three-sphere background of [2,3,4] by a so-called "κ ambiguity" shift [11,19] which we briefly discuss in Appendix B. While one can preserve four supercharges on S 3 , our background only preserves two of them.
For p > 1, we have a non-trivial holonomy of the R-symmetry gauge field A (R) µ along the Hopf fiber, corresponding to the fact that c 1 (L (R) ) = −1 mod p. This is in contrast with the supersymmetric backgrounds considered in [45,46,47], which studied the same geometry (3.36) with a topologically trivial L (R) . The reason is that there exists two distinct supersymmetric backgrounds on the same topological space, corresponding to topologically distinct THFs. To explain this point, let us consider the lens space L(p, q) defined as the quotient of the three-sphere by the freely-acting Z p action: with p and q two non-zero integers. The Hopf fibration considered above is given by the map: to the two-sphere, where z is the complex coordinate on CP 1 on the northern patch (z = ∞), related to the angular coordinates above by z = tan θ 2 e iφ . The quotient (3.40) acts on the base as: leaving it invariant if and only if q = p − 1 (mod p). It follows that: as Seifert manifolds equipped with a particular THF. In contrast, the previous literature dealing with N = 2 theories on lens spaces [45,46,47] considered L(p, 1) instead. While L(p, 1) and L(p, p − 1) are homeomorphic, the THFs induced on them by the quotient (3.40) are distinct (if p > 2). 11 We should note that the methods of this paper do not apply directly to L(p, 1) or other lens spaces, because they would correspond to circle fibrations over the sphere with orbifold points. (These are examples of general Seifert fibrations, as mentioned in the introduction.) We also note that [12] studied gauge theories on the L(p, p − 1) supersymmetric background.

Supersymmetric multiplets and Lagrangians
Given the supersymmetric background above, the N = 2 supersymmetric multiplets and Lagrangians directly follow from the general results of [11]. In this subsection, we spell out those multiplets and Lagrangian in "A-twisted variables"-see Appendix B.1 and e.g. [31,22]-in order to emphasize the relation to the A-twist on Σ g . In the following, we write all the fields in the canonical frame basis. In that case, the holomorphic line bundle K on M g,p is really a U (1) bundle, 12 andK ∼ = K −1 . The corresponding U (1) charge is the "two-dimensional spin" of a field-in other words, a field of integer two-dimensional spin s 0 ∈ Z is a section of (K) s 0 , and similarly for s 0 half-integer for some choice of square root. The three-dimensional A-twist (3.16) corresponds to a "twist" of the two-dimensional spin by the R-symmetry according to: with r the R-charge. By definition, the A-twisted variables have vanishing R-charge and definite twisted spins. Note that 2s ∈ Z p since K is a torsion bundle. The real connection on K is given by: Let us also define the covariant derivative acting on tensors valued in (K) s , with s ∈ 1 2 Z and∇ µ the connection defined by (3.12).

Supersymmetry algebra
The two Killing spinors (3.15) correspond to two supersymmetry transformations: which satisfy the supersymmetry algebra: Here Z is the real central charge of the N = 2 superalgebra in flat space, and L K is the K-covariant Lie derivative along the Killing vector K. For a vector multiplet V in Wess-Zumino (WZ) gauge, the real scalar component σ also enters (3.48) as Z = Z 0 −σ, where Z 0 is the actual central charge and σ is valued in the appropriate gauge representation. We should note that the Lie derivative and the covariant derivative∇ µ coincide along K µ , which means that: Note that we traded the R-symmetry gauge field for A (K) µ in (3.48) since we are considering A-twisted fields, which are R-neutral by definition.

Vector multiplet
Let G and g = Lie(G) denote a compact Lie group and its Lie algebra, respectively. In WZ gauge, a g-valued vector multiplet V has components: (3.50) The A-twisted fermions Λ µ decompose as: where the vertical components Λ 0 Λ 0 are scalar fields and the horizontal components Λ 1 , Λ1 are sections of K andK, respectively. Let us define the field strength and denote by D µ the covariant and gauge-covariant derivative. The supersymmetry transformations of (3.50) are The dependence of (3.53) on the geometric background is mostly implicit, through the covariant derivatives written in the frame basis. To check the supersymmetry algebra, it is important to note that: where H appears due to the non-zero torsion of the covariant derivative.

Chiral multiplet
Consider a chiral multiplet Φ of (integer) R-charge r, transforming in a representation R of g. In A-twisted notation [31], we denote the components of Φ by Similarly, the charge-conjugate antichiral multiplet Φ of R-charge −r in the represen-tationR has components The fields are valued in the canonical line bundle to the appropriate power. We have: where V R ,VR are the gauge vector bundles. In particular, A, B have two-dimensional spin r 2 , while C, F have two-dimensional spin r−2 2 . The supersymmetry transformations of the chiral multiplet read: where D µ is appropriately gauge-covariant and σ and Λ1 act in the representation R.
We have: (3.45). For the antichiral multiplet, we similarly have: (3.60) Using (3.53), one can check that (3.58) and (3.60) realize the supersymmetry algebra: K is the gauge-covariant Lie derivative, and σ acts in the appropriate representation of the gauge group.

Supersymmetric Lagrangians
To conclude this section, let us write down the most important supersymmetric Lagrangians for our three-dimensional N = 2 gauge theories [11].
Vector multiplet. The curved-space super-Yang-Mills (SYM) Lagrangian reads: (3.62) Here and below, the trace over gauge indices is left implicit. The Lagrangian (3.62) is δ-exact, like any well-defined D-term. One can check that: Another important Lagrangian is the Chern-Simons (CS) term. For any gauge group G, we have with k ∈ Z the CS level. 13 In the presence of an abelian sector, we can also have mixed CS terms between U (1) I and U (1) J , with I = J: 1 . For each U (1) I factor, we may also turn on the Fayet-Iliopoulos parameter: where we normalized ξ I like in [22]. The FI term is a special case of a mixed CS term between the U (1) I vector multiplet V I and the background vector multiplet V T I (with real mass σ T I = ξ I and vanishing flux n T I = 0) for the associated topological symmetry U (1) T I , with level k IT I = 1. 13 In general, we have a distinct CS level for each simple factor and for each U (1) factor in G.
Chiral multiplet. The standard kinetic term for a chiral multiplet coupled to a vector multiplet (in WZ gauge) reads: This Lagrangian is δ-exact: Finally, we may write down superpotential interactions in terms of a superpotential W = W (Φ) of R-charge 2. Those interaction terms are Q-exact and do not play any crucial role in the following. The only way the superpotential appears in the localization computation is by the constraints it imposes on the flavor symmetry and R-charges.
U (1) R and gravitational Chern-Simons terms. Three additional supersymmetric Chern-Simons Lagrangians are available in curved space [25,11]. Let us consider them on our M g,p background. The first Lagrangian is simply a mixed CS term between a U (1) I vector multiplet and the U (1) R vector multiplet (3.26). It reads: in terms of the supergravity background fields defined above. The second Lagrangian is a supersymmetric CS term for the U (1) R vector multiplet: 14 The third CS Lagrangian is the N = 2 supersymmetric completion of the gravitational CS terms: (3.71) We need k g ∈ Z for the non-supersymmetric gravitational CS term to be well-defined by itself. On the other hand, the coefficient of the R-symmetry CS term A (R) dA (R) is: This "RR CS level" must be integer, k RR ∈ Z, whenever the U (1) R line bundle is topologically non-trivial. The level k zz itself does not need to be quantized because it is a CS level for the gauge field coupling to the central charge [25], which is never quantized in our family of backgrounds. The mixed CS term (3.69) can involve either a dynamical or background U (1) I vector multiplet. The two other terms (3.70) and (3.71) only depend on the geometric background. The CS levels k RR and k g correspond to contact terms in two point functions of the R-symmetry current and energy-momentum tensor, respectively [25].

Localization on the Coulomb branch
In this section, we sketch the Coulomb branch localization argument, which gives an independent derivation of the results of Section 2.

Vector multiplet localization
Let us first consider the supersymmetry equations for the vector multiplet V. It follows from (3.53) that the gaugino variations vanish if and only if: In addition, we consider the partial gauge-fixing condition: which is simply D 0 a 0 = 0. To understand the supersymmetry equations, it is useful to define the complexified gauge field: with field strength F µν , in terms of which the equations (4.1) read: These conditions imply that A µ is the connection of a holomorphic vector bundle [19], together with the gauge-fixing condition D 0 A 0 = 0. Let us define the quantities: for the constant modes of σ and a 0 . We also define: the holonomy of A µ along the S 1 fiber. We would like to localize the path integral onto the constant modes (4.5). The bosonic part of the SYM action (3.62) can be written as: Since the action (4.7) is the bosonic part of Q-exact action, we can localize the path integral by taking the limit e → 0. We choose a standard reality condition for the dynamical fields a µ and σ, which are taken to be real, while we remain agnostic about the reality condition for D. 15 Then the BPS configurations (4.1) simplify to: If, in addition, we take D to be purely imaginary, we have f 11 = 0 and we localize onto flat connections. This is slightly too strong, however, and in the following we will also allow for constant modes of f 11 that satisfy (4.8).
We may use the residual two-dimensional gauge freedom to diagonalize a 0 : breaking the gauge group G to the Cartan subgroup From D µ σ = 0 and the reality condition, σ is also localized onto the constant diagonal modes σ = diag(σ a ). The constant modes u a = iβ(σ a + ia 0,a ) will be identified with the Coulomb branch parameters of Section 2. In the diagonal gauge, we should sum over H-bundles over M g,p which are pull-backs of H-bundles on Σ g [72,13]. All such bundles are torsion bundles [13]. Here we assume that p = 0. (We briefly review the p = 0 case below.) The torsion flux m takes value in the finite group: which is a Z p reduction of the ordinary magnetic flux lattice [73,74]. Here Γ G ⊆ ih * is the weight lattice of electric charges of G. In a given topological sector m, the non-trivial connection can be chosen to be flat. We take: Note thatâ 0 is the coefficient of a well-defined one-form, therefore it cannot affect the topological properties of the gauge field. Some basic properties of flat connections are reviewed in Appendix A. Importantly, we have the holonomy: along the fiber. Note that we have: in a given topological sector. Under a U (1) a large gauge transformations, the parameters m a and u a transform as: In addition to these parameters, the U (1) a line bundles are also characterized by flat connections along Σ g , corresponding to elements of the cohomology group H 1 (M g,p , R) ∼ = R 2g . We can parametrize these flat connections by: The U (1) a holonomies α I , α I live in a compact domain. Importantly, the kinetic terms for the gaugino appearing in the localizing action (3.62) admit fermionic zero-modes, which satisfy: and similarly for the charge-conjugate fermions Λ 0 , Λ1. These zero-modes are directly related to the more familiar zero modes of the A-twisted Dirac operator on Σ g . We have the constant mode of Λ 0 , and g one-form zero-modes for Λ 1 : The cohomology classes [ω I z dz] ∈ H 1 (M g,p , R) ∼ = R 2g are the pull-back of the holomorphic one-forms on the Riemann surface Σ g . Note that the torsion of the covariant derivative D µ =∇ µ plays a crucial role here, since it is such that the equations (4.17) are independent of p. Therefore, the localization of the path integral can be performed in a manner identical to the p = 0 case studied in [22]. The vector multiplet localizes to an integral over the zero-mode supermultiplets: where the constant modeD is defined by We have turned on a non-BPS constant modeD as a regulator. In order to have a positive definite localizing action, the contour forD is chosen to beD = R − 2f 11 , which allows the constant modes for f 11 [20,21,22]. Then we deform theD-contour to be along the real axis. When we deform the contour, we pick up the residues of the pole in the region 0 <D < −2f 11 , but the residues of these poles are exponentially suppressed as we take the limit e → 0 [20]. Schematically, we obtain the partition function: where the sum is over all topological sectors, S 0 is the classical action evaluated on the supersymmetric locus, including the fermionic zero-modes, and Z 1-loop m is the one-loop determinant in a given topological sector. The integrand of (4.21) enjoys a residual supersymmetry, which follows from (3.53) restricted to the zero-modes. Following [22], we can argue that (4.21) reduces to a certain multi-dimensional contour integral on u a -space with a meromorphic integrand.
While the integrand of that contour integral can be straightforwardly computed, the precise form of the contour is more complicated to derive. We will give a complete derivation of the contour in the rank-one case in Appendix D, and we will present the higher-rank generalization as a conjecture.

Classical action contribution: CS terms
Let us first consider the classical action evaluated on the supersymmetric locus. For the vector multiplet, this corresponds to the parameters u, u and m. The only nonvanishing contributions come from the Chern-Simons terms (including the FI terms). On general ground, the result should be holomorphic in u. We provide a summary of some subtle properties of the CS functional in Appendix C.
Ordinary CS term. For simplicity, let us first consider a U (1) vector multiplet as described above, with parameters (u, m). The Chern-Simons term (3.64) can be decomposed as: The expression for S CS is formal since it involves a non-trivial gauge connection. We claim that the exponentiated CS functional for the flat connection of a torsion U (1) bundle, of first Chern class m ∈ Z p , is given by: See e.g. [75,46] in the case g = 0. We conjecture that (4.24) also holds on M g,p with g > 0. A proper computation should be done by using the four-dimensional definition of the CS functional, as explained in Appendix C. Note that (4.24) is invariant under the large gauge transformations m ∼ m + p for any m ∈ Z p , if and only if k ∈ Z, as it should be. The integrand of S CS in (4.23), on the other hand, is well-defined, and the action can be evaluated straightforwardly. We find: which is holomorphic in σ + iâ 0 , as expected. The total contribution of the supersymmetric CS action takes the simple form: when written in terms of u as defined in (4.14), with x defined in (4.6). For a more general gauge group G, we similarly obtain: after diagonalization.
Mixed CS term. Consider two U (1) vector multiplets with parameters (u I , m I ) and (u J , m J ). We claim that the mixed Chern-Simons term (3.65) has a contribution from the flat connections: similarly to (4.24). This is invariant under large gauge transformations for k IJ ∈ Z.
The remaining terms are well-defined and give: The full supersymmetric action (3.65) can be written as: with x I = e 2πiu I and x J = e 2πiu J . Note that this includes the (generalized) FI parameter for a U (1) I gauge group, which is given by mixed CS term between U (1) I and the topological symmetry U (1) T I , at level k IT I = 1, with fugacity: and background flux n T I .
U (1) R and gravitational CS terms. By direct computation, one can check that the mixed U (1) R -U (1) I CS term (3.69) evaluates to: This simply corresponds to (4.30) with the U (1) R vector multiplet parameters plugged in. We wrote down (4.32) in the "A-twist gauge" ν (R) = 0. (More generally, we have ν (R) ∈ Z and therefore x R = e 2πiν (R) = 1.) In the A-twist gauge, the U (1) R and gravitational CS terms (3.70) and (3.71) give a subtle contribution: The k RR term can be inferred by replacing u and m by ν (R) = 1 and m R = g−1 in (4.26). The k g term is a further conjecture. We do not provide a complete proof of (4.33), but it passes a number of consistency checks. For instance, these CS classical terms can be generated from the chiral multiplet effective action on M g,p in the appropriate decoupling limits.
In the language of Section 2, all these supersymmetric Chern-Simons terms correspond to the classical twisted superpotential (2.23) and effective dilaton (2.35), that is: Note again that this only makes sense for k RI , k RR integer-quantized. Whenever U (1) R can be taken non-compact, the general result for a theory with continuous R-charges can be obtained by starting with integer-quantized R-charges and deforming the fugacities in the way explained in Section 3.1.3.

One-loop determinants
Next, we discuss the one-loop determinant contributions to the localized path integral.

Chiral multiplet contribution
Consider a chiral multiplet Φ coupled to a U (1) I vector multiplet V with charge Q = 1, and coupled to our geometric background with R-charge r ∈ Z. We contribution of Φ in the supersymmetric background (u, m) for V can be computed with the Q-exact action (3.67). The Gaussian integral only receives non-trivial contributions from the zero-modes of the operator D1, with D µ defined in (3.59). By a standard argument, 16 we find: All other modes cancel out by supersymmetry. Note that the modified covariant derivative D µ is the pull-back of the ordinary covariant derivative on Σ g . We can then expand any 3d field along the S 1 fiber: with the modes ϕ n living on Σ g . In particular, the zero-modes A n that contribute to the denominator in (4.36), satisfy: In other words, the modes A n correspond to holomorphic sections of the line bundle: on Σ g , where O(n) denotes a line bundle of first Chern number n. These bundles pull-back to torsion bundles on M g,p [13]. Similar considerations hold for the fermionic zero-modes C that satisfy D 1 C = 0, corresponding to the numerator of (4.36). In this way, we find that (4.36) is given by the formal expression: with u defined in (4.14). This infinite product has to be regulated carefully, but it is clear that it possesses the expected properties. Firstly, it is formally invariant under the large gauge transformation (u, m) ∼ (u + 1, m + p). Secondly, it takes the form: is the result of [20] for a chiral multiplet on Σ g × S 1 , in the presence of m units of flux on Σ g . The function: gives the contribution of a chiral multiplet to the fibering operator introduced in Section 2.4. A similar one-loop determinant was first obtained in [12].

Regulated chiral multiplet one-loop determinant
The formal product (4.40) is invariant under large gauge transformations. It is also invariant under a "parity" transformation which acts on (4.40) as: leaving all other parameters fixed. This reflects the fact that the kinetic Lagrangian (3.67) is both gauge invariant and parity invariant. 17 The quantum theory, however, has a "parity anomaly" [34,35,36]. This is the statement that we cannot quantize a three-dimensional Dirac fermion coupled to a background gauge field (and a background metric) while preserving both gauge invariance (and diffeomorphism invariance) and parity. In the present case, the parity anomaly shows up upon regulating the formal product (4.40). We naturally choose to preserve gauge invariance. The parity anomaly is sometimes loosely stated as the fact that one should "add a CS term with level 1 2 " to compensate for the lack of gauge invariance of the fermion effective action. This is misleading since there is no such thing as a Chern-Simons action with half-integer level. Instead, the gauge-invariant effective action necessarily breaks parity. (See [76] for a recent discussion of this point.) In particular, a Dirac fermion coupled to U (1) gauge fields contributes half-integer contact terms κ to twopoint functions of U (1) currents (and similarly for the coupling to the metric). These contact terms can be shifted by integers (by adding CS terms at levels k for the gauge fields in the effective action) but the non-integer parts of κ are physical [25] and violate parity.
In order to identify the correct gauge-invariant regularization for the chiral multiplet one-loop determinant, we recall that integrating out a chiral multiplet Φ by scaling the real mass σ → ±∞ leads to a shift of the relevant contact terms by: (4.44) Here we reintroduced the U (1) I gauge charge Q, which we had set to 1 before. We would like to identify a "U (1) − 1 2 regularization", corresponding to contact terms: for a free chiral multiplet coupled to background fields. This is such that: since the IR theory with large positive real mass Qσ is then an empty theory with vanishing background Chern-Simons levels. Let us first consider the p = 0 contribution to (4.40) (with Q = 1): The infinite product can be regularized in various ways, but there is a unique gaugeinvariant answer that satisfy (4.46). It is given by: with x = e 2πiu . Similarly, the "fibering operator" contribution (4.42) gives: (4.49) in agreement with (2.46). As mentioned before, F Φ (u) is a meromorphic function of u with poles at u = −n, n ∈ Z >0 . It is also the contribution of a chiral multiplet of R-charge r = 1 to the S 3 partition function [7,44], as we will discuss in Section 5. The full one-loop determinant on M g,p is given by: Note that F Φ (u) satisfies the difference equation: which implies that (4.50) is invariant under the large gauge transformations (4.15). We may also view F Φ as a function of x: in which case (4.51) corresponds to a monodromy around x = 0. 18 In the limit of large negative real mass, one can show that: Comparing to the classical Chern-Simons contributions discussed in Section 4.2, we see that this limit reproduces the classical supersymmetric Chern-Simons action with integer levels: provided that r ∈ Z. This agrees with the expected shift (4.44) of the bare contact terms (4.45).

Vector multiplet contribution
The W-boson and their superpartners also give a non-trivial contribution on the Coulomb branch. They contribute like chiral multiplets of gauge charges α, with α the roots of g, and R-charge 2 [31,20]. The W-bosons come in pairs of charges α and −α. As was already mentioned in Section 2, we choose a symmetric quantization, such that there is no shift of any contact term. This implies that the W-bosons do not contribute to the effective twisted superpotential, while they do contribute to the effective dilaton. We have: where g + denotes the positive roots. The one-loop determinant (4.55) is independent of p and of the topological sector m. It naturally agrees with previous results for S 3 [2] and Σ g × S 1 [20].

A comment on the
The case p = 0 was studied in [20,21,22]. Let us emphasize the presence of some subtle signs that were previously overlooked. When p = 0, the sum over topological sectors is over all GNO-quantized fluxes on Σ g : The Coulomb branch parameters u a are cylinder-valued, u a ∼ u a + 1, corresponding to complexified flat connections along S 1 . The classical and one-loop contributions can be obtained by setting p = 0 in the results above. In particular, a U (1) CS term at level k contributes: (4.57) in the presence of a flux m ∈ Z. We see that, even in the absence of flat connection along S 1 (that is, if u = 0), we have a contribution (−1) km . This is because of the choice of spin structure dictated by supersymmetry, with periodic boundary conditions for fermions around S 1 . This explicit dependence on the spin structure for k an odd integer [77] was discussed recently in [78,79], and we review some relevant material in Appendix C. The U (1) R CS term contributes a sign (−1) (g−1)k RR for the same reason. Note that mixed CS terms do not introduce any additional signs, because they are independent of the spin structure.

The contour-integral formula
Combining the classical and one-loop contribution, and integrating over the fermionic zero modes, the path integral (4.21) can be written as a particular contour integral on {u a } ∼ = h C . (This is proven in Appendix D in the rank-one case, and it is a wellmotivated conjecture in general.) On M g,p with background fluxes n α for the flavor symmetry, we have: with r = rk(G) and the integrand: The term Z classical m,g,p (u) is the classical contribution due to the Chern-Simons terms discussed in Section 4.2. The one-loop determinants contribute as: with F Φ (x) and Π Φ (x) defined as in (4.52) and (4.48), respectively. The last term in (4.59) originates from the integration over the gaugino zero-modes Λ 1 , Λ1. The integrand (4.59) may be conveniently written in terms of the effective twisted superpotential and effective dilaton of Section 2.2: with Ω, F and Π a , Π α the effective dilaton (2.38), the fibering operator (2.43), and the flux operators (2.33), respectively. (We suppressed the dependence on the flavor parameters ν α to avoid clutter.) Note that the integrand (4.59) is invariant under the large gauge transformations (u a , m a ) ∼ (u a + 1, m a + p). In particular, when p = 0, the integrand is periodic, u a ∼ u a + 1, in each topological sector, and the integration contour lies on the classical Coulomb branch M [22]. For p = 0, it is useful to decompose the (as yet unspecified) real codimension-r integration contour C ⊂ C r as: where C n is a contour that lies in the vertical strip n ≤ Re(u) < n + 1, as indicated. We then have the formal identities: where we used the property (2.44) in the second equality, and we relabelled the fluxes m − pn as m in the last one. Therefore, the partition function (4.58) can be written as a sum over the whole flux lattice of G, like in the p = 0 case: This formula realizes the relation (1.10) at a formal level, since (4.64) looks like an explicit insertion of the operator F p in the Coulomb-branch localization formula on Σ g × S 1 . This is only formal, however, because the localization argument must be adapted to accommodate for the insertion of the fibering operator. This generally results in a different contour prescription for p = 0, consistent with the fact that the integrand J (u) is no longer invariant under u ∼ u + 1 in this case.

Singularities of the integrand
Before discussing the integration contour, let us summarize the structure of the integrand singularities. We have four distinct types of singularities: Matter field singularities. First of all, we have potential singularities along the hyperplanes: as is evident e.g. from (4.40). Note that N ρ i ,n is the order of the pole. For N ρ i ,n < 0, on the other hand, we have a zero of order |N ρ i ,n | along the hyperplane.
Large Im(u) region (monopole singularities). The second type of singularities originate from the large imaginary u region. We define the "hyperplanes": That is x a = ∞ and x a = 0, respectively, in the x a variables. The integrand has potential singularities of the form: (4.68) in the limit σ a → ∓∞, where Q a± , Q F a± and r a± are the monopole charges (2.40). We refer loosely to the singularity at Im(u) → ∓∞ as a "pole at infinity". More precisely, we have an actual pole at x = ∞ or x = 0, respectively, when p = 0. For p = 0, it is more natural to use the variable u. The regions in the u-plane where (4.68) diverges generally contribute non-trivially to the partition function.
Large Re(u) regions. When p = 0, the integrand may diverge at Re(u) → ±∞. Using the property F(u+N ) = F(u)Π(u) −N with N a large integer, we can understand that divergence as follows. Suppose we have a part of the integration contour that probes the large Re(u) region. For p > 0, the integrand diverges as Re(u) → −∞ along portions of that contour such that |Π(u)| > 1; similarly, it diverges as Re(u) → ∞ when |Π(u)| < 1.
W-boson singularities. In addition, at higher genus g > 1 and for a non-abelian gauge group, we also have potential singularities at: for any simple root α ∈ g. These hyperplanes correspond to the walls of the Weyl chambers, where part of the non-abelian symmetry is restored. Following previous works, our prescription will be to exclude the contribution from any singularity that includes H α,n [13,21,22].
Example: U (1) −1/2 with one chiral To illustrate some of these general features, we will consider a simple example, the U (1) theory with a charge one chiral and an effective CS level κ = − 1 2 . For simplicity let us consider the case g = 0, p = 1, i.e., M g,p = S 3 , and an R-charge such that Ω = 0. Then the partition function is given by: where: (4.71) Here we have included a mass parameter ν for the chiral multiplet, as well as an FI parameter τ . 19 19 We may eliminate ν by a shift of u, but it will be instructive to include it. From (4.66), the integrand has a pole of order n at u = −ν − n, n = 1, 2, · · · . For large |u| the integrand behaves as: The behavior of the integrand is shown in Figure 1. There are poles due to the charged chiral multiplet, as well as the charged monopole T + , at Im(u) → −∞, however the monopole T − is uncharged. We will revisit this example below as we discuss more properties of the M g,p partition function.

Jeffrey-Kirwan contour: the rank-one case
In the rank-one case (r = 1), we can derive a precise contour on the u-plane, as we explain in Appendix D. The supersymmetric partition is given by: where H(u) ≡ ∂ 2 u W(u), and Π(u), Π α (u) are the gauge and flavor flux operators, respectively. The contour C η , with η a non-zero real number, is defined as follows. We excise an -neighborhood of all singularities in the integrand, as well as a box of size R, which we take very large, leaving a compact region,M in which the integrand is regular. We then define: (4.74) Figure 2: The p = 0 JK contour, for η > 0 and η < 0, respectively. For η > 0 the contour surrounds the poles due to positively charged chirals in an anti-clockwise manner, and for η < 0 it surrounds the poles due to negatively charged chirals in a clockwise manner. Only the part of the contour at infinity that satisfies the condition sign (Im(∂ u W)) = − sign(η) should be included in the respective contours.
For η > 0, this includes those portions of ∂M encircling the poles due to positivelycharged chiral multiplets, as well as the positively-charged monopole singularities at Im(u) → ±∞. Similarly, the contour for η < 0 picks the contributions from the negatively charged singularities. The orientation of C η is positive or negative for η > 0 or η < 0, respectively. This is such that the residues from the positively charged chiral multiplets are counted with a plus sign (respectively, the residues from the negatively charged fields are counted with a minus sign). A corresponding orientation is assigned to the boundary components, as shown in Figure 2. Since this contour integral is a slight modification of the Jeffrey-Kirwan residue prescription at rank one, we will call C η the "JK contour". For some purposes, it will be useful to rewrite (4.73) as: by using the identities (4.63). LetM 0 be the restriction ofM to the vertical strip 0 ≤ Re(u) ≤ 1 on the u-plane. The contour C η 0 is defined as: with the orientation depending on sign(η) as before. Note that this contour generally includes vertical lines along Re(u) = 0 and Re(u) = 1, as we will see in explicit examples below. For p = 0, we have the same formula (4.75) with a periodic integrand, and the Figure 3: JK contour C η −1 shown for η > 0 in blue, and C η 0 for η < 0 in red. Here we assume Im(τ ) < 0, which implies that the contribution at Im(u) → ∞ is included in the η > 0 contour.
contributions of those vertical lines cancel out. For p = 0, on the other hand, they are an important part of the JK contour C η 0 in the quasi-periodic representation (4.75). More generally, we may defineM n to be the restriction ofM to the vertical strip n ≤ Re(u) ≤ n + 1, and define the contour C η n analogously. We emphasize that, for each m, the integral in (4.75) is independent of the choice of η. 20 Due to the non-periodicity of the integrand under u → u + 1 for p = 0, this property would not hold if we did not inlcude the segments of the vertical lines along Re(u) = 0 and 1.

Example
In Figure 3, we illustrate the JK contour for the U (1) −1/2 theory with a charge one chiral multiplet. Note that: Then one finds: in the respective limits. Thus the η > 0 contour surrounds the pole at u = −ν − n, while the η < 0 contour surrounds the "pole at infinity" due to the charged monopole T + . In addition, along the vertical boundaries ofM m at Re(u) ∈ Z, and along the horizontal boundary at Im(u) → ∞, a portion of the contour is selected depending on the sign of Im(∂ u W); the figure illustrates the behavior for Im(τ ) < 0.

The higher-rank case
In the higher rank case, we conjecture the existence of a similar formula: Here η is a non-zero covector in h * , and C η is an appropriate middle-dimensional "JK contour" in h C ∼ = C r . Equivalently, by the same argument as in (4.75), we may rewrite this as: where C η 0 is contained in the region 0 ≤ Re(u a ) ≤ 1. We will comment on the precise form of these contours below.

Rank-one theories
Let us explore some of the properties of the partition function formula of the previous section in the case of theories with a rank-one gauge group (that is, g = u(1) or su (2)). We will comment on generalization to the higher-rank case in the next subsection.

The σ-contour
For p = 0, it is possible to express the M g,p partition function as a non-compact integral: Here, C σ is a non-compact contour connecting Im(u) → −∞ with Im(u) → ∞. In other words, it is roughly an integral over imaginary u, or equivalently, over real σ. This directly relates the contour prescription presented here to the one used in earlier work on the round S 3 [2,3,4], where such an integral over real σ was obtained instead.
Here we derive the precise form of the non-compact contour, C σ , by relating it to the JK contour prescription. Note that, unlike the more naive contour along the imaginary u axis, the contour C σ always leads to a converging integral.

A simplification in the sum over fluxes
To proceed, we will need a general fact about the sum over fluxes, which holds for all p. As we can see from (4.65) and (4.66), a chiral multiplet of gauge charge Q and R-charge r contributes poles to the integrand if and only if: where ν, n are the flavor parameters. We also have "monopole contributions" that arise in the limit Im(u) → ∓∞, where the integrand takes the form: Here k ∓ and k R∓ are the effective CS levels in this limit, which depend on the charges of the chiral multiplets, while τ ∓ and n ∓ are the effective parameters for the topological symmetry U (1) T , which depend on the flavor symmetry parameters. Recall from (2.40) that we have the monopole charges Q ± = ±k ∓ and r ± = ±k R∓ . We then find that the monopole singularity at Im(u) → ∓∞ contribute a "pole at infinity" only when: We see that the integrand only has singularities, associated to either the chiral multiplets or the monopole operators, provided that: where the index α runs over both the matter and monopole contributions, and δ α is some constant that depends on the flavor symmetry parameters and R-charges. Note that if Q α = 0 for a monopole operator, 21 this bound becomes independent of u and m, and depends only on the flavor symmetry parameters through δ α . We will return to this point below.
In general, the allowed choices for the R-charge and the flavor symmetry parameters may be restricted by superpotential terms and by the Weyl symmetry. Suppose for the moment that we lift any such restriction, and allow independent mass parameters for all chiral multiplets, and complexified FI parameters in the Cartan of the gauge group. Then it is clear from (4.82) that we may choose δ α arbitrarily for each chiral multiplet. Similarly, by shifting the bare U (1) T parameters, we may take δ ± , the bounds for the monopole contributions, to be arbitrary. Although the answer we obtain in this way may only be defined in a non-physical region of parameter space, it is typically possible to analytically continue it back to the physical region at the end of the computation.
Returning to the expression (4.75) for the M g,p partition function of a rank-one gauge theory, we find it useful to decompose the contour C η 0 into two pieces: where C η, bulk 0 is the part of the contour surrounding the poles in the integrand due to the charged chiral multiplets and monopole operators. The remainder, C η, boundary 0 , can be further decomposed as: Here the first two terms consist of the parts of the vertical lines Re(u) = 0, 1 contained in C η 0 , while the third and fourth terms are only included if the corresponding monopole charge vanish, Q + = 0 and/or Q − = 0 (otherwise these pieces are included as part of C η, bulk 0 ). It follows from (4.85) that, for sufficiently large negative m, there are no poles in the integrand which are due to the positively-charged singularities. Therefore, if we choose η > 0 to compute the integral at large negative m, the contour C η>0, bulk 0 gives a vanishing contribution, and the only contribution comes from the boundary contour. Similarly, for sufficiently large positive m, we may take η < 0 and there will be no contribution from C η<0, bulk 0 . For p = 0, since the integrand is periodic under u → u + 1, the boundary contributions along Re(u) = 0 and Re(u) = 1 cancel each other. If, in addition, the monopole charges Q ± are non-zero, then the sum over m truncates to a finite sum. More generally, if one or both of Q ± vanishes, this truncation only occurs provided the flavor symmetry parameters are picked so that the corresponding δ α satisfies (4.85). Otherwise, there will be in general be a contribution from infinitely many flux sectors. A similar truncation property in the sum over topological sectors was observed in [80] in the context of the S 2 × T 2 partition function (where there are no subtleties related to monopole contributions).
For p = 0, on the other hand, the pieces along the vertical boundaries at Re(u) = 0 and 1 no longer cancel. Their contributions actually add up and give rise to the σcontour.

Deriving the σ-contour
To proceed, let us first assume, for simplicity, that we have δ α − Q α p < 0 for all α. In this case, there is no contribution from positively-charged singularities for any m ≥ 0, and no contributions from negatively-charged singularities for any m ≤ 0. Moreover, with this assumption, the bound (4.85) is also violated for any zero-charge monopole operator, and so there is no contribution from the third and fourth terms in (4.87).
Then, if we choose η > 0 for m ≤ 0 and η < 0 for m > 0, there are no bulk contributions from C η 0 for any m, and we only need to deal with the boundary contributions. We set p > 0 for definiteness. Let us rewrite the expression (4.75) as: where we wrote the periodic and m-independent part of the integrand as J (u) to avoid clutter. Then, as argued above, the bulk contour, along with the third and fourth terms in (4.87), give a vanishing contribution, and we are left with: Consider the sum over n ≤ 0. Since the contours along Re(u) = 0 and Re(u) = 1 have opposite orientations, we see that it is a telescoping sum, with contributions canceling between adjacent terms. That is, if we place an lower cutoff at −N , we find: (4.90) Using F(u + N ) p = F(u) p Π(u) −pN and the fact that |Π(u)| = e −2πIm(∂uW) > 1 for η > 0, by definition of the C η 0 contour, we see that the second term in (4.90) vanishes as N → ∞, and so the sum converges to the first term. Similarly, the sum over positive n converges to: We then find: These two pieces include the portion of Re(u) = 0 with Im(∂ u W) > 0 and Im(∂ u W) < 0, respectively, thus spanning the entire imaginary axis (up to a measure zero subset). The respective orientations are such that C η>0, Re(u)=0 0 +C η<0, Re(u)=0 0 is the contour along Re(u) = 0 from Im(u) = −∞ to Im(u) = ∞. We finally obtain: This reproduces the formula (4.81) with C σ equal to the imaginary axis. The above derivation relied on the assumption that δ α − Q α p < 0, ∀α. In the more general case, the argument above, and the resulting integration contour C σ , needs to be modified slightly. In general, we may find a finite set of fluxes, m, which have a nonzero contribution from C η, bulk 0 . In addition, there may be contributions from third and fourth terms in (4.87). Both contributions will add additional pieces to the σ-contour.
Alternatively, a simple way to arrive at the correct contour is to start from a region of parameter space where the assumption δ α −Q α p < 0 holds, in which case the contour is the imaginary axis, and then analytically continue to the region of interest. As we continuously vary parameters to perform this analytic continuation, we must deform the integration contour so that no poles cross it. In particular, noting that the initial contour separates all poles due to positively charged chirals from those due to negatively charged ones, this must also be true of the general contour C σ .
Note this conditions does not uniquely fix the contour C σ , however, all choices which separate poles appropriately will give the same result by holomorphy. For p > 1, we may in principle choose C σ differently for the p different terms in the sum in (4.93). However, it is always possible to find a single C σ which separates the poles due to positively and negatively charged fields for all m ∈ Z p , and we will always make this choice.

Example
Returning to our example of U (1) −1/2 with a charge one chiral, note from Figure 3 that for n ≥ 0, the contour C η>0 n does not enclose any poles of the integrand. Similarly, for n ≤ 0, the contribution to C η<0 n from the charged monopole, T + , at Im(u) → −∞, vanishes. Thus if we choose η > 0 for n ≥ 0 and η < 0 for n < 0, there are no contributions from the "bulk" part of the contour, shown in Figure 4 as the dotted lines. All that remains are the boundary contributions, which partially cancel between adjacent values of n, and leave the non-compact contour C σ .
In more detail, the contour C σ pictured in Figure 4 includes both the imaginary u axis, as well as a horizontal piece at Im(u) → ∞, which is the contribution from the uncharged monopole, T − . This piece extends towards positive Re(u), which is a Figure 4: Taking η < 0 for n < 0 and η > 0 for n ≥ 0, we see the contours do not enclose any poles, and so the bulk contributions vanish, leaving only the boundary contributions. These sum to form the contour C σ . Here we have taken Im(τ ) < 0.

Figure 5:
Here we take Im(τ ) > 0, and note the corresponding contours, C η>0 n and C η<0 n . Summing these as above to obtain the σ-contour, we see it now runs off to Re(u) < 0 as Im(u) → ∞.
consequence of choosing Im(τ ) < 0. If we take Re(τ ) < 0, which is equivalent to imposing δ − < 0, then the contribution from this horizontal piece vanishes, and C σ is simply the imaginary u axis.
More generally, we must include this piece of the contour to obtain a convergent integral. Note that if we instead took Im(τ ) > 0, we would obtain a different JK contour, as shown in Figure 5. This leads to a contour C σ which extends towards negative Re(u). To understand this behavior, note from (4.72) that in order for the integral to converge as Im(u) → ∞ we must have Im(τ u) < 0. One can check that this Here the contour we find after summing all these pieces is homologous to the one shown at right, which separates the poles due to the positively and negatively charged fields holds provided we take (for some δ > 0 depending on arg τ ): These conditions are satisfied by the contours shown above. Finally, we note that if we vary the parameters ν and τ , it may no longer be the case that all the bulk pieces of the contour vanish. This is illustrated in Figure 6. In this case, we see that the contour we found above is supplemented by a finite number of additional pieces. The resulting contour is homologous to one which separates the poles due to positively and negatively charged fields.

Relation to the Bethe-vacua formula
In this section, we have computed the partition function by supersymmetric localization, starting from the UV action. In Section 2, we computed it instead using the low energy effective action, and found it was expressed as a sum over Bethe vacua. In this subsection we relate these two prescriptions, and we argue that they give the same result. For completeness, we will present two arguments, relating the Bethe vacua formula to the JK contour in (4.73), and then relating it directly to the σ-contour derived in the previous subsection.

Relation to JK-contour
Let us first assume that the gauge group is U (1). We start again from the JK contour expression (4.75): (4.95) where we defined J (u) as in (4.61). Note that, on the contour C η 0 , we have: As before, we may choose to take η < 0 for m ≥ 0 and η > 0 for m < 0: Then, both sums give converging geometric series due to (4.96), and we can permute the sum and the integral. We then obtain: where we defined the contour: This contour precisely bounds the regionM remaining after all poles in the original integrand have been excised. Therefore, by definition ofM, the contour integral (4.98) does not pick any contributions from any of the poles of J (u). On the other hand C BE is homologous to a contour that surrounds all the poles at the solutions to the Bethe equation Π(u) = 1 in an anti-clockwise manner. This directly leads to the Bethe-vacua formula: where we used the identity ∂ u Π(u) = 2πiH(u)Π(u) in the second line.
Finally, if the gauge group is non-abelian (i.e., for G = SU (2) or SO (3)), we should excludeû = 0 from the potential Bethe solutions. (At g = 0, we have a vanishing residue due to the vector multiplet contribution, while we should exclude theû = 0 contribution by hand in general. 22 ) The non-zero solutions come in Weyl-equivalent pairs, {±û}, which give the same contribution, and so we may count each pair once, cancelling the Weyl symmetry factor |W G | = 2. We are then counting precisely the Bethe solutions (2.34), and we reproduce in this way the Bethe-vacua expression (2.48) for the M g,p partition function.

Example
Let us see how this argument works in the example we have been considering above. If we start from the same contour as in the LHS of Figure 4, note that the geometric series in the sum over m ≥ 0, in the right half plane, converges on C η>0 m , since |Π| < 1 there, while the sum over m < 0 converges along C η<0 m since |Π| −1 < 1 there. Summing the geometric series, we find: This is shown in Figure 7. This encloses the regionM 0 , and counts the residues from any poles in this region. This includes only the single pole at Π = 1, leading to the Bethe-vacua formula as above.

Relation to σ-contour
Next, let us start from the σ-contour formula: (4.102) As noted above, C σ is a contour which separates the poles due to the positively charged fields (including monopole singularities at infinity) from those due to the negatively charged ones. For p > 0, the positively-charged singularities are to the left of C σ . By performing the finite sum over m and using the difference equation for F(u), we find: where C is a contour which encloses all the poles of the integrand between C σ and C σ − 1. (Roughly speaking, it encloses the strip −1 ≤ Re(u) ≤ 0 in anti-clockwise manner.) There are two types of poles that may occur in that region: those from the original integrand, F(u) p J (u), and those at solutions to Π(u) = 1. Let us first consider the poles from the original integrand. The poles due to negatively-charged fields must lie to the right of C σ , and so they cannot be enclosed by C . On the other hand, poles from positively-charged fields may lie inside C , and suppose one lies at some u * . Then by assumption, there is no pole at u * + 1 for any m ∈ Z p , and so F( is finite as well (here we recall Π(u) → ∞ for poles due to positively charged fields).
Then the only poles in (4.103) lie at solutions to Π(u) = 1. The partition function is then given by: (4.104) For a non-abelian rank-one gauge group, the same comments as written after (4.100) apply. The final formula precisely agrees with (2.48).

Higher-rank theories
In this section, we briefly discuss how some of the above considerations generalize in the case of higher-rank gauge theories.

Higher rank "JK contour": a conjecture
Here we present a natural conjecture for the contour C η appearing in (4.79), i.e.: Although we do not derive it directly from a localization argument, it passes several consistency checks, as we outline below and in Appendix D.2. We leave its careful derivation to future work. First we recall the usual JK residue prescription [32,29]. Generically, the integrand in (4.105) may have non-trivial residues at the intersection of r complex-codimensionone singular hyperplanes associated to chiral multiplets. 23 The JK prescription, which depends on a choice of covector, η ∈ h * , determines which of these residues one should count. Namely, if the corresponding chiral multiplets have charges Q a α , α = 1, ..., r, we count this residue (with an appropriate sign) if and only if: where the RHS is the positive cone of the Q α in ih * , spanned by positive real multiples of the charge vectors Q α . The final answer, obtained by summing over all such residues, is independent of the choice of η.
In our case, in order to properly deal with the "singularities at infinity" due to monopoles, it will be convenient to define an explicit contour, C η , also labeled by a covector η ∈ h * , which will turn out to be closely related to this prescription. Let us define: 24 To relate this to the usual JK residue prescription, recall that a chiral multiplet of charge Q α may develop a pole when Q a α (pu a − m a ) = β k for some set of parameters β k . In addition, there may be "poles at infinity" due to monopoles at large values of Im(u a ). Then, in the vicinity of such a singularity, one can check that: where we have defined the small parameters: near a monopole singularity (4.109) 23 For special choices of parameters, there may be "non-regular" singularities where more than r hyperplanes intersect, and the JK prescription in these cases is more complicated. However, moving slightly away from such a point in parameter space we may typically resolve this into regular singularities, where we may apply the procedure above, and then analytically continue back to the point of interest. (This is true, in particular, in all the examples we will consider below.) 24 Here we choose the overall orientation on C η so that the top form ∧ r a=1 d Re(∂ ua W) is positive. For example, in the rank one case, near a singularity due to a charge Q chiral this form goes as 2πQdθ, where u = u * + e iθ , correctly reproducing the orientation discussed above. For higher rank, one can check that this agrees with the sign convention of the usual JK residue prescription. Now, let us rescale η → tη for large positive t, and consider some component of the contour C tη . Since Im(∂ ua W) is parametrically large, this component must lie near some number, k > 0, of singular hyperplanes. Then, in the vicinity of these k hyperplanes, we have: Since the log α are negative near the intersection, the RHS is necessarily in the negative cone spanned by the Q α . Then the only way it is possible to satisfy Im(∂ ua W) = −tη a is if k = r (generically) and η is in the positive cone of the Q a α . Explicitly, writing η a = α c α Q a α , for c α > 0, and taking α = e −tc α we find a component of C η which wraps this intersection point. Thus this residue is indeed counted by the integral over C η , and so it counts the same residues as the usual JK prescription. In particular it is independent of the choice of η. This can also be seen directly by noting that changing η continuously deforms the contour while not crossing any poles of the integrand, since these only occur when some Im(∂ ua W) diverges.
We may also define the contour C η 0 in (4.80). This is contained inside the region M 0 = {u ∈ h C | 0 ≤ Re(u a ) ≤ 1}. First, we define the portion of the contour in the interior of M 0 : In addition to this bulk piece, the contour C η 0 includes segments along the boundary of M 0 , at Re(u a ) = 0 or 1 for some a, similar to the rank one case. We define: where t runs over the interval [0, 1]. Note that this generically defines a dimension r contour inside the boundary of M 0 . The prefactor sets the relative orientation of these components, which is picked so that they match consistently with the interior components where they meet. Then we set: With this definition, one can check that the integral is invariant under continuously rescaling η → tη, and more generally under any continuous change of η, as with the usual JK contour. As evidence that this is the correct contour for defining the M g,p partition function, in Appendix D.2 we present an argument relating the integral over this contour to the Bethe-vacua formula for the partition function in (2.48), generalizing the rank-one case.

The σ-contour
We further conjecture that there exists an equivalent σ-contour, analogous to the one described in Section 4.6.1, of the form: where C σ is a certain middle-dimensional non-compact contour connecting Im(u a ) → −∞ with Im(u a ) → ∞.
To define C σ , we first note that it is straightforward to generalize the bound (4.85) to higher rank. One finds that the chiral multiplets and monopole operators may only have poles provided that: Let us assume for simplicity that we may pick flavor symmetry parameters and Rcharges so that δ α − Q α p < 0 for all α. We then conjecture that we may take C σ to be the product of the imaginary u a -axes for a = 1, ..., r. This reproduces the prescription in [2,3,4], which was obtained with a slightly different choice of localizing supercharge. For more general parameters, one may derive the appropriate contour by analytic continuation.

Relation of the σ-contour to the Bethe-vacua sum
Here we show the equivalence of the conjectured σ-contour integral to the Bethe-vacua sum, (2.48). As above, we assume that we may pick flavor symmetry parameters such that δ α −Q α p < 0 for all α. With such a simplification, the argument for the higher-rank case is a straightforward extension of that of the rank-one case. We write: where u = {u a } and m = {m a }, where a runs over a set of generators of the Cartan of the Lie algebra, h. As before, we first perform the sum over torsion fluxes: .

(4.117)
Here the contour is a product of the contour iR − (iR − 1) over each direction in the Cartan. This encloses all the poles of the integrand in the region −1 < Re(u a ) < 0, a = 1, ..., r, and by our assumption above, these poles only arise at solutions to Π a (u) = 1, a = 1, ..., r. Thus we can write: where we have used: which contributes through a Jacobian factor of (det(∂ ua Π b (u))) −1 = (2πi) −r H(u) −1 to the residue. Finally, in the case of non-abelian gauge groups, we should exclude those poles which are not acted freely by the Weyl group, while we count the remaining solutions up to the Weyl group action, canceling the symmetry factor. In this way, we arrive at the Bethe-vacua formula (2.48). This completes the proof of the equivalence of the two prescriptions.

The S 3 partition function and F-maximization
Consider the S 3 partition function for an N = 2 supersymmetric gauge theory with integer R-charges r 0 , and with generic flavor fugacities ν turned on. The Bethe-vacua formula (2.48) reads: in this case. As explained in Section 3.1.3, this result can be analytically continued to any allowed R-charge: simply by replacing ν α by ν α + t α in (5.1). (Here t α = 0 only for α corresponding to the free abelian subgroup of the flavor group.) For any gauge theory that flows to an N = 2 superconformal theory, we define a trial F -function as: where we have set ν = t in (5.1). The superconformal R-charge maximizes the real part of F S 3 (t) as a function of t [4,44]. We then have: In general, the right-hand-side of (5.5) is only a local maximum, and we have to use our physical intuition to identify the correct superconformal R-charge. In practice, we choose r 0 = 1 as the integer R-charge for every elementary chiral multiplet, and we probe the t α parameter space such that all the elementary R-charges lie between r = 0 and 1. Given any R-charge that maximizes F S 3 , we should check that no gauge-invariant chiral operator violates the unitarity bound. A violation of the unitarity bound might signal the presence of free fields and accidental symmetries in the infrared-see e.g. [81,82,83] for a discussion of such cases. The formula (5.3) is an alternative to the matrix-model integral formula of [2,3,4]. In the following, we demonstrate its utility by performing F -maximization in some simple theories. This provides highly non-trivial consistency checks of (5.1). This Fmaximization method compares favorably to the usual method using the integral formula. The trial F in (5.3) is given in terms of an explicit (albeit highly involved) function. In numerical studies, the usual integral method becomes more time-consuming as the rank of the gauge group increases, while in the present case the evaluation time depends principally on the number of Bethe vacua. We also avoid cumbersome issues of numerical integration, and the potential lack of convergence of the integral formula with a real σ contour.
Note that F S 3 is generally a complex function, whose imaginary part encodes parityviolating contact terms [25]. It is interesting to expand (5.3) around t = t * . For instance, for a single U (1) F flavor symmetry mixing in (5.2), we have: with m F the real mass for U (1) F , and the ellipsis denotes higher-order terms in m F . The terms κ RR , κ g , κ F R , κ F F are the contact terms discussed in Section 4.3.2, and τ F F is the two-point function coefficient of the U (1) F conserved current [25].

The free chiral multiplet
Consider a chiral multiplet of R-charge r ∈ R coupled to a U (1) I vector multiplet with charge Q ∈ Z and real mass σ. The S 3 partition function reads: with the function F Φ defined in (4.49), and setting u = iσ in order to compare with [7,44]. We can easily check that: has a local maximum r = 1 2 , the superconformal R-charge of a free chiral multiplet, after we set σ = 0. Expanding around σ = 0 at r = 1 2 , we obtain: Comparing to (5.6), we read off: This corresponds exactly to the κ parameters (4.45) upon plugging in r = 1 2 , providing another confirmation that our regularization of the chiral multiplet one-loop determinant indeed corresponds to those contact terms. We also see from (5.9) that F S 3 = 1 2 log 2 and τ F F = Q 2 for a free chiral, as should be the case in any regularization scheme.
We should also note that the chiral multiplet partition function (5.7) is related to the result Z Φ S 3 of [3,4] by: The discrepancy is simply because of our choice of a gauge-invariant but parity-violating regularization, leading to contact terms κ = 0 in (4.45), while the regularization scheme of [3,4] implicitly sets κ = 0, which preserves parity but is inconsistent with gauge invariance.

U (N c ) k theory with N f flavors
Consider a U (N c ) theory at CS level k > 0 with N f flavors (that is, N f pairs of fundamental and antifundamental chiral multiplets, with symmetric quantization). We will discuss this theory in more detail in Section 6. The abelian subgroup of the flavor group is U (1) A × U (1) T , where U (1) T is the topological symmetry. We may assign a trial R-charge: to the chiral multiplets, where the only allowed mixing is with U (1) A . (A Z 2 symmetry prevents any mixing with U (1) T .) The Bethe vacua correspond to all the choices of N c roots of the degree-(N f + k) polynomial:    where y A = e 2πiν A and q = e 2πiτ are the fugacities for U (1) A and U (1) T , respectively. The twisted superpotential of this theory reads: Li 2 e 2πi(ua+ν A ) + Li 2 e 2πi(−ua+ν A ) , where we only turned on ν A , setting τ and all other mass parameters to zero. Let u a = log(x a )/(2πi) (5.15) denote a Bethe vacua, wherex a is a choice of N c roots of P (x). The formula (5.3) gives us: with: It is easy to maximize (5.16) using Mathematica, at least for N f + k small enough. We present some examples in the Table 1. They are in perfect agreement with results previously reported in the literature [39,40,83]. There are a few cases, denoted by ∼, where our numerical evaluation of (5.16) was inaccurate near the F -maximizing value of r. In all other cases, we can easily reach a high precision for r and F S 3 , although it becomes time-consuming as the number of Bethe vacua, increases. When k = 0, there are cases where naive F -maximization leads to unphysical results, given in parenthesis in Table 1; the physical values were computed in [83]. Note also that, in the special case N c = k + N f with k > 0, we obtain r = 1/4 and Indeed, the infrared theory consists of N 2 f free mesons [39]. This is the limiting case of the Giveon-Kutasov duality [84]. For N c = N f > 1 with k = 0, we should have r = 1/4 and F S 3 = (N 2 f + 2) log √ 2, which can be obtained using the Aharony dual theory [85,83].

Matching Z M g,p across supersymmetric dualities
The Bethe-vacua formula (2.52) provides a simple way to study supersymmetric dualities. If two distinct three-dimensional N = 2 gauge theories T and T D are infrared dual, their supersymmetric partition functions and correlation functions must agree on any M g,p . This implies: where: in the dual theories. Here ν α , n α are the flavor fugacities and fluxes, respectively (the product over the index α is implied), W is a loop operator in theory T , and W D is the loop operator it maps to under the duality. For (6.1) to hold for arbitrary g, p, n α , and operator W (x), it is necessary and sufficient that there exists a one-to-one "duality map" between the supersymmetric vacua: such that on every pair of dual vacuax andx D . Duality relations between Wilson loops in many infrared dualities were studied explicitly in [41,22]. As argued in Section 2.6, the fibering, flux, and handle-gluing operators evaluated at a Bethe vacuum can be obtained from the "on-shell" twisted superpotential and effective dilaton potential (2.53). To prove the equivalence of the partition functions, it thus suffices to demonstrate that: , Ω l (ν) = Ω l D (ν) , l = 1, · · · , |S BE | , (6.6) modulo the integer-quantized branch cut ambiguities, (2.32). In this section we will prove the equality (6.1) for a number of non-trivial dualities by checking (6.6), which then implies (6.4). In most of the examples below, the matching of the handle-gluing operators (and flux operators) was already checked in [22,21], by considering theories on Σ g × S 1 , so we will mostly focus on matching the fibering operators. 25 Note on conventions. In the remainder of this section, we will use a rescaled twisted superpotential: Let us recall that a (regularized) chiral multiplet Φ and the U (1) and gravitational Chern-Simons terms contribute: to W, respectively. In the following, it will be important to keep track of our branch-cut conventions. We define the logarithm log z such that −π < Im(log z) ≤ π (i.e. with a branch cut along the negative real axis), and we define the dilogarithm Li 2 (z) such that: with a single branch cut along the real axis with Re(z) > 1.

Two-term dilogarithm identities and abelian mirror symmetry
There are two elementary identities involving two dilogarithms: (6.10) These identities correspond, at the level of the twisted superpotential, to the following properties of 3d N = 2 theories.
Massive chiral multiplets. We already pointed out in Section 2.2.1 that the first identity in (6.10) corresponds to the fact that two chiral multiplets with a superpotential W = Φ 1 Φ 2 is "dual" to an empty theory. More precisely, consider two chirals with U (1) charges ±1 in the U (1) − 1 2 quantization, of R-charges r 1 = r, r 2 = 2 − r, respectively. The low-energy theory corresponds to an empty theory with U (1) CS level k = −1 and gravitational CS level k g = −2. This corresponds to: where we wrote the first line of (6.10) on the principal branch of the log. This implies the identity F Φ (u)F Φ (−u) = e πiu 2 − πi 6 (6.12) for the fibering operators, which is independent of the branch cuts as a function of uboth sides of (6.12) are meromorphic functions on the u plane. The low energy-theory also has the gauge-R and RR CS levels k R = −r + 1 and k RR = −(r − 1) 2 , respectively. The effective dilaton reads: which reproduces those CS levels, since: 14) The elementary mirror symmetry duality. Let us consider a U (1)1 2 gauge theory with a single chiral multiplet of charge 1 and R-charge r. The effective twisted superpotential and effective dilaton read: , where q = e 2πiτ is the fugacity for the U (1) T topological symmetry. This corresponds to the non-zero bare contact terms κ = 1 2 (for the gauge symmetry), κ R = − 1 2 (r − 1) and κ RR = − 1 2 (r − 1) 2 , in addition to the FI term. The Bethe equation for this theory has a single solution: Substituting back into (6.15), we find the on-shell twisted superpotential and dilaton potential: , where Ω (1) is defined as in (2.53). To obtain the fibering operator from (6.17), we must choose the "physical" branch of the twisted superpotential as discussed in Section 2.6. This is the condition: which indeed holds for all q. This theory is dual to a free chiral multiplet of charge 1 under the U (1) T global symmetry, and R-charge −r + 1. This chiral multiplet can be identified with the gaugeinvariant monopole operator T + in the original theory, whose induced charges can be computed from (2.40). This chiral multiplet is quantized with κ T T = − 1 2 , κ T R = − r 2 and κ RR = − 1 2 (r − 1) 2 + r (mod 2), so that the dual twisted superpotential is simply given by: while the dual effective dilaton is exactly the same as Ω (1) (q) in (6.17). The non-trivial identity of the on-shell twisted superpotentials: directly follows from (6.10). This duality relation implies: D (τ ) between the on-shell fibering operators, seen as meromorphic functions of τ . As a consistency check, one can easily check (6.21) numerically.

Gauging flavor symmetries and general abelian mirror symmetry
From this basic duality, it is possible to construct a mirror dual description of a more general abelian gauge theory. The idea is to start from several decoupled copies of this duality and gauge appropriate flavor symmetries on each side to obtain the desired theories [86]. Here we illustrate this procedure in a simple case, constructing the mirror dual of U (1) k=− N 2 with N charge-one chiral multiplets. We focus on the on-shell twisted superpotential for simplicity; the matching of effective dilaton can be shown similarly, and then that of the M g,p partition function follows from the general discussion in Section 2.6.
To construct the original theory, we start with N copies of the free chiral multiplet. This theory has a U (N ) symmetry, which we decompose as U (1) × SU (N ), with corresponding parameters z for the overall U (1) and y i with i y i = 1, for the SU (N ). 26 Then the twisted superpotential of this theory, including a level − 1 2 contact term for each chiral, is: Li 2 (zy i ) + log q log z . (6.22) For later convenience, we introduced a background vector multiplet with a BF coupling to the U (1) flavor symmetry, with a corresponding parameter q . We then gauge the U (1) symmetry corresponding to z by solving the Bethe equation: This has N solutions, which may be inserted into (6.22) to find the on-shell twisted superpotential for the N vacua.
To construct the mirror dual theory, we note that the N free chiral multiplets we started with are dual to N copies of the U (1)1 This has twisted superpotential: Here x i are the parameters for the U (1) N gauge symmetry. If we solve the Bethe equations for the x i and substitute the solutions, we obtain (6.22), and subsequently solving the Bethe equation for z will give the same N solutions as above. It is more illuminating, however, to first solve the Bethe equation for z. This gives: To solve this, introduce the new variables x i∼i+N by: Then the twisted superpotential becomes: 6.2 N f = 1 SQED/XY Z model duality Consider a U (1) theory with two chiral multiplets Q, Q of gauge charges ±, respectively, and R-charge r. The theory has a U (1) A × U (1) T flavor symmetry, with charges summarized in Table 2. We turn on the corresponding fugacities y A = e 2πiν A and q = e 2πiτ . The effective twisted superpotential is given by: (6.28) The CS terms in the second line appear because we choose the symmetric quantization for the flavor Q, Q, such that the bare contact terms vanish. Similarly, the effective dilaton reads: The Bethe equation has a single solution: This theory is dual to the XY Z model, which consists of three chiral multiplets (X, Y, Z) = (M, T + , T − ) with charges given in Table 2, and a cubic superpotential W = M T + T − . The twisted superpotential of that theory is: (6.31) The CS levels are again chosen so that the bare contact terms vanish. Similarly, the effective dilaton is such that: It is straightforward to check that the N f = 1 SQED handle-gluing operator exactly reproduces (6.32) on the Bethe vacuum: On the other hand, we can check that the twisted superpotentials also match on-shell: for a particular choice of branches. This relation follows from a well-known five-term relation for the dilogarithm, which can be written as: for a certain choice of branch. By plugging w = qy −1 A , z = q −1 y −1 A into (6.35) and by using (6.10) several times, one can derive (6.34). The fibering operators of the dual theories read: The relation (6.34) implies a functional relation: One can also easily check this relation numerically.

Seiberg-like dualities
Consider three-dimensional SQCD[k, N c , N f , N a ], which consists of a U (N c ) k gauge theory at CS level k, 27 coupled to N f fundamental and N a antifundamental chiral multiplets, denoted by Q i and Q j , respectively. Without loss of generality, we consider k ≥ 0 and N f ≥ N c . This theory has a flavor group: with charges summarized in Table 3. 27 In this language, the CS level k may be half-integer, while k + 1 2 (N f + N a ) must be integer. Three-dimensional SQCD has an infrared-dual description whose precise form depends on the parameters k and N f − N a [85,84,40]. The dual theory has a gauge group U (n f − N c ), with (6.39) The U (n f −N c ) vector multiplet is coupled to N a fundamental and N f antifundamental chiral multiplets, denoted by q i and q j , respectively. It also contains N f N a gauge singlets M j i , and d C ≤ 2 additional singlets in special cases. 28 The gauge-singlets are coupled to the gauge sector through the usual Seiberg-dual superpotential.
All these dualities can be derived by massive deformations of the so-called Aharony duality [85], which is the case k = 0, N f = N a . In the following, we discuss the equality of supersymmetric partition functions for Aharony-dual theories. (We refer to [22] for a more detailed review of Seiberg-like dualities.)

Aharony duality
Electric theory. Consider a U (N c ) vector multiplet coupled to N f pairs of fundamental and antifundamental chiral multiplets Q i , Q j of R-charge r. Let us introduce the parameters: for the flavor group (6.38), such that: The effective twisted superpotential of this theory reads: (6.42) The integer CS terms in (6.42) are chosen such that most of the bare contact terms vanish. More precisely, we have: where κ is the gauge contact term, and κ SU ( Similarly, the effective dilaton is given by: The Bethe equations of this theory, 45) are given in terms of a single polynomial of degree N f : The Weyl group is the symmetric group S Nc that permutes the x a 's. Therefore, a Bethe vacuumx (l) ≡ {x (l) a } Nc a=1 consist of a choice of N c distinct roots of P (x), and there are Magnetic theory. The Aharony dual theory is a U (N f − N c ) theory with N f pairs of fundamental and antifundamentals q j , q i of R-charge 1 − r, together with N 2 f gauge singlets M j i of R-charge 2r, and two additional singlets T ± of R-charge: and a superpotential The gauge singlets are identified with the "mesons" M j i = Q j Q i and with the monopole operators T ± in the U (N c ) theory. All the charges are given in Table 4.
The twisted superpotential reads: with: (6.52) In (6.50), we identified the dual FI parameter τ D with minus the U (N c ) FI parameter, τ D = −τ , and the bare contact terms are the same as in (6.43). Similarly, the dual effective dilaton reads: Ω D = Ω D,gauge + Ω D,singlet (6.53) with: with r ± given by (6.48). The dual Bethe equations read: 56) in terms of the same polynomial (6.46) as the original theory. Let {x α } N f α=1 denote the roots of P (x). The duality map (6.3) is simply: That is, givenx choice of N c roots of P (x), the dual vacuumx D in the Aharony-dual theory is given by the N f −N c complement set of roots. Note that the duality of Section 6.2 is also the special case N f = N c = 1 of Aharony duality.
Matching the fibering operators. To match the fibering operators across the duality, we need to prove that: for a particular choice of branch, where the dependence on the many flavor parameters is left implicit. Using the first relation in (6.10), one can show that (6.58) is equivalent to: W wherex in (6.59) is given by the N f roots P (x) in {x α } of (6.46). Note that (6.59) is independent of N c . This relation corresponds to a known multi-variable generalization of the five-term dilogarithm identity, which was studied thoroughly in the mathematical literature [37,87]. This implies the duality relations: which are independent of branch cut ambiguities. In particular, the relation (6.59) implies: wherex α = e 2πiûα are the roots of P (x). One can also check (6.61) numerically.
Matching the handle-gluing operators. To complete the proof of the equality (6.1) for Aharony duality, we must also prove that: for any pair of dual vacua. The handle-gluing operators are rational functions of the x a and xā variables, and the relation (6.62) can be proven using rather straightforward algebraic manipulations, as explained in [22].

Decoupling limits and Seiberg-like dualities
All other dualities for SQCD[k, N c , N f , N a ] can be derived from Aharony duality by real mass deformation. We refer to Appendix C of [22] for a detailed review.
To obtain SQCD[k, N c , N f , N a ], we consider a particular massive deformation of SQCD[0, N c , n f , n f ], with n f defined in (6.39). We can take the decoupling limit at the level of the effective twisted superpotential and effective dilaton. The number of Bethe vacua, stays constant upon deformation. We can then study the identities (6.6) as we take a decoupling limit. Typically, both sides of a duality relation diverge as the mass goes to infinity, but with an identical coefficient on both sides. Therefore, we can cancel the divergences and deduce the identity for the IR theory from its UV parent [40]. In the following, we demonstrate this behavior at the level of the Bethe equations.
Let us define k c ≡ 1 2 (N f −N a ). Consider first the case k ≥ k c . This can be obtained from SQCD[0, N c , n f , n f ] by integrating out k − k c fundamental chiral multiplets Q α with positive real mass and k + k c antifundamental chiral multiplets Q β with positive real mass, while the remaining N f fundamental chiral multiplets Q i and N a antifundamental chiral multiplets Q j remain light. Let us denote by m 0 → ∞ the real mass parameter that we send to infinity, and by y 0 → 0 the corresponding fugacity. The gauge and flavor fugacities must be rescaled according to: which also implies: The case k c ≥ k can be obtained similarly. We start from SQCD[0, N c , N f , N f ] and we integrate out k c + k antifundamental multiplets Q β with positive real mass and k c − k antifundamental multiplets Q γ with negative real mass. The relevant scaling is: 66) and It is easy to apply this scaling to any of the various operators that enter the supersymmetric partition function. By considering the limit y 0 → 0 at the level of the Bethe equations, we obtain new Bethe equations P (x a ) = 0 in terms of the polynomial: where we defined: We may similarly study this decoupling limit at the level of the twisted superpotential. It is obvious from the general properties of W, and in particular from the limits (2.26), that we reproduce in this way the correct low energy theories, including all the correct gauge and flavor Chern-Simons levels.

The "duality appetizer"
As our last example, we consider the "duality appetizer" of [88]. It relates the following theories: Theory A is an SU (2) gauge theory with CS level k = 1, coupled to a single adjoint chiral multiplet Φ. Theory B is a free chiral multiplet, Z, together with a decoupled U (1) k=2 topological sector. The operator T rΦ 2 in theory A is mapped to Z in theory B. Correspondingly, there is a single U (1) F flavor symmetry which acts on Φ with charge 1, and on Z with charge 2. 29 The handle-gluing operators across the duality were matched in [20]. Let us show that the fibering operators match as well. The effective twisted superpotential of theory A is given by: The corresponding Bethe equation can be written as: The solutions x = ±1 correspond to fixed points of the Weyl group action, x → x −1 , and are thus discarded. The remaining four solutions come in two Weyl pairs, with: x +x −1 = ±(1 + y −1 ) (6.72) which correspond to the two physical vacua of this theory. Let us definex = α to be one of the first solution in (6.72), so thatx = −α gives the other solution. Then y −1 = α + α −1 − 1. Plugging this relation into the effective twisted superpotential (6.70), we find that the on-shell twisted superpotential for the two vacua are: Note that, up to a change of branch: In other words, the only difference between the on-shell twisted superpotentials in the two vacua can be attributed to a relative gravitational CS term.
Turning to theory B, the contribution from the scalar Z is: where we set the U (1) F CS term such that the κ F F bare contact term vanishes. For the U (1) 2 sector at zero FI parameter, the two vacua contribute only gravitational CS terms k g = 0 and k g = 6. 30 This is precisely the difference (6.74) between the two vacua in Theory A. Thus it remains only to check the matching of the twisted superpotential of one of the vacua. The precise statement, including a relative gravitational CS term ∆k g = −2, is: This follows from the identity: (6.77) As with all identities involving dilogarithms evaluated at rational functions of a single variable, this can be derived by repeated applications of the five-term identity. The relation (6.76) implies the matching of the dual fibering operators.
In this Appendix, we briefly summarize our geometric conventions and we provide some additional details about the geometry and topology of M g,p . We also briefly discuss torsion line bundles over M g,p with p = 0.
A.1 The M g,p geometry We follow the geometry conventions of [22], which closely follows [11,19]. Let us consider the three-manifold M g,p , a U (1) principal bundle over the Riemann surface, Σ g , with metric: The coordinates are (x µ ) = (ψ, z,z), with ψ ∈ [0, 2π) an angular coordinate along the S 1 fiber, and the z,z local coordinates on the base Σ g . The two-dimensional metric 2g zz is a complete Hermitian metric on Σ g , written in a local patch. The quantity C is a U (1) connection over Σ g with first Chern number p: The complex frame (e a ) = (e 0 , e 1 , e1) is defined in (3.9). The frame indices a = 0, 1,1 are lowered using δ ab with δ 00 = 1 and δ 11 = 1 2 . The orientation is such that 011 = −2i and the γ-matrices are: The metric (A.1) has an Killing vector K = 1 β ∂ ψ . Let us also define the one-form: which satisfies K µ η µ = 1, and the tensor: 31 We have: The objects η and Φ define a metric-compatible transversely holomorphic foliation (THF) on M g,p . This means that there exists adapted coordinates ψ, z,z such that the transition functions between patches are of the form with λ real and f (z) a holomorphic function of z [11]. We are considering a particular THF on M g,p such that the foliation η is also an S 1 fibration, and the leaves of the THF are the S 1 fibers. Note that, under a change of coordinates (A.7), we also have the gauge transformation: so that η is a well-defined one-form.
A THF is a natural three-dimensional analog of a complex structure. In the present case, the THF is simply the uplift of the complex structure on Σ g . Let us define the projection operators: which satisfy P 0 +Π+ Π = 1. They allow us to decompose any one-form α into vertical, holomorphic and (horizontal) anti-holomorphic components, respectively: In particular, a holomorphic one-form, ω ∈ Λ 1,0 M g,p , is such that: Its single component ω z transforms as ω z = (∂ z f (z)) −1 ω z under a change of adapted coordinates. By definition, ω z is a section of an holomorphic line bundle over M g,p [19]. 32 We call that particular holomorphic line bundle the canonical bundle, denoted by K: K is the pull-back of the canonical line bundle on Σ g , and its first Chern class is given by (3.11). Similarly, a holomorphic vector X ∈ T 1,0 M g,p satisfies Π µ ν X ν = X µ , and is given by 13) in local coordinates. In the main text, we mainly use the frame basis, so that ω = ω 1 e 1 and X = X 1 ∂ 1 , with ∂ 1 = e µ 1 ∂ µ . Note that the Levi-Civita connection ∇ does not commute with η µ , and therefore does not preserve the decomposition (A.10). We define a metric-and THF-compatible connection∇, such that∇ µ g νρ = 0 ,∇ µ η ν = 0 . (A.14) It is given by: with Γ ν µρ the Christoffel symbols. Here K ν µρ is the contorsion tensor. The adapted spin connection is:ω We will denote the adapted covariant derivative, acting on any field, simply by D µ . 33 It commutes with the projectors (A.9) and it is therefore compatible with the decomposition into vertical, holomorphic and anti-holomorphic component, which we used extensively in Section 3. Note that we have: on a Dirac fermion ψ, and similarly on fields of any definite three-dimensional spin.
The adapted connection has torsion: In particular, we have: when acting on a scalar field ϕ.
We can also check that the Lie derivative and the adapted covariant derivative are equal along the Killing vector K µ : for fields of any spin. This is useful in order to check that the supersymmetry transformations of Section 3 realize the supersymmetry algebra (3.48). The following identities are also useful: where dvol(Σ g ) and dvol(M g,p ) are the volume forms on Σ g and M g,p , respectively. We normalized the volumes to vol(Σ g ) = π and vol(M g,p ) = 2π 2 β. Note that the volume form dvol(Σ g ) is exact unless p = 0.

B. Supersymmetry on M g,p
In this Appendix, we provide additional details about the supersymmetric background of Section 3. Curved-space supersymmetry for N = 2 supersymmetric theories with an R-multiplet is governed by the generalized Killing spinor equations [69,11]: A supersymmetric background on a compact three-manifold M 3 with Riemannian metric g µν consist of background values for the N = 2 "new-minimal" supergravity fields: that preserve certain Killing spinors ζ, ζ. 36 Consider M 3 = M g,p with the metric (A.1). Given the THF (A.4)-(A.5) and the Killing vector K µ = η µ , the general solution to (B.1) preserving one ζ and one ζ reads [11]: with A (R) given by: in the adapted coordinates ψ, z,z. The function κ in (B.3) satisfies K µ ∂ µ κ = 0 and is otherwise arbitrary. It couples to the real central charge Z of the three-dimensional N = 2 theory [19]. In this work, we choose: This leads to a simple relation between our M g,p background and the A-twist background on Σ g . While small deformations by κ do not affect supersymmetric observables, one could consider a "large" deformation such that κ introduces a flux for the central charge Z [19]. This would lead to a Dirac quantization condition for real mass and FI parameters. We do not consider such backgrounds. Note that S 3 background of [2,3,4] corresponds to κ = 0 such that V µ = 0. This does not affect the S 3 partition function, however, because there is no possible central 36 Note that A (R) µ = A µ − 3 2 V µ in the notation of [11].
charge flux on S 3 . Therefore, our results for M 0,1 ∼ = S 3 must be in agreement with [2,3,4], as we indeed find to be the case. Setting κ = 0 in (B.3) gives us the background fields Since V µ = 2iHη µ , we find it convenient to use the background field H and A (R) µ only, as in (3.8). The Killing spinor equations (B.1) can be simplified by using the adapted connection∇, as discussed in Section 3. We obtain (3.14), which is simply: in terms of the covariant derivative D µ define above, including the U (1) R gauge field A (R) µ .

B.1 A-twisted field variables
Using the Killing spinors ζ, ζ, we may build the one-forms: of R-charge 2 and −2, respectively. We have: In particular, p 1 is a nowhere-vanishing section of K ⊗ (L (R) ) −2 , where L (R) is the Rsymmetry line bundle. This implies that K ∼ = (L (R) ) 2 up to a topologically trivial line bundle.
After decomposing any field into vertical and horizontal components, like in (A.10), we may assign two-dimensional spins in the frame basis, as explained above (3.44). For instance, p 1 has 2d spin s 0 = 1 and R-charge −2, and it has vanishing A-twisted spin (3.44). We find it convenient to use field variables adapted to the A-twist, exactly like in [31,22]. Let us briefly review the definitions: A-twisted chiral multiplet. The twisted fields in the chiral and antichiral multiplets are related to the flat-space fields of [11] by: Here p1 and p 1 are the sections ofK ⊗ L 2 and K ⊗ L 2 as defined in (B.9). By constructions, all the A-twisted fields have R-charge zero and two-dimensional spin (3.44). In particular, A, B have twisted spin r 2 and C, F have twisted spin r−2 2 .
A-twisted vector multiplet. The gauginos λ and λ in the vector multiplet of [11] are related to the A-twisted fields (3.51) by: The gaugino supersymmetry variation can be written as: and similarly for Λ µ .
C. Spin-structure dependence of the U (1) Chern-Simons action Consider a U (1) connection a = a µ dx µ on an (oriented) three-manifold M 3 . Whenever a µ is a connection on a topologically non-trivial bundle, the CS action is defined by: with f = da and k ∈ Z the CS level. Here N 4 is a four-manifold with boundary ∂N 4 = M 3 , and the three-dimensional connection is extended to the connection of a line bundle over N 4 . An important subtlety is that the CS action depends on the spin structure of M 3 if k is odd. In that case, N 4 must also be a spin manifold, whose spin structure restricts to the spin structure specified on the boundary. This can introduce an explicit dependence of the CS action (C.1) on the choice of spin structure [77]. This point was emphasized recently e.g. in [79]. 37 First of all, note that the definition (C.1) is independent of the choice of N 4 . If we consider two different choices of four-manifolds (with spin structures) N 4 and N 4 , we have: where the compact four-manifold M 4 is the union of N 4 and N 4 (with reversed orientation) glued along M 3 .
Here q(f ) is a topological invariant of the U (1) line bundle on M 4 , which is always integer. If we specify a spin structure on M 3 , then M 4 is also a spin manifold and q(f ) is an even integer [77]; therefore the definition (C.1) makes sense for any integer k. Now, consider two distinct spin structures on the same three-manifold M 3 , which we denote by M ± 3 , and consider some choice of bounding spin four-manifolds N ± 4 . The difference between the CS actions on M + 3 and M − 3 is again given by (C.2), but the 37 See also [78]. We thank Victor Mikhaylov for very illuminating discussions on the matter.
compact four-manifold M 4 is not spin in general, since the spin structures on N + 4 and N − 4 are not compatible on the M 3 boundary. Therefore, the CS actions on M ± 3 might differ by some integer multiple of πi; in other words, the exponentiated action e −S CS might include a sign that depends on the choice of spin structure on M 3 .
We are particularly interested in the three manifolds M ± 3 ∼ = Σ g × S 1 ± , where the spin structures correspond to either the periodic (+) or anti-periodic (−) boundary condition for fermions along the S 1 (and with some given spin structure on Σ g ). In order to preserve supersymmetry, we choose the periodic spin structure, M g,0 ∼ = Σ g × S 1 + . Consider a U (1) line bundle with first Chern number m ∈ Z and a flat connection a ψ along the S 1 . We can easily see that: for the anti-periodic spin structure, because we can extend M − , with D 2 a disk with S 1 − as its boundary. 38 On the other hand, one can show that [78]: 39 S CS(+) − S CS(−) = πikm , (C.4) and therefore: This is the correct result on the supersymmetry-preserving Σ g × S 1 background; the sign was previously missed by [20,21,22]. The case T 2 × S 1 is discussed explicitly in [79]. Note that a closely related sign (−1) km appears in (4.24) from the CS action on any M g,p with p = 0, with m ∈ Z p . In that case, the sign is necessary for the CS action to be invariant under large gauge transformations, m ∼ m + p.
Incidentally, similar signs seem to be important for other supersymmetric backgrounds, in particular for the 3d superconformal index [16,15,90] (the "untwisted" S 2 × S 1 ) and the Lens space partition function [45,46]. In those cases, ad hoc signs were introduced e.g. in [53,91,47] in the sum over topological sectors. It would be interesting to review those results accordingly. 38 To see this, we can first set a ψ = 0, in which case S CS(−) = 0 because a extends to a flat gauge field along D 2 . The deformation by a flat connection corresponds to a shift by a well-defined one-form δa, and the shift in the CS action is given by the three-dimensional formula δa ∧ da. 39 In the general case, we have: with x ∈ H 1 (M 3 , Z 2 ) encodes the change of spin structure between M + 3 and M − 3 [78].

D. Localization and JK contours
In this Appendix, we sketch the derivation of the final formula (4.73) for p = 0, using supersymmetric localization. The derivation is very similar to the p = 0 discussed in Appendix B of [22], apart from subtleties regarding the contribution from infinity on the u-plane. We focus on the case where the gauge group has rank one. The generalization to any higher-rank gauge groups should follow from the previous works-see [29,30] and [20,31,21,22], except for complications due to the contributions from the "boundaries" at infinity, which we did not study rigorously. We presented a conjecture in the main text, and we provide some additional evidence for it below (see section D.2).

D.1 Localization for G = U (1)
In Section 4.1, we saw that the SYM action (3.62) admits the following scalar and one-form zero modes in the vector multiplet: For p = 0, the variable u = iβ(σ + ia 0 ) is valued in C. In this "Coulomb branch" background, the partition function can be written as:: where M denotes the complex u-plane and Z m is the contribution from the one-loop determinant and the classical action contribution at flux sector m. We also have defined the measure 3) The normalization of the path integral is chosen for convenience. In the end, we fix the overall normalization by comparing our result against known results [22]. For future convenience, we perform the change of variable u → u and Λ 0 → Λ 0 according to with k some small real parameter (not to be confused with a CS level). Note that the contribution from the one-loop determinant and classical action Z m has singularities at {u|u = u * } in M where the chiral multiplets become massless. There also exists a potential singularity associated to the boundary at infinity. For singularities in the bulk, we first define the -neighborhood ∆ of these singularities as (u − u * )( u − u * ) ≤ 2 . Then, if we take the limit → 0 and e → 0 in a way that is sufficiently smaller than e, we can show that the integral gets contribution only from the region M\∆ . We will discuss the contribution from infinity below.
The integration over the scalar gaugino zero-modes Λ 0 , Λ 0 can be performed by using the following relation from the residual supersymmetry of zero-modes: which implies Since there are no singularities in a compact domain of α I as long as > 0, the second term which involves the total derivative ∂ α I does not contribute to the path integral. We have Here ∆ also implicitly includes an excised region "at infinity". The u-plane integral in (D.7) then reduces to a sum of contour integrals over all the components of the boundary ∂∆ . To evaluate Z m for non-zeroD, we first expand the fields into the Fourier modes along the S 1 fiber: φ = n∈Z φ n (z,z)e inψ . (D.8) Let us define the two-dimensional variables (until (D.24) we consider the generalization to higher rank, as it is essentially the same argument): Qσ n = 1 iβ (Q a u a + n) , Q σ n = − 1 iβ (Q a u a /k 2 + n) . (D.9) At fixed n, we can have the spectrum {λ n } of the twisted Laplacian D 1 D1 on the two-dimensional base Σ g , with: −4D 1 D1φ n (z,z) = λ n φ n (z,z) . (D.10) Recall that the scalar φ n is valued in the line bundle (4.39). The contribution from the full chiral multiplet is given by: where the first factor is the contribution from the zero modes of D1 (or D 1 ): (D.12) Here n B and n C are the number of B n and C n zero-modes, respectively, with n B − n C = pn + Qm + (g − 1)(r − 1) by the Riemann-Roch theorem. Evaluating (D.12) atD = 0 gives the 1-loop determinant (4.36). Since the non-zero modes pair among themselves, they do not contribute in the limitD = 0. WhenD = 0, the contribution can be written as: n∈Z λn λ n + Q σ n Qσ n λ n + Q 2 σ n σ n + iQD × 1 − 2i (Q σ n )(Q Λ1)(QΛ 1 ) (λ n + Q 2 σ n σ n )(λ n + Q σ n Qσ n + iQD) . (D.13) The zero modes have singularities at finite u = u * i where the hypermultiplets with charge Q i become massless, as well as at the infinite boundary |u| → ∞. Each singualrity defines a "hyperplane" H i or H ∞ respectively.
First of all, let us consider the contour for theD-integral in (D.7). In order to ensure convergence of the integral, we define the contour Γ by R + iδ, where δ is a real number that satisfies |δ| < |Q i 2 /k 2 | for all singular hyperplane H i 's. The sign of δ is determined by the condition η(δ) > 0, where η ∈ ih * ∼ = R is a covector that we choose. The final answer does not depends on the choice of η.
Let us first integrate out the one-form zero modes Λ I , Λ I and the flat connections on the base Σ g . This procedure is the same as in the p = 0 case. We take the limit k so that the summation over the modes that couples to Λ I , Λ I can be simplified: For this, we note that log Z Φ | s-th order inD a (D.14) In the small k limit (large σ n limit), only the small t expansion of the heat kernel, λn e −tλ = 1 4πt ∞ l=0 a l t l , (D. 15) contributes for fixed n. Performing the t integral, we obtain log Z Φ | s-th order inD a Λ1=Λ 1 =0 = n a 0 (−iQ) s 4π(s − 1)(Q 2 σ n σ n ) s−1 + a 1 (−iQ) s 4πs(Q 2 σ n σ n ) s + · · · . (D.16) Therefore, in the limit k → 0, we are left with the following Λ 1 , Λ1 andD dependence: where: 40 This can be written as: (D. 19) in terms of the contribution of the chiral multiplet to the twisted superpotential. The dependence of the the classical action on the gauginos is also consistent with this expression: from the classical action. (Here we gave the formulas for the higher-rank case as well.) Note that the one-loop and classical contributions do not depend on the flat connections α I , α I . We have g I=1 dV I Z m | Λ 0 = Λ 0 =0 = H(u) g Z m | Λ 0 = Λ 0 =Λ 1 = Λ1=0 (D. 21) after integrating over the gaugino zero-modes Λ 1 , Λ1, where we have defined: The final formula can be written as where the summation runs over all the bulk singularities: (D.24) 40 Note that the regularization used in [22] is different from that we are using here. See Section 4.3.2. Figure 8: We define the u-contour at infinity by lim R→∞ C R , where C R is given on the left. This contour can be decomposed into lim R→∞ C R = k∈Z C k , a sum over an infinite number of contours around the strips of unit width, as shown on the right. and the contribution from the monopole singularities (D.25) We define the contour at infinity C R as shown on the left in Figure 8. One can show that, once we take the limit R → ∞ sufficiently faster than e → 0 so that e N R → ∞, the integral (D.2) does not get any contribution from the region outside of the contour C R . (To show this, we generally need to turn on the regulator, as in [20].) The easiest way to perform these integrals is to use the topological property of the theory on Σ g . Using the fact that the final answer does not depend on the vol(Σ g ), we rescale it with a positive real µ 1:D → µD , vol(Σ g ) → µ −1 vol(Σ g ) . (D.26) Let us take the limit µ → 0, keeping e finite. We have Let us first assume Im(∂ u W) > 0. Then we may close the contour in the upper-half D plane. If η > 0, this contour surrounds no poles, so the result of the integral is zero, while for η < 0, it surrounds the pole atD = 0, and picks up the residue there.
Similarly, for Im(∂ u W) < 0, we close the contour in the lower half-plane, and get a contribution only when η > 0. Thus we find: Let us choose η > 0 below for definiteness. For the bulk singularities, this rule picks up the residues from the poles with positive charges, as in the p = 0 case: (D.29) As discussed in Section 4, using the invariance under u → u + 1 , m → m + p , (D. 30) we can further massage this expression into (D.31) The contribution from the "poles at infinity" does not directly follows from the p = 0 case, since the geometry of the boundary at infinity is different. We have where the contour C R has been replaced by: The contour C R consists of horizontal segments and vertical segments. For the horizontal segments, where Im(u) = ±R → ±∞, one finds: Im(∂ u W) ∼ Q ∓ (Im(u)) , (D. 34) where Q ± are the monopole charges defined in (2.40). Thus the contributions along the horizontal segments are included in the final contour, C η R , precisely when the sign of the monopole charge is the same as η, just as in the p = 0 case. If Q ∓ = 0, the sign of Im(∂ u W) is determined by the flavor symmetry parameters, as discussed in an example in Section 4.5.2. Next, consider the vertical segments of C R , where Re(u) = ±R → ±∞. Recall that: Z(u + n) = Π(u) −pn Z(u) , (D. 35) and therefore: |Z(u + n)| = |Π(u)| −pn |Z(u)| = e 2πpnIm(∂uW) |Z(u)| .
(D. 36) Suppose first that we take η > 0. Then see that, for Re(u) → ∞, the portions of the vertical line we are including, those with Im(∂ u W) < 0, have vanishing contribution. Thus we can ignore the vertical line on the right. However, the vertical line on the left, at Re(u) → −∞, has a large contribution, and can not be ignored. Similarly, for η < 0, we must include the vertical line on the right. It is also useful to write this expression in a way which clarifies the connection to the p = 0 case. Starting from the contour C R , we decompose it into a sum over an infinite number of contours C n , where C η n is the portion of C n with sign Im(∂ u W(u)) = − sign η. Noting that the (D.32) is invariant under the (D.30), we can rewrite it as: (D. 39) In this formulation, the domain of the integration and of the sum is the same as in p = 0 case, but with a different integrand. (Note that, for p = 0, the integrand is periodic, and so the contributions along the vertical lines in C η 0 cancel.)

D.2 Relation of the JK contour to the Bethe-vacua formula
Here we derive the Bethe-vacua formula (2.48) for the M g,p partition function from the conjectured "JK contour" integral (4.80) for higher-rank gauge groups. This provides some non-trivial evidence for the conjectured contour. The higher-dimensional contour integral (4.80) takes the form: (D.40) Consider the sum over all m ∈ Z r . Let us split the sum as: Note that along C η δ 0 , we have, for each a: |Π a | δ a = e −2πδ a Im(∂aW) = e −2π|Im(∂aW)| < 1 (D. 46) where we used the fact that sign(Im(∂ a W)) = δ a due to (D.44). Thus the sum over m δ a a is a convergent geometric series. Using: Summing over all choices of δ a , we have: Now we use the independence of the answer on η, and consider taking η → η for 0 < 1. Note that, in this limit, the boundary contributions become negligible, since the interval in (4.112) includes a vanishingly small range of values of Im(∂ a W), and so C η 0 ≈ C η, bulk 0 . Thus, what remains are the contours at: Im(∂ ua W) = ± η a . (D.51) Given their relative orientations, from (D.50), the contributions from these nearby contours cancel everywhere except in the neighborhood of the singularities in (D.49) at Π a = 1. The integral then captures the residues at the simultaneous solutions to: Π a = 1, a = 1, · · · , r , (D. 52) i.e., the solutions to the Bethe equations. Then, by an argument identical to the one leading to (4.118), summing the residues leads to the formula (2.48), given by a sum over Bethe vacua.
E. Gauging flavor symmetries using the on-shell W and Ω In this appendix, we describe in more detail the procedure of gauging global symmetries at the level of the M g,p partition function. As discussed in Section 2.6, this is achieved most easily by working with the on-shell twisted superpotential and effective dilaton: W l (ν), Ω l (ν), l = 1, ..., |S BE | (E.1) Namely, suppose one is given these objects for a three dimensional N = 2 theory T , but one does not have any other information about the theory (e.g., a Lagrangian description). Then, as explained in Section 2.6, we may nevertheless use these to construct the M g,p partition function Z Mg,p [T ]. Moreover, for any theoryT obtained from T by gauging flavor symmetries, we can use this data to construct the on-shell superpotential and effective dilaton forT , and therefore also its M g,p partition function. Let us recall here how this gauging operation works, and elaborate on some of the details. Suppose the theoryT is obtained by gauging the flavor symmetry associated to some subset S of the flavor symmetry generators, whose parameters we relabel ν i → vâ, a = 1, ..., |S|. 41 Then we claim that we should simply write the Bethe equation for vâ, in terms of W l , i.e.: That is, the setŜ BE of Bethe vacua ofT is: ∂W l ∂vâ vâ=v l,ĵ a = 1 .

(E.3)
An important consistency check of this procedure is the following. Suppose we are told the on-shell objects in (E.1) actually come from a gauge theory. That is, they were obtained by starting with a twisted superpotential, W(u, v, ν), which is a function of some gauge variables, u a , a = 1, ..., rk(G), and solving the Bethe equations: ∂W(u l , v, ν) ∂u a = 0, a = 1, ..., rk(G) , (E.4) such that: Then, another way to obtain the theoryT is to gauge all the variables u a , vâ at once. In that case, we would find the Bethe equations: exp 2πi ∂W ∂u a = 1, exp 2πi ∂W ∂vâ = 1 (E.6) which we should solve simultaneously as a function of the u a and vâ. This procedure must lead to the same Bethe vacua and M g,p partition function as we obtained by starting from (E.1). First, to see that we get the same set of vacua, note that if we solve the first set of equations in (E.6) as a function of u a , and for fixedû a , we find the solutions u l a in (E.5). Next, we can plug in the u l a , where we consider all choices of l, and find theûâ which solve the second set of equations in (E.6), that is: However, from (2.56), the RHS is equal to Π l a , and so this is equivalent to solving (E.2). It remains to check that the various ingredients in the M g,p partition function that we obtain by the two methods agree. For the fibering and flux operators, this follows straightforwardly from (2.56). For the handle gluing operator, if we gauge u a and vâ simultaneously, we find, forl ∈Ŝ BE : On the other hand, starting from W l and Ω l and solving the Bethe equations for the vâ, we would find, in the notation of (E.3): H l,j (ν) = e Ω l (v,ν) det ∂W l ∂vâ∂vb vâ=v l,ĵ a = e Ω(u,v,ν) det ∂W ∂u a ∂u b u=u l det ∂W l ∂vâ∂vb v=v l,j (E.9) At first sight, the expressions (E.8) and (E.9) look quite different. To see that they agree, let us first introduce the notation: We differentiate (2.55) to find: Plugging this into (E.12) gives: and so the determinants in (E.9) can be written as: agreeing with (E.11) (after identifying the solution corresponding tol with that corresponding to the pair (l, j)), and completing the proof that (E.8) agrees with (E.9).