Mean square over auxiliary quadratic twists
There is an absolute $C>0$ with the following property. Fix $0<\varepsilon\le1$ and $A\ge1$. For all sufficiently large $Y$, let $m>0$, $8\mid m$, $(a,m)=1$, and $U>0$ satisfy $$\tfrac14(\log Y)^2\log m\le\log U,\qquad Y^{\varepsilon/6}\le\log U\le Y^{\varepsilon/5}(\log Y)^2.$$ Assume every prime divisor $p$ of $m$ satisfies either $p\le Y^{\varepsilon/5}$ or $p>(Y^A)^{400}$. Set $Z=(Y^A)^{400}$ and $P=\{q\text{ prime}:\sqrt U<q\le U,\ q\equiv a\pmod m\}$. For $Y\le y\le Y^A$ and any $\kappa:\mathbb N\to\mathbb C$ with $|\kappa(n)|\le1$, $$\sum_{q\in P}\left|\sum_{1\le n\le Z}\Lambda(n)\min(1,y/n)\kappa(n)\left(\frac n q\right)\right|^2\le C y\log y\,|P|.$$ Here $\Lambda$ is the von Mangoldt function and the parenthesized symbol is the Jacobi symbol.
The threshold for $Y$ may depend on $\varepsilon$ and $A$, and is uniform in the progression and bounded coefficients.
This controls averages over the auxiliary primes used to choose the quadratic twists.