# Small-scale radio jets and tidal disruption events: A theory of high-
luminosity compact symmetric objects

Andrew G. Sullivan1, Roger D. Blandford1, Mitchell C. Begelman2,3, Mark
Birkinshaw4, Anthony C.S. Readhead5
1Kavli Institute for Particle Astrophysics and Cosmology, Department of
Physics, Stanford University, Stanford, CA 94305, USA
2JILA, University of Colorado and National Institute of Standards and
Technology, 440 UCB, Boulder, CO 80309-0440, USA
3Department of Astrophysical and Planetary Sciences, University of Colorado,
391 UCB, Boulder, CO 80309-0391, USA
4School of Physics, H.H. Wills Physics Laboratory, University of Bristol,
Tyndall Avenue, Bristol BS8 1TL, UK
5Owens Valley Radio Observatory, California Institute of Technology, Pasadena,
CA 91125, USA E-mail<EMAIL_ADDRESS>
(Accepted 2024 January 24. Received 2024 January 23; in original form 2023
December 7)

###### Abstract

Double lobe radio sources associated with active galactic nuclei represent one
of the longest studied groups in radio astronomy. A particular sub-group of
double radio sources comprises the compact symmetric objects (CSOs). CSOs are
distinguished by their prominent double structure and sub-kpc total size. It
has been argued that the vast majority of high-luminosity CSOs (CSO 2s)
represent a distinct class of active galactic nuclei with its own
morphological structure and life-cycle. In this work, we present theoretical
considerations regarding CSO 2s. We develop a semi-analytic evolutionary
model, inspired by the results of large-scale numerical simulations of
relativistic jets, that reproduces the features of the radio source
population. We show that CSO 2s may be generated by finite energy injections
and propose stellar tidal disruption events as a possible cause. We find that
tidal disruption events of giant branch stars with masses $\gtrsim 1$ M⊙ can
fuel these sources and discuss possible approaches to confirming this
hypothesis. We predict that if the tidal disruption scenario holds, CSO 2s
with sizes less than 400 pc should outnumber larger sources by more than a
factor of $10$. Our results motivate future numerical studies to determine
whether the scenarios we consider for fueling and source evolution can explain
the observed radio morphologies. Multiwavelength observational campaigns
directed at these sources will also provide critical insight into the origins
of these objects, their environments, and their lifespans.

###### keywords:

galaxies: jets – radio continuum: galaxies – galaxies: active – radio
continuum: transients – (galaxies:) quasars: supermassive black holes –
(stars:) supergiants

††pubyear: 2024††pagerange: Small-scale radio jets and tidal disruption
events: A theory of high-luminosity compact symmetric objects–LABEL:lastpage

##  1 Introduction

Compact Symmetric Objects (CSOs) represent a class of compact ($<1$ kpc)
bright double radio sources, in which the radio lobes straddle the active
galactic nucleus (AGN) (Wilkinson et al., 1994; Readhead et al., 1996). There
are two fundamentally different types of CSOs: an edge-dimmed, low-luminosity
class (CSO 1) and and edge-brightened high-luminosity class (CSO 2) (Tremblay
et al., 2016). This paper focuses on CSO 2s.

While some CSO 2s may be early stage Fanaroff-Riley-type (FR) double radio
sources (Fanaroff & Riley, 1974), it has been suggested that CSO 2s represent
a separate class of AGN with different driving mechanisms and morphological
history (Readhead et al., 1994, 1996; Readhead et al., 2024). Such
distinctions are manifest in the sizes and ages of CSO 2s relative to their FR
counterparts (Kiehlmann et al., 2024a). Namely, specific CSO population
analyses (Kiehlmann et al., 2024b, a) have shown that there exists a sharp
size cutoff above 500 pc. The size cutoff and their rapid hot spot separation
speeds $\sim 0.3c$ (Owsianik & Conway, 1998; Owsianik et al., 1999) suggest
that CSO 2s generally have short $\lesssim 10^{4}$ yr lifespans.

Based on morphology, the CSO 2 class may be subdivided into three sub-classes:
CSO 2.0s, CSO 2.1s, and CSO 2.2s (Readhead et al., 2024). Readhead et al.
(2024) argue that these three classes may represent the temporal evolution of
CSO 2 objects, with CSO 2.0s as early life sources, CSO 2.1s as mid-life
sources, and CSO 2.2s as late life sources. Because of the short lifetimes and
low total energies of CSO 2s relative to FR Is and FR IIs, Readhead et al.
(2024) propose that tidal disruption events (TDEs) may be associated with CSO
2s, as had first been suggested by Readhead et al. (1994). Beyond the
qualitative discussion of Readhead et al. (2024), a coherent theoretical model
of the evolution of CSO 2s has yet to be proposed in light of this recent
work.

Continuing the work of Readhead et al. (2024), we develop a theory of CSO 2
evolution, and discuss the open questions that observational campaigns can
answer. We model the propagation of CSO 2 jets into their environment and
consider their fueling mechanism, particularly the TDE scenario, as well as
host galaxy environments. In Sec. 2, we summarize the recent work on CSO 2s
motivating this paper. In Sec. 3, we describe the possible evolutionary model
for CSO 2s and the features of CSO 2 morphological evolution. In Sec. 4, we
discuss the absence of CSO 2s larger than $500$ pc and its potential
relationship to host galaxy environments. In Sec. 5, we assess TDEs as a
candidate fueling mechanism for CSO 2s, before concluding in Sec. 6.

##  2 Summary of Compact Symmetric Object Observations

CSO 2s are distinguished from other jetted AGN by their double lobe
morphology, small sizes, and lack of features indicative of relativistic
beaming towards the observer. Historically, double lobe sources with sizes
less than 1 kpc have been classified as CSOs, distinguishing them from medium
symmetric objects (MSOs) with sizes $1-20$ kpc, and large symmetric objects
(LSOs) with sizes greater than 20 kpc (Fanti et al., 1995; Readhead et al.,
1996). Recently, Kiehlmann et al. (2024b, a); Readhead et al. (2024) presented
an updated catalog of CSO 2s after introducing additional classification
criteria to explicitly exclude blazars that mimic the compact double
structure: 1) that source variability be slower than the light travel time
across the emitting region and 2) that apparent superluminal motion in the
source not exceed $2.5c$.

The updated CSO catalog includes 79 bona fide CSO 2s, 54 of which have
measured spectroscopic redshifts (Kiehlmann et al., 2024b). The distribution
of sizes of the bona fide CSO 2s cuts off sharply, well below 1 kpc, and
signals a discontinuity in the size distribution of doubles around the CSO-MSO
boundary. While CSO 2s have often been considered the early life versions of
larger FR objects, they make up a much larger fraction of radio surveys than
expected from a uniform size distribution (Kiehlmann et al., 2024a). In fact,
fewer than $5\%$ of CSO 2s should evolve into the larger double radio sources
to respect the population statistics of MSOs and LSOs (Kiehlmann et al.,
2024a).

The updated Kiehlmann et al. (2024b) bona fide CSO catalog bifurcates into 11
CSO 1s and 43 CSO 2s with spectroscopic redshift (Readhead et al., 2024).
Lower power and smaller than CSO 2s, the CSO 1s have few common features
across the sample. The CSO 2s are roughly evenly distributed into 2.0s, 2.1s,
and 2.2s (Readhead et al., 2024). CSO 2.0s have narrow lobes and prominent
terminal hot spots in contrast to CSO 2.2s with wider lobes and no hot spots.
CSO 2.1s represent a hybrid between CSO 2.0s and CSO 2.2s, containing features
of both classes. The classified CSO 2.0s are by and large brighter and smaller
than CSO 2.2s, with CSO 2.1s intermediate between the two. CSO 2.0s possess
large hot spot separation speeds $\sim 0.3c$, while those of CSO 2.2s are
negligible. The standing hypothesis is that the CSO 2.0-2.1-2.2 paradigm maps
the early, middle, and late stages of CSO 2 evolution (Readhead et al., 2024).
We sketch the CSO evolutionary sequence in Fig. 1.

The CSO 2 luminosity-size distribution (Fig. 1 in Readhead et al. 2024)
broadly shows an increase in luminosity with size among CSO 2.0s. This
observed increase is not intrinsic, and results from the angular size cutoff
at 4 milliarcseconds as well as the CSO luminosity function (Readhead et al.,
2024). Classic FR-II models propose that luminosity $L$ should decrease with
size $D$ as $L\propto D^{-1/2}$ (Reynolds & Begelman, 1997; Kaiser et al.,
1997). Should this relationship persist from the smallest FR-IIs ($\sim 10$
kpc) down to the smallest CSO 2s ($\sim 10$ pc), one would expect 10 pc-sized
CSO 2s with luminosities a factor of $\sim 30$ brighter than the brightest FR-
IIs ($\sim 10^{29}$ W/Hz). The absence of these sources in the known samples
implies that the luminosities of double radio sources must generally increase
with size, and by extension time, for at least some portion of their early
evolution. Consequently, the luminosities of CSO 2s (including those which
develop into MSOs and LSOs) likely increase initially but fade at later times.

Figure 1: A diagram of the proposed evolutionary sequence of CSO 2s based on
their radio morphology. The core is represented by the black circle. The radio
lobes, which increase in size through the sequence, contain narrow jets
represented in yellow and hot spots when young at early times. These fade
while the lobes become more turbulent. See Fig. 2 for a more detailed look at
the CSO 2.0 case.

##  3 Evolutionary Model of Compact Symmetric Objects

###  3.1 Early life

Figure 2: A detailed diagram of CSO 2.0s as modeled. The jet and inner cocoon
radii are each labeled. We indicate the height of the recollimation shock. The
red outer layer represents the shocked external medium.

Early life CSO 2s appear to evolve analogously to the larger and longer-lived
classical FR-II objects. Their edge-brightened lobes with prominent hot spots
are consistent with typical features of a relativistic jet propagating into
the external medium. Classic jet models suppose that the jet collides with the
ambient medium, forming a contact discontinuity between a forward and a
reverse shock (Begelman et al., 1984; Falle, 1991; Kaiser & Alexander, 1997;
Bromberg et al., 2011, e.g.). The material in the reverse shock becomes
deflected upstream into a cocoon around the jet. The cocoon also produces
synchrotron radiation, and accounts for dimmer radio emission upstream of the
hot spots (Begelman et al., 1984; Readhead et al., 1996). The jet power
$L_{j}$ determines how rapidly the jet pushes into the external medium. By
analogy, CSO 2.0s should possess the aforementioned properties (Begelman,
1996). The radio hot spots of early life CSO 2s represent the working surface
of the jet where particle heating and magnetic field amplification occur
(Begelman et al., 1984), while a cocoon forms around the narrow jet.

####  3.1.1 Relativistic Jet Model

Because early-life CSO 2s exhibit features so similar to those of classical
FR-II sources, we apply the Bromberg et al. (2011) unmagnetized and gas
pressure collimated jet model. The jet working surface, whose height we denote
by $\zeta_{j}(t)$, advances with speed (Bromberg et al., 2011)

$v_{h}\approx\sqrt{\frac{L_{j}}{\rho_{a}A_{j}c}},$ (1)

where $\rho_{a}$ is the ambient density of the external medium, $A_{j}$ is the
cross sectional area of the jet, and $c$ is the speed of light. The cocoon
pressure $P_{c}$ collimates the initially conical jet, forming a shock, above
which the now cylindrical jet has radius $r_{j}$ so that $A_{j}=\pi
r_{j}^{2}$. The height of the collimation shock expands along the Mach cone as
(Bromberg et al., 2011)

$\hat{\zeta}=\sqrt{\frac{L_{j}}{P_{c}\pi c}}.$ (2)

The collimation radius $r_{j}$ can be approximated as
$r_{j}=1/2\theta_{0}\hat{\zeta}$, where $\theta_{0}$ is the initial jet
opening angle (Bromberg et al., 2011). The cocoon pressure is

$P_{c}=\frac{1}{3}\frac{E(t)}{\pi r_{c}^{2}\zeta_{j}},$ (3)

where $E(t)$ is the energy deposited into the cocoon and $r_{c}$ is its
radius. $P_{c}$ balances the external medium ram pressure, giving (Begelman &
Cioffi, 1989; Bromberg et al., 2011)

$v_{c}=\sqrt{\frac{P_{c}}{\rho_{a}}}$ (4)

as the expansion rate of $r_{c}$.

Eq. 1, 2, 3, and 4 can be arranged into a system of differential equations for
the height and cross-sectional areas of the cocoon and jet

$\frac{d\zeta_{j}}{dt}=\sqrt{\frac{L_{j}}{\rho_{a}A_{j}c}},$ (5a)
$\frac{dA_{c}}{dt}=2\sqrt{\frac{\pi E(t)}{3\zeta_{j}\rho_{a}c}},$ (5b)
$A_{j}=\frac{3}{4}\theta_{0}^{2}\frac{L_{j}}{E(t)c}A_{c}\zeta_{j},$ (5c)

with $A_{c}=\pi r_{c}^{2}$ as the cocoon cross-sectional area. In a real
source, $A_{j}$ may be wider if the hot spot wiggles around as in Cygnus A.
Note that $dA_{c}/d\zeta_{j}=\theta_{0}\sqrt{\pi A_{c}}$ has solution
$A_{c}=1/4\pi\theta_{0}^{2}\zeta_{j}^{2}$ and allows eq. 5 to simplify to

$\frac{d\zeta_{j}}{dt}=4\sqrt{\frac{E(t)}{3\pi\rho_{a}\theta_{0}^{4}\zeta_{j}^{3}}}.$
(6)

In practice, this is an upper limit on the expansion speed because of the
possible variation in $A_{j}$.

Because CSO luminosity increases with size, CSO 2.0 jet power may increase in
kind. Therefore, we give the CSO jet power $L_{j}$ the phenomenological
profile

$L_{j}(t)=\begin{cases}L_{max}\left(\frac{t}{t_{0}}\right)^{p_{1}}&t<t_{0}\\\
L_{max}\left(\frac{t}{t_{0}}\right)^{-p_{2}}&t>t_{0}\end{cases}.$ (7)

Integrating eq. 7 gives the energy deposited by the jets into the cocoon as a
function of time $E(t)$.

Solving eq. 6 with $E(t)$ and a prescription for the ambient density profile
gives the height of the working surface as a function of time. For
$\rho_{a}=\rho_{0}(\zeta_{0}/\zeta)^{a}$, the jet has a characteristic scale
height
$\zeta_{s}\equiv\left(\frac{L_{max}t_{0}^{3}}{\pi\theta_{0}^{4}\rho_{0}\zeta_{0}^{a}}\right)^{\frac{1}{5-a}}$.
Illustrative parameters (e.g. $L_{j}=10^{44}$ erg s-1, $t_{0}=2500$ yr,
$\theta_{0}=10^{\circ}$, $a=1$, and $\rho_{a}=10^{-23}$ g cm-3 at
$\zeta_{0}=5$ pc) give $\zeta_{s}\approx 190$ pc and $v_{h}\approx 0.15c$,
which are consistent with the observations.

####  3.1.2 Alternative Jet Models

The model we have considered above is purely hydrodynamic (Falle, 1991; Kaiser
& Alexander, 1997; Bromberg et al., 2011; Harrison et al., 2018), although
large-scale magnetically collimated jet models exist (Lovelace et al., 2002;
Lyubarsky, 2009, 2011; Globus & Levinson, 2016; Zdziarski et al., 2022). We
appeal to a simpler hydrodynamic picture since only two CSO 2s (J0741+2706 and
J1326+3154) have observed rotation measures (Gugliucci et al., 2007; Tremblay
et al., 2016). The polarized regions are concentrated at the heads and have
diameters $<10$ pc and magnetic fields $<10$ $\mu$G perpendicular to the
propagation direction. Additionally, neither of these sources is classified as
a CSO 2.0 (Readhead et al., 2024). While obscuring tori may surround and
decohere the large-scale polarized emission, low polarization in these
examples make a purely hydrodynamic model adequate at this stage.

####  3.1.3 Ballistic Projectile Model

An alternative possible model for early life CSO 2.0s posits that rather than
being active jets, the hot spots represent energetic projectiles ejected from
the core by a powerful fueling event. In this picture as we envision it, the
projectiles, packets of energized plasma injected into the external medium,
are produced rapidly by a short-lived jet of negligible duration compared to
the CSO lifetime and propagate at near relativistic by their own inertia. We
suppose that the projectiles are subsequently confined and decelerated by the
external ram pressure as first considered by De Young & Axford (1967) in the
context of Cygnus A. While this model is inadequate for FR-IIs with visible
jets, it may apply to some CSO 2.0s which lack obviously visible jets and have
small sizes. The acceleration is
$\dot{v}_{p}\approx-\rho_{a}v_{p}^{2}A_{p}/M_{p}$, where $v_{p}$ is the upward
velocity, $A_{p}$ is the cross-sectional area, and $M_{p}$ is the mass. The
time over which the projectile decelerates to the ambient sound speed from $c$
will be

$\begin{split}t\approx&1000\text{ yr}\\\ &\times\left(\frac{M_{p}}{1\text{
}M_{\odot}}\right)\left(\frac{r_{p}}{10\text{
pc}}\right)^{-2}\left(\frac{\rho_{a}}{10^{-24}\text{ g
cm}^{-3}}\right)^{-1}\left(\frac{c_{s}}{250\text{
km/s}}\right)^{-1},\end{split}$ (8)

where $r_{p}$ is the radius of the projectile and $c_{s}$ is the ambient sound
speed, while the height above the core will be

$\begin{split}\zeta\approx 0.2\text{ pc}\left(\frac{M_{p}}{1\text{
}M_{\odot}}\right)\left(\frac{r_{p}}{10\text{
pc}}\right)^{-2}\left(\frac{\rho_{a}}{10^{-24}\text{ g
cm}^{-3}}\right)^{-1}\ln\left(\frac{c}{c_{s}}\right).\end{split}$ (9)

To get properties commensurate with CSOs, small values of $r_{p}$ and
$\rho_{a}$ while high values of $c_{s}$ are needed. If $\rho_{a}(\zeta)$ falls
off steeply or the projectile area decreases, the deceleration rate slows,
allowing the projectile to propagate further into the medium. The lifetime as
a CSO 2.0 would depend on when the projectile experiences sufficient adiabatic
losses in electron energy.

###  3.2 Mid-life

By mid-life, CSO 2s must transition from nearly relativistic to transonic or
subsonic, bridging the CSO 2.0 through CSO 2.2 evolutionary paradigm. The hot
spot separation speed of CSO 2.0s ($\sim 0.3c$) corresponds to $v_{h}\approx
0.15c$, so the sonic Mach number is $v_{h}/c_{s}\approx 200$ with an ambient
sound speed of $c_{s}\approx 250$ km s-1. To respect the observed CSO age and
size cutoffs (Kiehlmann et al., 2024a), the Mach number must decrease to order
unity in time $t_{1}<10^{4}$ yr without the size increasing by a factor of
more than 5. While the sonic Mach number in Sedov-like expansion models (e.g.
Kompaneets, 1960; Eremin & Kovalenko, 1998; Olano, 2009) decreases too slowly,
the entrainment of thermal material and the eventual development of turbulence
through interface instabilities (Bicknell, 1994) can slow down jets
sufficiently. Mass loading, as has been proposed to explain the FR-I/FR-II
dichotomy in kpc-scale jets (Komissarov, 1994; Bicknell, 1994; Readhead et
al., 1996; Laing & Bridle, 2002; Perucho et al., 2014; Perucho, 2020; Anglés-
Castillo et al., 2021), may therefore partially account for the transition
from CSO 2.0 to CSO 2.2.

With an initial sonic Mach number $M_{0}\approx 200$ and for deceleration over
$1000$ yr, momentum conservation implies a mass-loading rate of $0.2$ M⊙ yr-1.
Assuming a mass entrainment rate $\dot{M}_{a}\approx
2\pi\rho_{a}r\zeta_{j}c_{s}$ from the external medium alone, $\rho_{a}\gtrsim
8\times 10^{-25}$ g cm-3 is sufficient to slow the expansion, compatible with
typical densities in the centers of elliptical galaxies (Capelo et al., 2010)
and of our CSO 2.0 environments. Conversely, taking main sequence B star mass-
loss rates of $\dot{M}_{\star}\approx 10^{-12}-10^{-9}$ M⊙ yr-1 (Krtička,
2014) as a fiducial value, the number of stars immersed in the lobes needed to
provide sufficient mass loading is $\sim 10^{11}-10^{8}$, not exceptionally
different from the number within the central kpc of the Milky way galaxy
(Schödel et al., 2018).

Mass-loading could be initiated by various instabilities (Matsumoto & Masada,
2013; Matsumoto et al., 2017; Abolmasov & Bromberg, 2023; Wang et al., 2023).
The lobes naturally expand into an interstellar medium (ISM) with fluctuating
density, especially if it is thermally unstable. Density may vary by multiple
orders of magnitude on pc scales due to clumping (Li & Bryan, 2014; Donahue &
Voit, 2022). The instabilities or density variations may cause shocks and
turbulent behavior. For stellar mass-loading, numerical simulations have shown
that comet-like tails form behind the star where the stellar wind mixes with
the jet (Perucho & López-Miralles, 2023). Particle acceleration at the mixing
sites (Bednarek & Protheroe, 1997; Torres-Albà & Bosch-Ramon, 2019) or jet-
induced disruption of the immersed stars (Bosch-Ramon et al., 2012) can cause
gamma-ray flares, so high energy non-thermal transients from CSO 2s can
corroborate this model. The high surface brightness regions in the middle of
CSO 2.2 J0131+5545 (Lister et al., 2020; Readhead et al., 2024) may represent
the sites of an instability (Falle, 1991; Canto & Raga, 1991; De Young, 1993)
or possibly stellar mass-loading.

####  3.2.1 Discussion of CSO 2.1s

CSO 2.1s resemble both CSO 2.0s and CSO 2.2s and have been classified by
Readhead et al. (2024) as "mid-life". The catch-all nature of the CSO 2.1
class may include sources that are not necessarily mid-life. CSO 2.1s may
develop in asymmetrical environments with different density gradients or
nonzero ambient medium velocity, which can induce turbulent mixing in one jet
but not the other. Bearing in mind our currently limited understanding, our
model will simply assume that the speed at the end of the CSO 2.0 phase
decelerates at a constant rate to the sound external speed $c_{s}$. With
deceleration occurring from time $t_{1}$ to $t_{2}$, the distance to the
working surface from the central engine is

$\begin{split}\zeta(t)=\frac{c_{s}-v_{h}(t_{1})}{t_{2}-t_{1}}&\left(\frac{t^{2}-t_{1}^{2}}{2}-t_{2}\left(t-t_{1}\right)\right)\\\
&+v_{h}(t_{1})(t-t_{1})+\zeta(t_{1}).\end{split}$ (10)

We assume that the jet power is negligible at this stage, so the lobe energy
should be approximately the total energy of the fueling event.

####  3.2.2 Jet Inclination Bias in the CSO 2.1 Population

Because CSO 2.1s exhibit features common to both CSO 2.0s and 2.2s, some true
CSO 2.2s may be classified as CSO 2.1s due to the inclination of the radio
jets on the plane of the sky. If the jet axis is inclined to the sky plane,
one CSO lobe will be closer to Earth than the other, producing a small
difference in the radio emission travel time. While the CSO selection criteria
make it unlikely that CSO 2s are highly inclined to the sky plane, CSO
inclinations may reach as high as $45^{\circ}$ and fit selection criteria. The
delay in light travel time between the two sides should be $\Delta\tau=D\sin
i/c$, where $i$ is the angle between the jet axis and the plane of the sky.
The sky projected source size should be $D_{proj}=D\cos i$. In terms of
projected size, the time delay between the emission from the two lobes is
$\Delta\tau=D_{proj}\tan i/c$. With maximum $i=45^{\circ}$ and $D_{proj}\sim
600$ pc, an upper limit on the delay time is $\Delta\tau\sim 2000$ yr.
Assuming CSO 2s live for $10^{4}$ yr and spend $2/5$ of their lifetime as CSO
2.0s and CSO 2.2s and $1/5$ as CSO 2.1s, at most half of true CSO 2.2s would
be misclassified as CSO 2.1s due to the time delay. In the observed
distribution of 43 bona fide CSO 2s with spectroscopic redshifts, CSO 2.1s
make up a larger fraction of the CSO 2 population than CSO 2.2s, suggesting
that this bias may have some effect. For example, if CSO 2.0s and 2.2s each
intrinsically account for 40% of the CSO population, 35% of CSO 2.2s have been
misclassified as CSO 2.1s. This would suggest an average time delay of 1400 yr
across the population. The bias cannot affect the entire population because
CSO 2.1s make up more than $20\%$ (the maximum percentage of the source
lifetime affected by viewing inclination) of the observed CSO population.
Therefore, a true medium class of CSO 2s should exist.

###  3.3 Late Life

The apparent motion of CSO 2.2s is invisible, so their upward expansion is
likely transonic or subsonic. We suppose that CSO 2.2s correspond to
convectively rising turbulent plumes. In a convectively stable ambient medium,
the plume will reach a terminal height where the ambient and plume densities
equilibrate. The plume then spreads horizontally rather than vertically
(Morton et al., 1956), producing the mushroom cloud shape characteristic of
volcanic and other geophysical plumes (Woods, 2010). With a decaying ambient
density profile (e.g. $\rho_{a}=\rho_{0}\left(\zeta_{0}/\zeta\right)^{a}$),
this behavior should be generic. In fact, M87 displays similar features $\sim
20$ kpc from its core (Owen et al., 2000). In many CSO 2s, the equilibrium
height could be much closer to the core, even within the central kpc after
mass-loading. The lateral expansion of CSO 2.2s signals that they may have
already reached their equilibrium height.

Similar to plumes, some AGN show evidence of previous jet activity in the form
of coherent bubbles (Owen et al., 2000; Churazov et al., 2001; Nulsen et al.,
2002; Fabian et al., 2003), which rise at their terminal velocity (Churazov et
al., 2001; Irwin et al., 2019)

$v_{t}=\sqrt{2g\frac{V}{C_{d}A}\frac{(\rho_{a}-\rho_{b})}{\rho_{a}}}\approx
c_{s},$ (11)

where $g$ is gravitational acceleration, $V$ is the bubble volume, $C_{d}$ is
the drag coefficient, $A$ is the bubble cross-sectional area, $\rho_{a}$
remains the ambient density, and $\rho_{b}$ is the density inside the bubble.
Some CSO 2.2 images morphologically resemble simulations of rising bubbles
(Churazov et al., 2001; Reynolds et al., 2002; Sternberg & Soker, 2008; Huško
& Lacey, 2023). Although difficult to reconcile with mass-loading-induced
turbulence, bubbles may form, perhaps with the assistance magnetic draping
(Dursi & Pfrommer, 2008; Bambic et al., 2018), and spread laterally. This
would dilute the energy and explain the lack of large low power CSO 2.2s in
the Readhead et al. (2024) population.

####  3.3.1 Subsonic Rise and Disappearance of CSO 2.2s

A coarse model of subsonic CSO 2.2s has the lobes expand constantly at the
ambient sound speed. The duration of the CSO 2.2 phase must be comparable to
that of the other CSO phases to respect the population distribution observed
by Readhead et al. (2024). For reasons that remain unclear, CSO 2s must
disappear at a certain point. One possibility, which we consider and elaborate
on further in Sec. 4, is the existence of a steep density gradient at some
characteristic point in the host galaxies. The pressure of the ambient medium
and by extension the pressure inside the CSO will drop considerably, causing
the lobes to expand laterally and quickly form the mushroom cloud shapes
discussed previously. This would cause CSO 2s to rapidly fade and partially
facilitate the observed CSO size cutoff. The pressure surrounding a CSO may
drop by a factor $n$ when reaching this stage, so that $P_{2.2}=P(t_{2})/n$ or
alternatively, $V_{2.2}=n^{3/4}V(t_{2})$ (for an internal adiabatic index of
4/3). While the height may not change appreciably, $n^{3/4}$ accounts for the
factor by which the cross sectional area of the lobes increases above the
pressure drop. This idea is separate from the jet fueling scenarios we
consider and not mutually exclusive with those scenarios.

###  3.4 Numerical Realizations of the Model

We present the results of the toy model for CSO 2s we have outlined above. The
injection of a finite energy amount $E_{0}$ in a finite time gives rise to the
jet power profile in Sec. 3.1.1. The CSO 2s produce synchrotron radio emission
with equipartition radio luminosity

$L(t)=C(\alpha)V(t)^{-3/4}E(t)^{7/4},$ (12)

where $C$ is a numerical coefficient which is a function of the spectral index
$\alpha$, while $V(t)$ is the emitting volume, and $E(t)$ is the energy in the
CSO at time $t$.

We assume that CSO 2s evolve through the CSO 2.0–2.1–2.2 paradigm. In our
realization, we apply the active jet model for CSO 2.0s, lasting from $t=0$ to
$t=t_{1}$, with $t_{0}<t_{1}$. The source then becomes an inactive CSO 2.1
during $t_{1}<t<t_{2}$ and a CSO 2.2 when $t>t_{2}$. We compute the energy and
volume of CSO 2.0s in the manner described in Sec. 3.1.1. The volume of CSO
2.1s is $V\propto\zeta^{3}$ with $\zeta$ computed by eq. 10. For CSO 2.2s, we
implement the two different cases discussed in Sec. 3.3.1: 1) the volume of
the CSO evolves as $V\propto\zeta^{3}$ and 2) when CSO 2.1s transition to CSO
2.2s, the pressure drops by a factor $n$, corresponding to an increase in
cross-sectional area by a factor of $n^{3/4}$ without an increase in
$\zeta(t)$. In both cases, we set $\zeta(t)=c_{s}t+\zeta(t_{2})$.

Because the synchrotron cooling times are comparable to the source lifetimes,
we correct the energy available for CSO 2.1s and 2.2s. Assuming
$L=-\frac{dE}{dt}$, we integrate eq. 12 from $t_{1}$ to $t$, keeping the
volume fixed at $V(t_{1})$ (since CSO 2s grow more slowly in these phases),
and obtain the energy in the inactive jet phases

$E(t)=E_{0}\left(1+\frac{3}{4}\frac{L(t_{1})}{E_{0}}(t-t_{1})\right)^{-\frac{4}{3}},$
(13)

where $L(t_{1})$ is the value of eq. 12 evaluated at $t_{1}$. This is the
energy we substitute into eq. 12 and is less than $E_{0}$.

We choose a set of parameters to qualitatively reproduce the observed
distribution of CSO 2s on the $(P,D)$ plane as shown in Fig. 1 of Readhead et
al. (2024). We draw the timescales from uniform distributions with
$t_{0}\in\\{2000\text{ yr},3000\text{ yr}\\}$, $t_{1}\in\\{t_{0}+1000\text{
yr},t_{0}+3000\text{ yr}\\}$, and $t_{2}\in\\{t_{1}+2000\text{
yr},t_{1}+4000\text{ yr}\\}$. The ambient density profiles are set by
uniformly drawing $\rho_{a}\in\\{10^{-23}\text{ g cm}^{-3},10^{-22}\text{ g
cm}^{-3}\\}$ with $\zeta_{0}=5$ pc and $a=1$. We fix $p_{1}=4/3$ and
$p_{2}=5/3$. We fix the spectral index $\alpha=0.7$ and calculate the
luminosity at each simulated source’s synchrotron self-absorption frequency.
We set the ambient sound speed as $c_{s}=250$ km/s, which corresponds to an
ISM temperature $\sim 10^{7}$ K. To generate a population of CSO 2s, we draw
$E_{0}\in\\{0,10M_{\odot}c^{2}\\}$,
$\theta_{0}\in\\{10^{\circ},20^{\circ}\\}$, and $t\in\\{0,20000\text{ yr}\\}$,
uniformly. For the model in which CSO 2.2s experience a steep pressure drop,
we uniformly draw $n\in\\{0,100\\}$.

The populations of 1000 simulated CSO 2s along with the 43 bona fide CSO 2s
with spectroscopic redshifts are shown on the $(P,D)$ plane in Fig. 3.

Figure 3: The $(P,D)$ distribution of the real bona fide CSO 2 population
(Readhead et al., 2024) (left), our 4-phase toy model in which CSO 2.2 lobes
expand at the ambient sound speed (middle), and our model in which a large
drop in external pressure causes a proportionate increase in cross-sectional
area of CSO 2.2s (right). The dashed blue curve in the each panel show the
evolution of a model CSO with $E_{0}=5$ $M_{\odot}c^{2}$,
$\theta_{0}=15^{\circ}$, and all environmental properties set by their median
values.

Like the real population, there is a divide between CSO 2.0s which occupy the
upper-left portion of phase space, while CSO 2.2s occupy the lower-right
portion. We show the size distributions of our model CSO 2.0s and 2.2s in Fig.
4. Our model choices, particularly the maximum energy, recreate the size
distribution cutoff. Our choice of $a=1$, consistent with the observations of
CSO 2s, can also be approximately derived by assuming that the radiative
cooling time of the ambient gas is proportional to its infall time from height
$\zeta$ at fixed temperature. This assumption is broadly consistent with
observations of gaseous media in the centers of galaxies (Donahue & Voit,
2022).

Figure 4: The size distributions of the bona fide CSO 2.0 and 2.2 populations
(Readhead et al., 2024) (left), and the size distributions of our simulated
CSO 2.0 and 2.2 populations (right).

By design, the two proposed models have a different spread of CSO 2.2s across
the $(P,D)$ plane. The middle panel of Fig. 3 shows a buildup of CSO 2.2s very
near the CSO 2.1 population. In contrast, the model with a pressure drop shows
a broader spread of CSO 2.2s, placing some older CSO 2s firmly below the flux
limits of the surveys from which the real CSO population is gathered. The
model realizations might suggest host galaxy features at radii $\sim 100-1000$
pc which cause rapid lateral expansion and a commensurate drop in luminosity.
We elaborate on the hypotheses in Sec. 4.

##  4 The Disappearance of Compact Symmetric Objects

Our model in the center panel of Fig. 3 shows that CSO 2.2s should fade slowly
if embedded in an ambient medium with a continuous density gradient. Evolving
our population to times longer than $2\times 10^{4}$ yr gives an even larger
buildup of CSO 2.2s and causes CSO 2.2s to vastly outnumber CSO 2.0s,
incommensurate with the findings of Readhead et al. (2024). To respect the
observed population distribution, CSO 2s should fade rapidly without much
height increase. As the right panel of Fig. 3 shows, a sharp drop in ambient
pressure around when CSO 2s transition to CSO 2.2s can produce a broad spread
in the CSO 2.2 population, with particularly old CSO 2.2s ($>10^{4}$ yr)
disappearing below the survey flux limits (Kiehlmann et al., 2024b). Such a
rapid decrease in pressure, if real in some sources, may result from some
unique host galaxy feature. We propose two possible features which could cause
such a drop: 1) the rapid falloff in the stellar density around the galaxy
core radius and 2) the presence of shocks separating the inner core from the
exterior.

###  4.1 Stellar Distribution

Probes of the stellar distribution may be an excellent way to constrain the
ambient environment of CSO 2s. Near and beyond the Bondi radius, the stars are
sources of gravitational potential, magnetic fields, and additional outflowing
winds (Stark et al., 1991; Morris & Serabyn, 1996). Since the stellar
distribution in dense environments directly correlates with that of molecular
gas (Russeil et al., 2017, e.g.), the stellar distribution broadly
characterizes the ambient density. CSO galaxies may possess prominent cores
with radii $<1$ kpc, outside of which the stellar density drops substantially.
Knowledge of core Plummer radii, perhaps obtained from the mass to light
ratios in the interiors of CSO galaxies, would strongly constrain this model.

###  4.2 Shock Fronts

Alternatively, density and pressure jumps on account of the buildup of gas at
accretion shocks around the cores may affect CSO 2s. In this scenario,
infalling gas from galactic halos can cause the formation of shock fronts (van
de Voort et al., 2011; Coughlin, 2023, e.g.) separating the ISM and the core.
If these shocks manifest within the central kpc of CSO galaxies, CSO cocoons
could blow up upon crossing the density discontinuity. Excess filaments of Hα
emission in UV surveys (Venuti et al., 2014) or IR emission (Nenkova et al.,
2008) could point to the buildup of dust in the central kpc of the CSO
galaxies and represent tracers of core accretion shocks, should they exist.

##  5 Possible Driving Mechanism

###  5.1 Tidal Disruption Events

Readhead et al. (2024) have proposed that stellar tidal disruption events
(TDEs) could fuel CSO 2s. The small sizes, finite lifetimes, and relatively
low energies of CSO 2s suggest single catalyzing events as their sources,
making TDEs, well established jet launching events (Giannios & Metzger, 2011;
Kelley et al., 2014; Curd & Narayan, 2019; De Colle & Lu, 2020), a plausible
candidate. The synchrotron minimum energies $\gtrsim 1$ M${}_{\odot}c^{2}$ in
CSO jets are comparable to what a disrupted star can provide. The very large
SMBHs at the centers of CSO 2s have the ability to disrupt a variety of
stellar populations (Readhead et al., 2024); however, the estimated event
rates of TDEs and CSO 2s are not quite commensurate. We explore the time
scale, fueling, and event rate of CSO 2s in the following subsections.

####  5.1.1 Time Scale

The fallback time of the debris onto the central SMBH sets the timescale of a
TDE (Phinney, 1989; Strubbe & Quataert, 2009; Giannios & Metzger, 2011;
Metzger et al., 2012). The disruption is initiated when the star falls within
the tidal radius $r_{t}\approx R_{\star}(M_{BH}/M_{\star})^{1/3}$. The
disruption must happen outside the SMBH event horizon, so we may write $r_{t}$
as

$\frac{r_{t}}{r_{g}}=2.2\left(\frac{M_{BH}}{10^{8}\text{
}M_{\odot}}\right)^{-\frac{2}{3}}\left(\frac{M_{\star}}{1\text{
}M_{\odot}}\right)^{-\frac{1}{3}}\left(\frac{R_{\star}}{1\text{
}R_{\odot}}\right),$ (14)

where $r_{g}\equiv GM_{BH}/c^{2}$. The stellar encounter periapse radius
$r_{p}$ must satisfy $r_{p}<r_{t}$. The change in specific energy of the
stellar debris is $\Delta e\approx GM_{BH}R_{\star}/r_{p}^{2}\sim
GM_{BH}^{1/3}M_{\star}^{2/3}/R_{\star}$ for $r_{p}\sim r_{t}$. Therefore, the
bound debris will have apoapse distance $r_{a}\gtrsim
r_{\star}\left(M_{BH}/M_{\star}\right)^{2/3}$. The characteristic fallback
timescale for the debris is (Phinney, 1989)

$\begin{split}t_{f}\sim&\left(\frac{r_{a}^{3}}{GM_{BH}}\right)^{\frac{1}{2}}\\\
&\approx 0.5\text{ yr}\left(\frac{M_{BH}}{10^{8}\text{
}M_{\odot}}\right)^{\frac{1}{2}}\left(\frac{M_{\star}}{1\text{
}M_{\odot}}\right)^{-1}\left(\frac{R_{\star}}{1\text{
}R_{\odot}}\right)^{\frac{3}{2}}.\end{split}$ (15)

Before $t_{f}$, the mass accretion rate increases rapidly, and should follow
$\dot{M}\sim t^{-5/3}$ after $t_{f}$ (Phinney, 1989; Strubbe & Quataert, 2009,
e.g.). For main sequence stars, $t_{f}$ can be of order months to years (De
Colle & Lu, 2020). Some class of TDEs should have $t_{f}\gtrsim 1000$ yr for
the CSO-TDE hypothesis to hold. Giant branch stars with $R_{\star}>100$ R⊙
give values of $t_{f}\sim 1000$ yr for SMBH masses $\gtrsim 10^{8}$ M⊙. For
instance, a 1 $M_{\odot}$ star with radius of 200 $R_{\odot}$, commensurate
with typical red giant parameters (Han et al., 1994), tidally disrupted by a
SMBH with $M_{BH}=10^{8.5}$ M⊙ will have $t_{f}\approx 3000$ yr. In practice,
a giant is divided into a dense He core and a less dense envelope, each
containing about half the original star’s mass, so the stripped envelope mass
would supply the infalling gas while the core remains undisturbed.
Nevertheless, the rise in accretion rate over $t_{f}$ and decay $\dot{M}\sim
t^{-5/3}$ is consistent with that assumed in our toy model.

####  5.1.2 Energy Supply

The TDE energy extraction efficiency may be $\lesssim 10\%$ (De Colle & Lu,
2020), naively suggesting that only massive, difficult to disrupt stars $\sim
10-100$ M⊙ have fuel for CSO 2s. However, lower mass TDEs can provide magnetic
flux to ignite the extraction of the SMBH spin energy (Blandford & Znajek,
1977; Penna et al., 2013). Shortly after the TDE, we expect the magnetic flux
to disperse around the disk and thread the black hole

$\Phi_{BH,0}\approx\Phi_{\star}\frac{R_{H}^{2}}{r_{p}^{2}},$ (16)

where $\Phi_{\star}$ is the flux in the captured star, and $R_{H}$ is the
radius of the SMBH horizon. This magnetic flux coupled with the SMBH spin
launches a jet with power (Blandford & Znajek, 1977; Penna et al., 2013)

$L_{j}=\frac{1}{6\pi c}\Omega_{BH}^{2}\Phi_{BH}^{2},$ (17)

where $\Omega_{BH}$ is the spin of the BH. For a maximally spinning BH,
$R_{H}=r_{g}$ and $\Omega_{BH}=c/2r_{g}$. CSO jet powers can reach $L_{j}\sim
10^{44}$ erg s-1 (Readhead et al., 2024), requiring magnetic fields at the
SMBH to reach $\sim 10$ kG.

A very strong dipolar dynamo action (Parker, 1955; Ruediger et al., 1995) or
the magneto-rotational instability (Balbus & Hawley, 1991; Arlt & Rüdiger,
2001) could grow the field after being seeded by the TDE. The difficulty is
that the net magnetic flux must be conserved with vertical magnetic flux
randomly walking around that supplied by the TDE (Tchekhovskoy et al., 2014).
A pre-existing "fossil" disk which already has some seed flux could
nevertheless be amplified by the TDE (Tchekhovskoy et al., 2014), increasing
the jet power to make an observable CSO.

Once more, giant branch stars provide a compelling progenitor. Asymptotic
giant branch stars posses surface magnetic fields as high as $10$ G (Vlemmings
et al., 2002, 2005, 2011) while red giants have surface magnetic fields as
high as 300 G (Aurière et al., 2008; Donati & Landstreet, 2009). The cores of
red giants may even support magnetic fields exceeding $10^{5}$ G (Fuller et
al., 2015). For a single incoming giant with average magnetic field
$B_{\star}\gtrsim 10^{2}$ G, stellar radius $R_{\star}\approx 200$ R⊙,
$r_{p}=100$ $r_{g}$, and SMBH mass $10^{8}$ M⊙, the initial TDE would still
only provide a seed magnetic field, producing jet power $L_{j}\sim 10^{33}$
erg s-1.

The released gravitational energy of infalling debris provides sufficient
energy to grow the magnetic field in the vicinity of the SMBH. The energy
needed to build the magnetic field is $B^{2}R_{in}^{3}\approx
GM_{BH}m_{\star}/R_{in}$, where $R_{in}$ is the distance from the SMBH to
which the TDE material infalls from infinity. A 1 $M_{\odot}$ debris stream
can provide the energy for $B\approx 10$ kG by falling to $R_{in}\sim 40$
$r_{g}$. Since a giant branch star can be disrupted at $r_{t}>100$ $r_{g}$,
the infalling material can release the energy needed to build up the field.
Even a $\sim 1$ $M_{\odot}$ star can generate sufficient magnetic field to
power CSO jets. At least energetically, a wide range of TDE masses can produce
CSO 2s, not simply the most massive. Via a similar argument, the infalling
debris of lower mass stars should also be able to provide sufficient pressure
to hem in the magnetic field at the SMBH.

####  5.1.3 Ballistic Model and TDEs

The scenario we have just discussed changes slightly under the ballistic
projectile model for early CSO fueling. In this case, a TDE with $t_{f}<<1000$
yr, like that from a main sequence star, would provide the energy injection
into the projectile. To inject a full $M_{\odot}c^{2}$ into the projectile
within this short duration, $L_{j}$ would need to be at least 2 orders of
magnitude larger than assumed in the previous section, requiring magnetic
fluxes at the central SMBH to be higher by over a factor of 10. This would
consequently require a very efficient mechanism for increasing $\Phi_{BH}$
such as a stronger seed field (Tchekhovskoy et al., 2014; Curd & Narayan,
2019).

####  5.1.4 Event Rate

The inferred CSO 2 birth rate varies strongly with luminosity, rising from
$\sim 3\times 10^{-7}$ Gpc-3 yr-1 at $P=2\times 10^{28}$ W/Hz to $\sim 2\times
10^{-3}$ Gpc-3 yr-1 at $P=3\times 10^{25}$ W/Hz (Readhead et al., 2024). The
birth rate of jetted-TDEs has been weakly constrained to be (0.003–1)$\times$
the total TDE rate (De Colle & Lu, 2020), which implies a birth rate of
$3-10^{3}$ Gpc-3 yr-1. The TDE sources which can become CSO 2s likely require
long duration accretion events as well as preferential jet launching
conditions. Particularly, high jet-powering efficiencies (already a
requirement, as we have discussed in Sec. 5.1.2) and aligned disk-jet angular
momenta (Teboul & Metzger, 2023) are needed, suggesting that only a small
population of stars have favorable initial conditions. The disproportionate
paucity of red giants in galactic centers (Genzel et al., 1996; Dale et al.,
2009) suggests an even lower rate for these favorable source candidates. TDEs
with long enough timescales also require massive SMBHs like those inferred in
CSO galaxies (Readhead et al., 2024). Moreover, the flux limits on CSO 2
surveys imply that a larger population of low luminosity sources might exist.
Deeper radio surveys will better probe the CSO event rate and could provide
results commensurate with the TDE rates.

###  5.2 The Unlikelihood of Gas Cloud Captures

Generically, the infall of cold gas from the host galaxies can feed an AGN
(Gaspari et al., 2012; Combes, 2021). While an infalling gas cloud with mass
$\sim 100$ $M_{\odot}$ destabilized from kpc distances provides both the
energy and material needed to power a jet, tidal forces from the SMBH should
disrupt the cloud before reaching the central pc. A hot gas cloud at the Jeans
limit has tidal radius

$r_{t}\approx 10\text{ pc}\left(\frac{M_{BH}}{10^{8}\text{
}M_{\odot}}\right)^{\frac{1}{3}}\left(\frac{m_{c}}{100\text{
}M_{\odot}}\right)^{\frac{2}{3}}\left(\frac{T}{300\text{ K}}\right)^{-1}.$
(18)

Clouds with masses $\sim 100$ $M_{\odot}$ will consequently be tidally
disrupted well beyond a few 100 $r_{g}$. The dynamical time $t_{d}\approx
r_{t}^{3/2}/G^{1/2}M_{BH}^{1/2}$ with $M_{BH}=10^{8}$ $M_{\odot}$ is $\gtrsim
10^{5}$ yr, an order of magnitude too large to explain CSO 2s. In principle,
smaller ($m_{c}\sim 10$ $M_{\odot}$) and hotter ($T\sim 3000$ K) gas clouds
could have more amenable timescales, although such cases are very similar to
single stellar captures.

###  5.3 Testing the Hypothesis

The sharp size cutoff found by Kiehlmann et al. (2024a) needs to be verified
on a larger complete sample of CSO 2s. Work is underway to more than triple
the sample size to test this result. Precision measurements of this cutoff as
well as multiwavelength observations of the central 100 pc can test the
hypothesis. Recalling the characteristic working surface height $\zeta_{c}$
from Sec. 3.1.1 and assuming the source size doubles over the course of its
lifetime (as in both the real and our model CSO populations), the maximum
diameter of a typical CSO 2 is

$\begin{split}D_{c}=400&\text{ pc}\left(\frac{E_{tot}}{10\text{
}M_{\odot}c^{2}}\right)^{\frac{1}{4}}\left(\frac{t_{0}}{2500\text{
yr}}\right)^{\frac{1}{2}}\\\
&\times\left(\frac{\theta_{0}}{15^{\circ}}\right)^{-1}\left(\frac{\rho_{a}(\zeta=5\text{
pc})}{5\times 10^{-23}\text{g cm}^{-}3}\right)^{-\frac{1}{4}},\end{split}$
(19)

where we have assumed the density profile has $a=1$. For an initial mass
function $\propto m^{-2}$ over 1-100 $M_{\odot}$ (Kroupa, 2001, 2002;
Chabrier, 2003), stars with $M_{\star}<10$ $M_{\odot}$ should outnumber more
massive stars by a factor of $\gtrsim 10$. Consequently, assuming roughly
similar environmental and jet properties, we predict that CSO 2s with sizes
$\lesssim 400$ pc will outnumber those with sizes $\gtrsim 400$ pc by a factor
of $\sim 10$ if the TDE hypothesis holds.

The observation of a population of long duration ($>1$ yr) jetted TDEs
(potential proto-CSOs) would directly probe the hypothesis we propose for CSO
2s. A few such events have already been observed (Sfaradi et al., 2023), and
hopefully soon population studies may be conducted on them. Self-collisions of
post-TDE debris streams (Batra et al., 2021; Bonnerot et al., 2022) may
produce additional electromagnetic transients in X-ray, optical, and UV bands
(Jiang et al., 2016; Liu et al., 2022). Fading radio afterglow from these
collision sites may be observable as localized hot spots in particularly young
CSO 2s cores. Additionally, the UV and optical spectra should reflect the
elemental abundances deposited by a stellar capture. An over-abundance of
nitrogen relative to carbon (Kochanek, 2016; Cameron et al., 2023), in
particular, would be expected from old progenitor stars and such an
observation would strongly support our giant star TDE hypothesis.

##  6 Conclusion

With the current state of the observations, the phenomenology of CSO 2s
remains ripe for study. As a class of jetted-AGN with potentially distinct
fueling mechanisms and host environments, CSO 2s represent excellent galactic
center probes and reveal the evolution of radio loud AGN. In this work, we
have considered the possible mechanisms involved in CSO 2s and presented a
semi-analytic model of their life cycle. We have mapped the evolutionary
sequence presented by Kiehlmann et al. (2024b, a); Readhead et al. (2024) onto
the phases of the model and explored the phenomenological implications of the
different CSO sub-classifications.

At present, the most pressing questions about CSO 2s concern how sharp the
apparent size cutoff is, how they are fueled, and what causes them to fade.
CSO 2s are active jets for some period of time; for how long, however, remains
an open question. Eventually, CSO 2s with finite fuel should decelerate to
subsonic speeds as their power source is extinguished. This must occur to
prevent CSO 2s from reaching sizes exceeding 1 kpc in total. We have discussed
two fueling possibilities: TDEs or the infall of large molecular clouds. Given
the current evidence, we favor the TDE interpretation and suggest that TDEs of
giant branch stars can naturally explain the timescales and event rates of CSO
2s. It remains possible that much shorter TDEs of main sequence stars can
reproduce the morphology. Multiwavelength observations of CSO 2s, particularly
in the infrared with James Webb Space Telescope or in UV, coupled with
continued VLBI studies should strongly probe the progenitor models and the
properties of the host galaxies. Furthermore, our results motivate pointed
hydrodynamic and magnetohydrodynamic jet launching simulations to see if the
fueling scenarios we posit reproduce the observed radio morphologies.

More broadly, CSO 2s may represent a model system for studying the lifespans
of double radio sources, especially because they probe the critical phase of
evolution in which the luminosity increases with time as the jet power
increases. As a prevalent class of smaller finitely fueled radio loud AGN, CSO
2s, including those which grow into FR-IIs, display a wide variety of
morphologies corresponding to their ages and interactions with ambient media.
Observations of CSO 2s at all stages of their lifespan may provide insights
into the fate of their larger, longer lived counterparts. The late life
evolution of CSO 2s may morphologically correspond to the end state of FR-I or
FR-II sources when their central engines expire. The continued study of CSO 2s
has the potential to answer questions regarding galactic astrophysics, the
life cycle of radio jets, and the dynamics of accretion disk formation. The
study of CSO 2s brings time domain astronomy into the study of relativistic
jets in AGN. Identifying small CSO 2s early, we might follow the evolution of
jets in individual systems. CSO 2s open a window for galactic and high energy
astrophysical discoveries.

## Acknowledgements

The authors are grateful to Roger W. Romani for useful discussions and the
referee for helpful comments that improved the manuscript. A.S. acknowledges
the support of the Stanford University Physics Department Fellowship and the
National Science Foundation Graduate Research Fellowship. This work was
supported by a grant from the Simons Foundation (00001470, R.B., A.S.). In
recognition of his many important contributions to astrophysics and cosmology,
and in particular of his work on jetted-AGN, this paper is dedicated to Mark
Birkinshaw. Mark was working hard on this paper right up until his death from
cancer on 23 July 2023. Mark is sorely missed world-wide by his colleagues and
friends.

## Data Availability

The data underlying this article will be shared on reasonable request to the
corresponding author.

## References

  * Abolmasov & Bromberg (2023) Abolmasov P., Bromberg O., 2023, MNRAS, 520, 3009
  * Anglés-Castillo et al. (2021) Anglés-Castillo A., Perucho M., Martí J. M., Laing R. A., 2021, MNRAS, 500, 1512
  * Arlt & Rüdiger (2001) Arlt R., Rüdiger G., 2001, A&A, 374, 1035
  * Aurière et al. (2008) Aurière M., et al., 2008, A&A, 491, 499
  * Balbus & Hawley (1991) Balbus S. A., Hawley J. F., 1991, ApJ, 376, 214
  * Bambic et al. (2018) Bambic C. J., Morsony B. J., Reynolds C. S., 2018, ApJ, 857, 84
  * Batra et al. (2021) Batra G., Lu W., Bonnerot C., Phinney E. S., 2021, arXiv e-prints, p. arXiv:2112.03918
  * Bednarek & Protheroe (1997) Bednarek W., Protheroe R. J., 1997, MNRAS, 287, L9
  * Begelman (1996) Begelman M. C., 1996, in Carilli C. L., Harris D. E., eds, , Cygnus A – Study of a Radio Galaxy. p. 209
  * Begelman & Cioffi (1989) Begelman M. C., Cioffi D. F., 1989, ApJ, 345, L21
  * Begelman et al. (1984) Begelman M. C., Blandford R. D., Rees M. J., 1984, Reviews of Modern Physics, 56, 255
  * Bicknell (1994) Bicknell G. V., 1994, ApJ, 422, 542
  * Blandford & Znajek (1977) Blandford R. D., Znajek R. L., 1977, MNRAS, 179, 433
  * Bonnerot et al. (2022) Bonnerot C., Pessah M. E., Lu W., 2022, ApJ, 931, L6
  * Bosch-Ramon et al. (2012) Bosch-Ramon V., Perucho M., Barkov M. V., 2012, A&A, 539, A69
  * Bromberg et al. (2011) Bromberg O., Nakar E., Piran T., Sari R., 2011, ApJ, 740, 100
  * Cameron et al. (2023) Cameron A. J., Katz H., Rey M. P., Saxena A., 2023, MNRAS, 523, 3516
  * Canto & Raga (1991) Canto J., Raga A. C., 1991, ApJ, 372, 646
  * Capelo et al. (2010) Capelo P. R., Natarajan P., Coppi P. S., 2010, MNRAS, 407, 1148
  * Chabrier (2003) Chabrier G., 2003, PASP, 115, 763
  * Churazov et al. (2001) Churazov E., Brüggen M., Kaiser C. R., Böhringer H., Forman W., 2001, ApJ, 554, 261
  * Combes (2021) Combes F., 2021, Active Galactic Nuclei: Fueling and Feedback, doi:10.1088/2514-3433/ac2a27.
  * Coughlin (2023) Coughlin E. R., 2023, MNRAS, 522, 5500
  * Curd & Narayan (2019) Curd B., Narayan R., 2019, MNRAS, 483, 565
  * Dale et al. (2009) Dale J. E., Davies M. B., Church R. P., Freitag M., 2009, MNRAS, 393, 1016
  * De Colle & Lu (2020) De Colle F., Lu W., 2020, New Astron. Rev., 89, 101538
  * De Young (1993) De Young D. S., 1993, ApJ, 405, L13
  * De Young & Axford (1967) De Young D. S., Axford W. I., 1967, Nature, 216, 129
  * Donahue & Voit (2022) Donahue M., Voit G. M., 2022, Phys. Rep., 973, 1
  * Donati & Landstreet (2009) Donati J. F., Landstreet J. D., 2009, ARA&A, 47, 333
  * Dursi & Pfrommer (2008) Dursi L. J., Pfrommer C., 2008, ApJ, 677, 993
  * Eremin & Kovalenko (1998) Eremin M. A., Kovalenko I. G., 1998, A&A, 335, 370
  * Fabian et al. (2003) Fabian A. C., Sanders J. S., Allen S. W., Crawford C. S., Iwasawa K., Johnstone R. M., Schmidt R. W., Taylor G. B., 2003, MNRAS, 344, L43
  * Falle (1991) Falle S. A. E. G., 1991, MNRAS, 250, 581
  * Fanaroff & Riley (1974) Fanaroff B. L., Riley J. M., 1974, MNRAS, 167, 31P
  * Fanti et al. (1995) Fanti C., Fanti R., Dallacasa D., Schilizzi R. T., Spencer R. E., Stanghellini C., 1995, A&A, 302, 317
  * Fuller et al. (2015) Fuller J., Cantiello M., Stello D., Garcia R. A., Bildsten L., 2015, Science, 350, 423
  * Gaspari et al. (2012) Gaspari M., Ruszkowski M., Sharma P., 2012, ApJ, 746, 94
  * Genzel et al. (1996) Genzel R., Thatte N., Krabbe A., Kroker H., Tacconi-Garman L. E., 1996, ApJ, 472, 153
  * Giannios & Metzger (2011) Giannios D., Metzger B. D., 2011, MNRAS, 416, 2102
  * Globus & Levinson (2016) Globus N., Levinson A., 2016, MNRAS, 461, 2605
  * Gugliucci et al. (2007) Gugliucci N. E., Taylor G. B., Peck A. B., Giroletti M., 2007, ApJ, 661, 78
  * Han et al. (1994) Han Z., Podsiadlowski P., Eggleton P. P., 1994, MNRAS, 270, 121
  * Harrison et al. (2018) Harrison R., Gottlieb O., Nakar E., 2018, MNRAS, 477, 2128
  * Huško & Lacey (2023) Huško F., Lacey C. G., 2023, MNRAS, 521, 4375
  * Irwin et al. (2019) Irwin C. M., Tang X., Piran T., Nakar E., 2019, MNRAS, 488, 4926
  * Jiang et al. (2016) Jiang Y.-F., Guillochon J., Loeb A., 2016, ApJ, 830, 125
  * Kaiser & Alexander (1997) Kaiser C. R., Alexander P., 1997, MNRAS, 286, 215
  * Kaiser et al. (1997) Kaiser C. R., Dennett-Thorpe J., Alexander P., 1997, MNRAS, 292, 723
  * Kelley et al. (2014) Kelley L. Z., Tchekhovskoy A., Narayan R., 2014, MNRAS, 445, 3919
  * Kiehlmann et al. (2024a) Kiehlmann S., et al., 2024a, ApJ, p. in press.
  * Kiehlmann et al. (2024b) Kiehlmann S., et al., 2024b, ApJ, p. in press.
  * Kochanek (2016) Kochanek C. S., 2016, MNRAS, 458, 127
  * Komissarov (1994) Komissarov S. S., 1994, MNRAS, 269, 394
  * Kompaneets (1960) Kompaneets A. S., 1960, Soviet Physics Doklady, 5, 46
  * Kroupa (2001) Kroupa P., 2001, MNRAS, 322, 231
  * Kroupa (2002) Kroupa P., 2002, Science, 295, 82
  * Krtička (2014) Krtička J., 2014, A&A, 564, A70
  * Laing & Bridle (2002) Laing R. A., Bridle A. H., 2002, MNRAS, 336, 1161
  * Li & Bryan (2014) Li Y., Bryan G. L., 2014, ApJ, 789, 153
  * Lister et al. (2020) Lister M. L., Homan D. C., Kovalev Y. Y., Mandal S., Pushkarev A. B., Siemiginowska A., 2020, ApJ, 899, 141
  * Liu et al. (2022) Liu X.-L., Dou L.-M., Chen J.-H., Shen R.-F., 2022, ApJ, 925, 67
  * Lovelace et al. (2002) Lovelace R. V. E., Li H., Koldoba A. V., Ustyugova G. V., Romanova M. M., 2002, ApJ, 572, 445
  * Lyubarsky (2009) Lyubarsky Y., 2009, ApJ, 698, 1570
  * Lyubarsky (2011) Lyubarsky Y., 2011, Phys. Rev. E, 83, 016302
  * Matsumoto & Masada (2013) Matsumoto J., Masada Y., 2013, ApJ, 772, L1
  * Matsumoto et al. (2017) Matsumoto J., Aloy M. A., Perucho M., 2017, MNRAS, 472, 1421
  * Metzger et al. (2012) Metzger B. D., Giannios D., Mimica P., 2012, MNRAS, 420, 3528
  * Morris & Serabyn (1996) Morris M., Serabyn E., 1996, ARA&A, 34, 645
  * Morton et al. (1956) Morton B. R., Taylor G., Turner J. S., 1956, Proceedings of the Royal Society of London Series A, 234, 1
  * Nenkova et al. (2008) Nenkova M., Sirocky M. M., Nikutta R., Ivezić Ž., Elitzur M., 2008, ApJ, 685, 160
  * Nulsen et al. (2002) Nulsen P. E. J., David L. P., McNamara B. R., Jones C., Forman W. R., Wise M., 2002, ApJ, 568, 163
  * Olano (2009) Olano C. A., 2009, A&A, 506, 1215
  * Owen et al. (2000) Owen F. N., Eilek J. A., Kassim N. E., 2000, ApJ, 543, 611
  * Owsianik & Conway (1998) Owsianik I., Conway J. E., 1998, A&A, 337, 69
  * Owsianik et al. (1999) Owsianik I., Conway J. E., Polatidis A. G., 1999, New Astron. Rev., 43, 669
  * Parker (1955) Parker E. N., 1955, ApJ, 122, 293
  * Penna et al. (2013) Penna R. F., Narayan R., Sądowski A., 2013, MNRAS, 436, 3741
  * Perucho (2020) Perucho M., 2020, MNRAS, 494, L22
  * Perucho & López-Miralles (2023) Perucho M., López-Miralles J., 2023, Journal of Plasma Physics, 89, 915890501
  * Perucho et al. (2014) Perucho M., Martí J. M., Laing R. A., Hardee P. E., 2014, MNRAS, 441, 1488
  * Phinney (1989) Phinney E. S., 1989, in Morris M., ed., Vol. 136, The Center of the Galaxy. p. 543
  * Readhead et al. (1994) Readhead A. C. S., Xu W., Pearson T. J., Wilkinson P. N., Polatidis A. G., 1994, in Zensus J. A., Kellermann K. I., eds, Compact Extragalactic Radio Sources. p. 17
  * Readhead et al. (1996) Readhead A. C. S., Taylor G. B., Xu W., Pearson T. J., Wilkinson P. N., Polatidis A. G., 1996, ApJ, 460, 612
  * Readhead et al. (2024) Readhead A. C. S., et al., 2024, ApJ, p. in press.
  * Reynolds & Begelman (1997) Reynolds C. S., Begelman M. C., 1997, ApJ, 487, L135
  * Reynolds et al. (2002) Reynolds C. S., Heinz S., Begelman M. C., 2002, MNRAS, 332, 271
  * Ruediger et al. (1995) Ruediger G., Elstner D., Stepinski T. F., 1995, A&A, 298, 934
  * Russeil et al. (2017) Russeil D., Adami C., Bouret J. C., Hervé A., Parker Q. A., Zavagno A., Motte F., 2017, A&A, 607, A86
  * Schödel et al. (2018) Schödel R., Gallego-Cano E., Dong H., Nogueras-Lara F., Gallego-Calvente A. T., Amaro-Seoane P., Baumgardt H., 2018, A&A, 609, A27
  * Sfaradi et al. (2023) Sfaradi I., et al., 2023, MNRAS,
  * Stark et al. (1991) Stark A. A., Gerhard O. E., Binney J., Bally J., 1991, MNRAS, 248, 14P
  * Sternberg & Soker (2008) Sternberg A., Soker N., 2008, MNRAS, 389, L13
  * Strubbe & Quataert (2009) Strubbe L. E., Quataert E., 2009, MNRAS, 400, 2070
  * Tchekhovskoy et al. (2014) Tchekhovskoy A., Metzger B. D., Giannios D., Kelley L. Z., 2014, MNRAS, 437, 2744
  * Teboul & Metzger (2023) Teboul O., Metzger B. D., 2023, ApJ, 957, L9
  * Torres-Albà & Bosch-Ramon (2019) Torres-Albà N., Bosch-Ramon V., 2019, A&A, 623, A91
  * Tremblay et al. (2016) Tremblay S. E., Taylor G. B., Ortiz A. A., Tremblay C. D., Helmboldt J. F., Romani R. W., 2016, MNRAS, 459, 820
  * Venuti et al. (2014) Venuti L., et al., 2014, A&A, 570, A82
  * Vlemmings et al. (2002) Vlemmings W. H. T., Diamond P. J., van Langevelde H. J., 2002, A&A, 394, 589
  * Vlemmings et al. (2005) Vlemmings W. H. T., van Langevelde H. J., Diamond P. J., 2005, A&A, 434, 1029
  * Vlemmings et al. (2011) Vlemmings W. H. T., Humphreys E. M. L., Franco-Hernández R., 2011, ApJ, 728, 149
  * Wang et al. (2023) Wang J.-S., Reville B., Mizuno Y., Rieger F. M., Aharonian F. A., 2023, MNRAS, 519, 1872
  * Wilkinson et al. (1994) Wilkinson P. N., Polatidis A. G., Readhead A. C. S., Xu W., Pearson T. J., 1994, ApJ, 432, L87
  * Woods (2010) Woods A. W., 2010, Annual Review of Fluid Mechanics, 42, 391
  * Zdziarski et al. (2022) Zdziarski A. A., Stawarz Ł., Sikora M., Nalewajko K., 2022, MNRAS, 515, L17
  * van de Voort et al. (2011) van de Voort F., Schaye J., Booth C. M., Haas M. R., Dalla Vecchia C., 2011, MNRAS, 414, 2458


# Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code

Nicolas Dupuis1, Luca Buratti2, Sanjay Vishwakarma3, Aitana Viudes Forrat3,
David Kremer3, Ismael Faro3, Ruchir Puri1 and Juan Cruz-Benito3  1IBM
Research, Yorktown Heights, NY, USA  2IBM Research, Zurich, Rüschlikon,
Switzerland  3IBM Quantum, Yorktown Heights, NY, USA

###### Abstract

Code Large Language Models (Code LLMs) have emerged as powerful tools,
revolutionizing the software development landscape by automating the coding
process and reducing time and effort required to build applications. This
paper focuses on training Code LLMs to specialize in the field of quantum
computing. We begin by discussing the unique needs of quantum computing
programming, which differ significantly from classical programming approaches
or languages. A Code LLM specializing in quantum computing requires a
foundational understanding of quantum computing and quantum information
theory. However, the scarcity of available quantum code examples and the
rapidly evolving field, which necessitates continuous dataset updates, present
significant challenges. Moreover, we discuss our work on training Code LLMs to
produce high-quality quantum code using the Qiskit library. This work includes
an examination of the various aspects of the LLMs used for training and the
specific training conditions, as well as the results obtained with our current
models. To evaluate our models, we have developed a custom benchmark, similar
to HumanEval, which includes a set of tests specifically designed for the
field of quantum computing programming using Qiskit. Our findings indicate
that our model outperforms existing state-of-the-art models in quantum
computing tasks. We also provide examples of code suggestions, comparing our
model to other relevant code LLMs. Finally, we introduce a discussion on the
potential benefits of Code LLMs for quantum computing computational
scientists, researchers, and practitioners. We also explore various features
and future work that could be relevant in this context.

###### Index Terms:

Code Large Language Models, code LLMs, Qiskit, Quantum Computing

##  I Introduction

We are digitally surrounded by Large Language Models (LLMs) that guide us
while writing to serve as assistants for several problems, reduce user writing
effort, suggest different options for words/sentences to enhance our style, or
fix our grammatical errors. The same applies in the context of source code,
where LLMs are being used in different stages of the software development
cycle: from the generation of code to bug fixing, from generating
documentation to migration [1, 2]. Generic LLMs such as GPT-4 [3], Claude [4],
or Gemini [5] are very good at coding, but smaller code-LLMs can reach almost
the same coding skills while being easier and cheaper to train, and to infer.
For example, to cite just a few, StarCoder [6], Code Llama [7], and DeepSeek
Coder [8] all show impressive performances on various code benchmarks.

There is a growing interest in the application of Artificial Intelligence (AI)
methods to enhance the quantum computing field [9, 10]. In recent years, it
has become apparent that the majority of research and development efforts in
this area have been focused on devising novel quantum algorithms for
artificial intelligence [11, 12, 13, 14, 15, 16, 17] or integrating classical
AI features with quantum systems to optimize specific domains or processes
[18, 14, 15, 19, 20]. However, there is a noticeable gap in the application of
machine learning and classical intelligence systems and algorithms to augment
quantum ecosystems and platforms and empowering quantum computing
practitioners, a concern that has gained increasing attention within the
quantum community [21, 22, 23].

With the proliferation of Large Language Models (LLMs) for code assistance,
and considering the previous comments in the field of quantum computing, an
area of interest is to develop specialized LLMs for quantum code generation.
Quantum code generation poses unique challenges that make it a more complex
task than standard code generation:

  * •

It requires a basic knowledge of quantum computing

  * •

There is limited amount of data and code examples

  * •

The field evolves quickly, and new techniques appear frequently and the
relevant libraries are updated accordingly.

The same challenges apply to some extent to human coders: quantum computing
has a high barrier of entry for developers that are not familiar with the
field but want to explore its capabilities. With specialized code assistants
for quantum, we aim to make quantum computing more accessible to new adopters,
and to make development workflows more efficient for current users.

In this work, we introduce specialized LLMs that can work as code assistants
for Qiskit SDK [24, 25] users. Qiskit is the lead open-source quantum
computing framework [26] that provides a comprehensive set of tools,
libraries, and documentation for building quantum algorithms, simulating
quantum systems, and working with quantum hardware.

The paper is organized as follows: Section 2 presents the methods and
materials employed to train the LLMs, including details about the dataset,
training procedures and foundation models used. Section 3 presents a summary
of the results achieved, including a description of our evaluation benchmark,
how our model compare to others and some prompt results. Section 4 presents
some conclusions and future directions.

##  II Methods and materials

We start training on top of a Granite code model [27], part of a family of
decoder-based models for generative AI code tasks. The Granite series of
models shows state-of-the-art performance across open Code-LLMs in a variety
of coding tasks. Furthermore, Granite models are among the most open models
available as of today [28], providing clear details about data, training and
architecture. Our base model is granite-20b-code which uses gpt_bigcode [29]
architecture, has $20~{}$Billion parameters, learned positional encodings,
multi-query attention, and a context length of $8192$ tokens. The tokenizer is
identical to StarCoder [30] and has a vocabulary size of $49152$. The Granite
base model was pre-trained on $1.6~{}$T tokens of code data including 116
programming languages.111We started this work using an early version of
granite code which saw less tokens than the recently published moded[27].

To improve the performances of the model at generating high-quality Qiskit
code, we extend its pretraining with additional Qiskit data containing python
scripts, and Jupyter notebooks. We crawled GitHub using its API, searching for
all publicly available repositories with a permissive open-source license that
contain the keyword “qiskit” in the name or in the description, keeping only
the main branch at the latest commit available, and omitting forks. All the
data was collected on April 19, 2024. As common with technical SDKs, Qiskit
evolves fast and deprecates features often, so training a model with the
latest data available ensure compatibility with the latest releases. After
collecting data, we filtered out samples with deprecated code, keeping only
samples updated after 2022, and applied exact-match deduplication. For the
Jupyter notebooks, we followed a similar approach to StarCoder [6], and used
sentinel tokens to separate out code and markdown fields. We also filter out
cells containing decoded base64 image data. We did not use the output cells
from the notebooks.

After filtering, the total number of tokens is $88~{}$M, of which $80~{}$M
were never seen by the base model. We set up training data mixing ratios to
ensure diversity and quality. Table I shows the data and token distribution
used. The data includes python scripts, and Jupyter notebooks that contain mix
of Qiskit tutorials and code. In the table, we highlight the difference
between Qiskit Official (qko) and other non-official Qiskit data (qk). The qko
data comes from one of the following GitHub organizations, Qiskit [31],
Qiskit-Community [32], or Qiskit-Extensions [33], and is considered of the
highest quality, hence the large oversampling factors ($10.3$ and $11.2$). We
tested different weights and mixing ratios and found the values in Table I to
work the best on our evaluation benchmark and when sampling from the model.

For extend-pretraining, the data is packed and we use a special token to
separate each samples. The total number of tokens after oversampling is
$193~{}$M and we train for $1400$ steps ($\approx 3$ epochs). We use a global
batch size of $64$, and a learning rate warmed-up from $0$ to $1\times
10^{-5}$ on $140$ steps then decayed with a cosine schedule.

In order to improve natural language understanding, we further instruct-tune
the model. We use the octopack approach as described in [34], mixing chat data
from openassistant ($8$k samples) and commit data from commitpackft ($5$k
samples). We also add synthetic data specific to Qiskit: $2.7$k
question/answer pairs synthetically generated from tutorial using mixtral
instruct model [35], and $1$k synthetic prompt/code pairs, whose execution
accuracy were validated using synthetically-generated unittests. We left-pad
all the sequences and use a $2048$ sequence length. We train the model for
$3.2$ epochs using a global batch size of $32$, a learning rate of $8\times
10^{-6}$ decayed using a cosine schedule and a warm-up of $160$ steps.

TABLE I: Data distribution and token count used for extend pretraining. Each subset has a weight and is oversampled. Total token count in one training epoch is $193~{}$M. “qko” refers to any sample originating from an official Qiskit GitHub organization. Dataset |  Weight |  Epochs |  Raw tokens (M) |  Eff tokens (M)
---|---|---|---|---
qko-code |  $0.35$ |  $10.3$ |  $6.5$ |  $67.7$
qk-code |  $0.3$ |  $1$ |  $58$ |  $58$
qko-notebook |  $0.24$ |  $11.2$ |  $4.1$ |  $46.4$
qk-notebook |  $0.11$ |  $1$ |  $20$ |  $20$

##  III Results

###  III-A Qiskit HumanEval

For testing our model, we have created a new execution-based benchmark called
Qiskit HumanEval (QHE). The benchmark is similar to HumanEval [36], including
multiple challenging code problems to solve, all based on the Qiskit library.
Among the different problems evaluated through the benchmark we can find
management of basic quantum code instructions, writing of particular quantum
algorithms, handling of executions in either simulators or quantum devices,
basic understanding of quantum information theory-related problems or
terminology. QHE currently comprises 101 examples. Similar to HumanEval, the
context provided to the model consists in a function definition, followed by a
docstring which details the task the model is required to solve. Each example
also includes a reference canonical solution, as well as unittests in order to
evaluate the correctness of the generated solutions. This benchmark will be
released later in 2024.

⬇

# Import qiskit ibm runtime service and print which backends are available for

# my account. Get backend ”ibm brisbane” and define a function in which I

# can show the properties thermal relaxation time, dephasing time and gate
error

# of sx gate for the qubit 1 in that backend.

from qiskit_ibm_runtime import QiskitRuntimeService

service = QiskitRuntimeService()

print(service.backends())

backend = service.backend(”ibm_brisbane”)

def show_properties(backend):

properties = backend.properties()

qubit = 1

print(f”Qubit {qubit} thermal relaxation time:
{properties.qubit_property(qubit, ’T1’)}”)

print(f”Qubit {qubit} dephasing time: {properties.qubit_property(qubit,
’T2’)}”)

print(f”Qubit {qubit} sx gate error: {properties.gate_error(’sx’, qubit)}”)

show_properties(backend)

(a) granite-20b-code-qk

⬇

# Import qiskit ibm runtime service and print which backends are available for

# my account. Get backend ”ibm brisbane” and define a function in which I

# can show the properties thermal relaxation time, dephasing time and gate
error

# of sx gate for the qubit 1 in that backend.

from qiskit_ibm_runtime import QiskitRuntimeService

from qiskit.providers.ibmq.runtime import UserMessenger

service = QiskitRuntimeService()

print(service.backends())

backend = service.get_backend(”ibmq_qasm_simulator”)

def show_properties(backend):

print(backend.properties().to_dict())

print(backend.properties().qubits[1].to_dict())

print(backend.properties().gates[0].to_dict())

show_properties(backend)

(b) deepseek-coder-33b-base

⬇

from qiskit.circuit.library import LinearFunction

from qiskit.synthesis.linear.linear_matrix_utils

import random_invertible_binary_matrix

def get_random_linear_function(n_qubits, seed):

”””

Generate a random linear function circuit using the input parameters

n_qubits, seed and through using the random_invertible_binary_matrix

method.

”””

matrix = random_invertible_binary_matrix(n_qubits, seed)

linear_function = LinearFunction(matrix)

return linear_function

(c) granite-20b-code-qk

⬇

from qiskit.circuit.library import LinearFunction

from qiskit.synthesis.linear.linear_matrix_utils

import random_invertible_binary_matrix

def get_random_linear_function(n_qubits, seed):

”””

Generate a random linear function circuit using the input parameters

n_qubits, seed and through using the random_invertible_binary_matrix

method.

”””

random_invertible_binary_matrix.seed(seed)

matrix =
random_invertible_binary_matrix.get_random_invertible_binary_matrix(n_qubits)

return LinearFunction(matrix)

(d) deepseek-coder-33b-base

Figure 1: Output samples generated with granite-20b-code-qk and deepseek-
coder-33b-base. In (a) and (b) the models are prompted with an instruction set
as a python comment, while in (c) and (d), the models are prompted with the
import statements, a function header and a python docstring.

###  III-B Evaluation Results

We tested the Qiskit model and other baselines on QHE and HumanEval (HE). To
compute the execution accuracy, we used the bigcode harness framework [37] and
ran the code generated by the models in a docker environment setup with the
latest version of Qiskit SDK (at the time of writing this paper, v1.0.2).
Table II presents the results. The pass scores were computed on greedy-decoded
model outputs. We compare Granite with 3 base models and one instruct model.
Of the three base, deepseek-coder-33b-base has the highest QHE pass score at
$39.6$%. The instruct version of DeepSeek Coder is best at HE but the QHE pass
rate is slightly lower. starcoder2-15b is also a strong baseline on QHE with a
pass score of $37.62$%. Our granite base model (granite-20b-code) has a QHE
pass score of $20.79$%, however, after extend training, the pass score reaches
$46.53$%, beating all models.

TABLE II: HumanEval (HE) and Qiskit-HumanEval (QHE) pass@$1$ computed using greedy decoding. Model |  HE |  QHE
---|---|---
CodeLlama-34b-Python-hf |  $52.43$% |  $26.73$%
deepseek-coder-33b-base |  $49.39$% |  $39.6$%
deepseek-coder-33b-instruct |  $\mathbf{68.9}$% |  $35.64$%
starcoder2-15b |  $45.12$% |  $37.62$%
granite-20b-code |  $38.41$% |  $20.79$%
granite-20b-code-qk |  $36.58$% |  $\mathbf{46.53}$%

###  III-C Prompt results

In Fig. 1, we present examples of prompt queries sent to granite-qiskit (a),
(c) and DeepSeek Coder (b), (d). First comparing (a) and (b), DeepSeek Coder,
does not correctly follow the instructions provided. It starts by introducing
an unnecessary import with “from qiskit.providers.ibmq.runtime import
UserMessenger”, which is irrelevant and outdated. Furthermore, while it does
manage to list available backends, it incorrectly chooses
“ibmq_qasm_simulator” instead of the specified “ibm_brisbane” backend. Also,
displaying the backend properties, though somewhat informative, misses the
mark by not focusing on the specified properties of thermal relaxation time,
dephasing time, and sx gate error for qubit 1. Whilst the output is
technically correct in a broader context, it fails to address the prompt
specifics. The Qiskit model correctly responds to the prompt. It accurately
selects the “ibm_brisbane” backend and correctly defines the “show_properties”
function to focus on the requested qubit and gate properties. When the model
proposes code to get qubit properties, it shows a good knowledge about quantum
computing terminology as it associates the prompt statement “thermal
relaxation time” to the term “T1” or “dephasing time” as “T2”. Now looking at
prompts (c) and (d), granite-qiskit correctly addresses the prompt
specifications, creating a “get_random_linear_function” method that accurately
employs the input parameters of “n_qubits” and seed. This is achieved through
the correct application of generating a random invertible binary matrix and
leveraging this matrix to construct a LinearFunction, thereby aligning with
the prompt. DeepSeek Coder’s response, while attempting to address the same
task, falls short on several fronts. It uses an unnecessary method call
“random_invertible_binary_matrix.seed(seed)” that disrupts the standard
workflow and makes the code unable to run. Furthermore, the misapplication of
the LinearFunction object construction, characterized by an erroneous approach
to matrix generation, further underscores a fundamental misinterpretation of
the task requirements.

##  IV Discussion

In terms of the utility of such solutions, we view these tools as a potential
catalyst that could accelerate the adoption and utilization of quantum
computing, particularly among newcomers and students, much like how LLMs have
facilitated the learning of programming in classical languages/paradigms [38].
For more experienced researchers, computational scientists, and similar user
personas, we anticipate that LLMs could improve the coding experience,
exploration, and overall happiness [36, 39, 40], although further evaluation
is required to confirm this observation [41]. In relation to the public
release of these LLMs, the models trained under the auspices of the Qiskit
Code Assistant project will be made available to IBM Quantum users in the
upcoming months through a suite of services and extensions that can integrate
with existing IDEs or various programming environments. Similarly, the
evaluation benchmark, the Qiskit HumanEval, will be released publicly to
enable other LLMs to compare and enhance their code suggestions in the field
of quantum computing. Enabling LLMs in a rapidly evolving context like quantum
computing presents unique challenges. We anticipate continuous updates to new
approaches, algorithms, and libraries. A crucial aspect of this project is the
ability to regularly update the models to reflect the most recent code,
trends, and best practices, ensuring that they remain valuable and relevant
for all user personas. As part of this evolving landscape, we expect the need
for features such as code explanation, translation between different libraries
or versions, automatic test generation and code repair to arise soon.

## Acknowledgment

The authors thank the data and model factory who collected the code data and
trained the base model, in particular Mayank Mishra, Rameswar Panda, Gaoyuan
Zhang, Matthew Stallone, and Hima Patel. We also thank Atin Sood for helping
setting up the service, and Xuan Liu for support and management.

## References

  * [1] Z. Zheng, et al., “A survey of large language models for code: Evolution, benchmarking, and future trends,” _arXiv:2311.10372_ , 2023.
  * [2] GitHub, https://github.com/features/copilot, 2024.
  * [3] OpenAI, “GPT-4 Technical Report,” 2023.
  * [4] Anthropic, https://claude.ai/, 2024.
  * [5] M. Reid, et al., “Gemini 1.5: Unlocking multimodal understanding across millions of tokens of context,” _arXiv:2403.05530_ , 2024.
  * [6] A. Lozhkov, et al., “StarCoder 2 and The Stack v2: The Next Generation,” _arXiv:2402.19173_ , 2024.
  * [7] B. Rozière, et al., “Code Llama: Open Foundation Models for Code,” _arXiv:2308.12950_ , 2023.
  * [8] D. Guo, et al., “DeepSeek-Coder: When the Large Language Model Meets Programming – The Rise of Code Intelligence,” _arXiv:2401.14196_ , 2024.
  * [9] J. Preskill, “Quantum computing in the NISQ era and beyond,” _Quantum_ , vol. 2, p. 79, 2018.
  * [10] J. Biamonte, et al., “Quantum machine learning,” _Nature_ , vol. 549, no. 7671, pp. 195–202, 2017.
  * [11] K. Bharti, et al., “Machine learning meets quantum foundations: A brief survey,” _AVS Quantum Science_ , vol. 2, no. 3, 2020.
  * [12] D. Peral-García, et al., “Systematic literature review: Quantum machine learning and its applications,” _Computer Science Review_ , vol. 51, p. 100619, 2024.
  * [13] V. Dunjko, et al., “Machine learning & artificial intelligence in the quantum domain: a review of recent progress,” _Reports on Progress in Physics_ , vol. 81, no. 7, p. 074001, 2018.
  * [14] P. S. Emani, et al., “Quantum computing at the frontiers of biological sciences,” _Nature Methods_ , vol. 18, no. 7, pp. 701–709, 2021\.
  * [15] M. Martonosi, et al., “Next steps in quantum computing: Computer science’s role,” _arXiv:1903.10541_ , 2019.
  * [16] P. Baireuther, et al., “Machine-learning-assisted correction of correlated qubit errors in a topological code,” _Quantum_ , vol. 2, p. 48, 2018.
  * [17] J. Bausch, et al., “Learning to decode the surface code with a recurrent, transformer-based neural network,” _arXiv:2310.05900_ , 2023\.
  * [18] H. P. Nautrup, et al., “Optimizing quantum error correction codes with reinforcement learning,” _Quantum_ , vol. 3, p. 215, 2019.
  * [19] V. Nguyen, et al., “Deep reinforcement learning for efficient measurement of quantum devices,” _npj Quantum Information_ , vol. 7, no. 1, p. 100, 2021.
  * [20] D. Kremer, et al., “Practical and efficient quantum circuit synthesis and transpiling with reinforcement learning,” _arXiv:2405.13196_ , 2024.
  * [21] V. Esbroeck, et al., “Quantum device fine-tuning using unsupervised embedding learning,” _New Journal of Physics_ , vol. 22, no. 9, p. 095003, 2020.
  * [22] H. Moon, et al., “Machine learning enables completely automatic tuning of a quantum device faster than human experts,” _Nature communications_ , vol. 11, no. 1, p. 4161, 2020.
  * [23] J. Cruz-Benito, et al., “A deep-learning-based proposal to aid users in quantum computing programming,” in _Learning and Collaboration Technologies. Learning and Teaching_ , P. Zaphiris and A. Ioannou, Eds. Cham: Springer International Publishing, 2018, pp. 421–430.
  * [24] Qiskit contributors, “Qiskit: An open-source framework for quantum computing,” 2023.
  * [25] A. Javadi-Abhari, et al., “Quantum computing with qiskit,” _arXiv:2405.08810_ , 2024.
  * [26] Unitary Fund, “2023 Quantum Open Source Survey,” Dec 2023. [Online]. Available: https://unitaryfund.github.io/survey-website/
  * [27] M. Mishra, et al., “Granite code models: A family of open foundation models for code intelligence,” _arXiv:2405.04324_ , 2024.
  * [28] B. Rishi, et al., “The foundation model transparency index v1.1,” _arXiv:2310.12941_ , 2024.
  * [29] L. Ben Allal, et al., “SantaCoder: don’t reach for the stars!” _arXiv:2301.03988_ , 2023.
  * [30] R. Li, et al., “StarCoder: may the source be with you!” _arXiv:2305.06161_ , 2023.
  * [31] “Qiskit,” https://github.com/Qiskit/qiskit, 2024.
  * [32] “Qiskit Community,” https://github.com/qiskit-community, 2024.
  * [33] “Qiskit Extensions,” https://github.com/Qiskit-Extensions, 2024.
  * [34] N. Muennighoff, et al., “OctoPack: Instruction Tuning Code Large Language Models,” _arXiv:2308.07124_ , 2023.
  * [35] A-Q. Jiang, et al., “Mixtral of experts,” _arXiv:2401.04088_ , 2024\.
  * [36] M. Chen, et al., “Evaluating large language models trained on code,” _arXiv:2107.03374_ , 2021.
  * [37] “A framework for the evaluation of code generation models,” https://github.com/bigcode-project/bigcode-evaluation-harness, 2022.
  * [38] J. Finnie-Ansley, et al., “The robots are coming: Exploring the implications of openai codex on introductory programming,” in _Proceedings of the 24th Australasian Computing Education Conference_ , 2022, pp. 10–19.
  * [39] A. M. Dakhel, et al., “Github copilot ai pair programmer: Asset or liability?” _Journal of Systems and Software_ , vol. 203, p. 111734, 2023\.
  * [40] S. Barke, et al., “Grounded copilot: How programmers interact with code-generating models,” _Proceedings of the ACM on Programming Languages_ , vol. 7, no. OOPSLA1, pp. 85–111, 2023.
  * [41] P. Vaithilingam, et al., “Expectation vs. experience: Evaluating the usability of code generation tools powered by large language models,” in _Chi conference on human factors in computing systems extended abstracts_ , 2022, pp. 1–7.