  This paper addresses the problems of quantum spectral curves and 4D limit for
the melting crystal model of 5D SUSY $U(1)$ Yang-Mills theory on
$\mathbb{R}^4\times S^1$. The partition function $Z(\mathbf{t})$ deformed by an
infinite number of external potentials is a tau function of the KP hierarchy
with respect to the coupling constants $\mathbf{t} = (t_1,t_2,\ldots)$. A
single-variate specialization $Z(x)$ of $Z(\mathbf{t})$ satisfies a
$q$-difference equation representing the quantum spectral curve of the melting
crystal model. In the limit as the radius $R$ of $S^1$ in $\mathbb{R}^4\times
S^1$ tends to $0$, it turns into a difference equation for a 4D counterpart
$Z_{\mathrm{4D}}(X)$ of $Z(x)$. This difference equation reproduces the quantum
spectral curve of Gromov-Witten theory of $\mathbb{CP}^1$. $Z_{\mathrm{4D}}(X)$
is obtained from $Z(x)$ by letting $R \to 0$ under an $R$-dependent
transformation $x = x(X,R)$ of $x$ to $X$. A similar prescription of 4D limit
can be formulated for $Z(\mathbf{t})$ with an $R$-dependent transformation
$\mathbf{t} = \mathbf{t}(\mathbf{T},R)$ of $\mathbf{t}$ to $\mathbf{T} =
(T_1,T_2,\ldots)$. This yields a 4D counterpart $Z_{\mathrm{4D}}(\mathbf{T})$
of $Z(\mathbf{t})$. $Z_{\mathrm{4D}}(\mathbf{T})$ agrees with a generating
function of all-genus Gromov-Witten invariants of $\mathbb{CP}^1$. Fay-type
bilinear equations for $Z_{\mathrm{4D}}(\mathbf{T})$ can be derived from
similar equations satisfied by $Z(\mathbf{t})$. The bilinear equations imply
that $Z_{\mathrm{4D}}(\mathbf{T})$, too, is a tau function of the KP hierarchy.
These results are further extended to deformations $Z(\mathbf{t},s)$ and
$Z_{\mathrm{4D}}(\mathbf{T},s)$ by a discrete variable $s \in \mathbb{Z}$,
which are shown to be tau functions of the 1D Toda hierarchy.
