\section{Introduction}
\label{sec:intro}

\begin{figure}[!t]
	\begin{center}
		\includegraphics[width=1.0\linewidth]{figures/introduction.png}

	\end{center}
	\vspace{-0.7cm}
	\caption{Illustration of the regular UDA (a), the lifelong UDA in the stationary target scenario (b) and dynamic target scenario (c).}
	\vspace{-0.5cm}
	\label{fig:intro}
\end{figure}

Person re-identification (ReID) aims to identify the same person across different locations, time instances and cameras. It is of high value in a wide range of applications~\cite{wang2013intelligent} in diverse environments, such as customer activity analysis, missing children finding. In practice, a trained ReID model usually suffers from severe performance drops when deployed in new environments due to the domain gaps between the training data and the data in new environments. Unsupervised domain adaptive (UDA) person ReID has been widely studied to help deployed person ReID models better adapt to new environments, by transferring learned knowledge from labeled source domain to unlabeled target domain \cite{zhang2019self,fu2019self,ge2020mutual,song2020unsupervised,zhang2021unsupervised,bai2021unsupervised}.

Existing UDA person ReID methods \cite{zhang2019self,fu2019self,ge2020mutual,song2020unsupervised,zhang2021unsupervised,bai2021unsupervised} assume that the data in the target domain can be accessible all at once, which does not accord well with practical scenarios. In deployment environments, new people are often showing up constantly and the data statistics may vary over time. This imposes strong demands in developing a practical person ReID model/system that can support 1) flexible adaptation to data statistics on the fly so that we can timely obtain adapted performance without waiting for a long time to collect massive data and 2) continuous knowledge acquisition from increasing data.
Recent works begin to look into lifelong (supervised) person ReID~\cite{wu2021generalising,pu2021lifelong}. They greatly advance practical applications by supporting continuous supervised domain adaptation, but still leave much exploration room in the following aspects. First, these works require costly annotations in the target domain. Besides human labour efforts, data labelling is time consuming, which is not conductive to quick adaptation and privacy protection.
Second, they all aim to balance anti-forgetting and adaptation, lacking explicit consideration for their coordination.
In fact, anti-forgetting can facilitate flexible/quick adaptation when harnessed in the right manner.
In this paper, we propose and study a more practical task, \textit{i}.\textit{e}., Lifelong Unsupervised Domain Adaptive (LUDA) person ReID, which does not require annotations in the target domain.

\textit{LUDA person ReID}~enables deployed models to achieve continuous domain adaptation using unlabeled target stream.
To the best of our knowledge, we are the first to define this task.
Different from conventional life-long learning \cite{li2017learning,verwimp2021rehearsal,hu2021distilling}, our proposed task is challenging attributable to two reasons. First, person ReID is a fine-grained retrieval task. Critical to this task is to capture the inter-instance relations for accurately ranking instances.
Second, in the context of lifelong learning, person ReID requires higher generalization ability on unseen identities/categories since there are constantly new people showing up, beyond the requirements for remembering how to classify seen categories as in classification tasks. Thus, for \textit{LUDA person ReID}, we expect that anti-forgetting can promote adaptation by avoiding over-fitting new data and facilitating learning more generalizable features so that we can achieve fast adaptation especially when the target domain changes or reappears.

In this paper, we design an effective scheme for \textit{LUDA person ReID}~in which anti-forgetting and adaptation are coordinated, dubbed \textit{CLUDA-ReID}. In previous studies \cite{chaudhry2018riemannian,wu2021striking,mai2021online,delange2021continual}, anti-forgetting is commonly placed into a joint learning framework together with the training for adaptation, lacking explicit considerations on their coordination. We propose Coordinated Data Replay (CDR) to solve this problem. Particularly, we store old data with a modified ID-wise reservoir sampling algorithm, and design a meta-based optimization strategy to align the objective of anti-forgetting with that of adaptation when replaying stored old data. Moreover, we maintain a model that is timely updated and a momentum-updated model that accumulates learned knowledge over time.
We further introduce Relational Consistency Learning (RCL) to promote knowledge distillation/inheritance from the historical model to the current model when performing adaptation. Different from other knowledge distillation strategies \cite{wu2021generalising} in conventional lifelong learning, RCL is carefully designed to match the task characteristics of person ReID. We introduce two scenarios with stationary or dynamic target streams as illustrated in Fig.\ref{fig:intro}, and evaluate our \textit{CLUDA-ReID}~ on these settings. Besides, we build a new dataset named MMP-Retrieval upon the MMPTRACK dataset for unseen-domain generalization evaluation, released at \url{https://iccv2021-mmp.github.io/subpage/dataset.html}.

Our contributions can be summarized in three aspects:

\begin{itemize}[noitemsep,nolistsep,leftmargin=*]
\item We propose a novel yet realistic task, Lifelong Unsupervised Domain Adaptive (LUDA) person re-identification, to endow person ReID models with automatic adaptation using continuously collected unlabeled data.
\item We design an effective \textit{LUDA person ReID}~scheme, \textit{i}.\textit{e}., \textit{CLUDA-ReID}, wherein Coordinated Data Replay (CDR) and Relational Consistency Learning (RCL) are proposed to explicitly coordinate anti-forgetting and adaptation.
\item We set up two practical evaluation schemes to simulate real application scenarios. Extensive experiments demonstrate that our proposed method is effective in achieving LUDA for scenarios with stationary or dynamic target streams and enhancing unseen-domain generalization.
\end{itemize}

\section{Related Works}
\label{sec:related}

\subsection{Domain Adaptive Person Re-identification}

Person re-identification (ReID) has been widely investigated and applied in many real-world scenarios.
Unsupervised domain adaptive (UDA) person ReID is of high practical values in transferring the knowledge from labeled source domain to unlabeled target domain for improving the accuracy on the target domain after supervised fine-tuning.
Approaches in this field can be grouped into three main categories: (1) Style translation based methods \cite{liu2019adaptive,ge2020structured}; (2) Pseudo labelling based methods \cite{yu2019unsupervised,ge2020mutual,zhai2020multiple,zhao2020unsupervised}; (3) Domain-invariant feature learning based methods \cite{lin2018multi,huang2019domain,liu2020domain}. Albeit their effectiveness, they all assume that the target domain can be entirely accessible but this may not hold in practice. In the real-world, target data usually comes in a stream and its statistics may vary over time.

Recently, a few works \cite{wu2021generalising,pu2021lifelong} study the lifelong (supervised) person ReID problem wherein supervised domain adaptation is continually performed. In \cite{wu2021generalising}, consistencies from different perspectives (\textit{i}.\textit{e}., classification, distribution and representation) are incorporated into a comprehensive training objective for distilling knowledge from the old model. But it does not explicitly consider the optimization in line with the objective of learning to rank.
Pu \etal \cite{pu2021lifelong} propose an adaptive knowledge accumulation method for this task. However, both of them consider the supervised setting and lack explicit consideration on coordinating anti-forgetting with adaptation, in the sense that enabling anti-forgetting to enhance adaptation. In this work, we propose and address a new task, \textit{i}.\textit{e}., \textit{LUDA person ReID}.

\subsection{Lifelong Learning}

Lifelong learning aims to learn from ever-expanding data, which is challenging in capturing new knowledge as well as maintaining old knowledge. Approaches in this field can be summarized into three categories. (1) \textit{Knowledge distillation based methods}~\cite{li2017learning,iscen2020memory,wu2021generalising} transfer already acquired knowledge from a fixed old model maintained at a certain moment to the new model currently being trained via adding consistency regularization between them. Existing works in this view ignore the design of a consistency regularization in line with the task characteristics of person ReID, \textit{i}.\textit{e}., learning to rank. This problem is addressed in this paper via our proposed RCL. (2) \textit{Sample storing/generation based methods} recall old knowledge on the stored \cite{maracani2021recall,riemer2018learning,verwimp2021rehearsal} or synthetic \cite{wu2018memory,cheraghian2021synthesized} data, interleaved with the training on new collected data. They aim to strike a balance between the knowledge learned on old and new data respectively, lacking explicit consideration on the coordination between different optimization objectives at the task level. (3) \textit{Dynamic model based methods} \cite{rusu2016progressive,cortes2017adanet,xiao2014error} handle expanding data/knowledge with progressively modified model architecture. Our framework is based on combining the first two categories.

\begin{figure*}[!t]
	\centering
	\includegraphics[width=0.96\textwidth]{figures/pipeline.png}
	\caption{The overall architecture of the proposed scheme \textit{CLUDA-ReID}~for \textit{LUDA person ReID}. In \textit{CLUDA-ReID}, we set up a memory buffer to store samples that have been seen/trained as the old data, and preserve a momentum-updated model as the historical model to accumulate acquired knowledge over time. We fed both the old data (dashed lines) and new data (solid lines) into the current model and the historical model for capturing new knowledge for timely adaptation while enhancing the memorization of old knowledge. We achieve coordinated anti-forgetting and adaptation learning via our proposed Coordinated Data Replay and Relational Consistency Learning. }
	\label{fig:framework}
\end{figure*}

\section{Proposed Problem: LUDA Person ReID}
\label{sec:problem}

\subsection{Problem Definition}
\label{subsec:definition}

Consider a realistic scenario: a person ReID model or system is offline trained on labeled source data, then deployed in new environments wherein new data arrives continuously. Usually, the new data has domain gaps with the source data and is hard to be annotated in time. \textit{Can we utilize such unlabeled new data to perform continual domain adaptation so that the deployed model can quickly adapt to new environments?} This motivates the problem of LUDA person ReID.

For \textit{LUDA person ReID}~task, we assume that a labeled source dataset $\mathcal{X}^s\!=\!\{(\textbf{x}_i^s, y_i^s)|_{i=1}^{N_s}\}$ is available at first, which comprises $N_s$ samples $\textbf{x}_i^s\!\in\!\mathcal{X}^s$ with corresponding ID labels $y_i^s\!\in\!\mathcal{Y}_s$. The target stream is divided into $T$ splits over time, denoted by $\mathcal{X}^t\!=\!\{\textbf{x}_i^t|_{i=1}^{N^j_t}\}_{j=1}^T$. For an interval of time indexed by $j$ (called ``stage'' in the following), $N^j_t$ new unlabeled samples $\textbf{x}_i^t$ are collected in this stage and compose a set $\mathcal{X}_j^t$. After each interval/stage, $\mathcal{X}_j^t$ is used to automatically update the deployed person ReID model for continual adaptation, in the sense that we need not wait to collect the entire target dataset or train the model from scratch on the combination of newly collected and historical data many times.

\subsection{Learning Setups}
\label{subsec:setups}

In the real world, the statistics of target streams may vary over time in different degrees, corresponding to different scenarios as follows: (i) In the \textit{stationary target scenario}, such as fixed cameras in retail, supermarket, \textit{etc.}, only identities increase as new data comes while the domain/style characteristics maintain a relatively stable state. We can suppose that there are no distribution shifts between the $\mathcal{X}_j^t$ in different stages. (ii) In the \textit{dynamic target scenario}, such as cameras mounted in cars, drones, \textit{etc.}, the number of seen identities keeps increasing and their statistic characteristics also vary over time, leaving this setup being not only class-incremental but also  domain-incremental.

\section{Proposed Solution: A Coordinated Scheme}

\subsection{Overall Pipeline}
\label{sec:overall}

In our proposed scheme, we first pre-train the person ReID model on labeled source data $\mathcal{X}^s\!=\!\{(\textbf{x}_i^s, y_i^s)|_{i=1}^{N_s}\}$. Then, we deploy the pre-trained model in the target environment and update the model with target stream data $\mathcal{X}^t\!=\!\{\textbf{x}_i^t|_{i=1}^{N^j_t}\}_{j=1}^T$ for achieving lifelong UDA. For each sample, from $\mathcal{X}^s$ or $\mathcal{X}^t$, we first use a backbone network to extract its corresponding feature tensor, then adopt a global spatial GeM pooing \cite{radenovic2018fine} on this feature tensor to obtain a feature vector as its final ID representation. As common practices in this field \cite{luo2019bag,zhang2020relation,he2020fastreid}, we employ a triplet loss and a cross-entropy based classification loss (each ID is taken as one category) as person ReID losses on the extracted feature vector for training.
In the $j$-th stage, to acquire new knowledge for unsupervised domain adaptation, we train a timely updated model (called ``current model'' for brevity) on $\mathcal{X}_j^t\!=\!\{\textbf{x}_i^t|_{i=1}^{N^j_t}\}$ with person ReID losses. Here, we generate or update the pseudo ID labels for $\mathcal{X}_j^t$ via a clustering algorithm every few training epochs.

Meanwhile, we recall old knowledge via data replay and knowledge distillation for anti-forgetting. To this end, we set up a memory buffer with a limited size for data replay and maintain a historical model for knowledge distillation. Specifically, we sample historical data stored in the memory to update the current model together with new data in each iteration, and store new samples into the memory at the end of each stage. Besides, we perform knowledge distillation from the maintained historical model to the current model by adding consistency constraints on their outputs.

\subsection{Coordinated Data Replay}
\label{sec:CDR}

Recalling old knowledge (for anti-forgetting) and capturing new knowledge (for adaptation) correspond to two different objectives, thus can be viewed as two ``tasks''. However, as we discussed in our introduction, these two tasks do not have to conflict with each other. In fact, they can be coordinated to enhance the model's generalization capability for unseen identities and new domains.
Thus, we propose Coordinated Data Replay (CDR) to coordinate the optimization of anti-forgetting and adaptation.

The trainable network parameters of a \textit{LUDA person ReID}~model comprise a backbone network $\theta$ (such as the ResNet-50 in Fig.\ref{fig:framework}) for ReID feature extraction, and a classifier $\phi$ for adding the classification loss. In the learning stage of lifelong unsupervised domain adaptation, the optimization objective of \textbf{adaptation} can be formulated as:
\begin{equation}\label{eq:1}
    \min_{\theta, \phi}{\mathcal{L}_{Adap}(\theta, \phi)} = \min_{\theta, \phi}{\mathcal{L}_{Tri}(\theta) + \mathcal{L}_{Cls}(\theta, \phi)},
\end{equation}
where $\mathcal{L}_{Tri}(\theta)$ is the triplet loss applied to the extracted feature vectors of new data, $\mathcal{L}_{Cls}(\theta, \phi)$ denotes the Cross-Entropy based classification loss applied to the logits of new data. Here, the new data refers to the training batch sampled from $\mathcal{X}_j^t$ in the $j$-th stage.

To recall previously learned knowledge, we set up a limited-size memory buffer for storing data to replay these samples. This memory is updated at the end of each stage with a modified reservoir sampling algorithm. The classical reservoir sampling algorithm \cite{vitter1985random} is designed to randomly keep $N$ samples in memory from a sequence, with equal probability for each one. Here, to preserve as diverse ID information as possible, we modify the reservoir algorithm from an instance-wise one to an ID-wise one. (See more details in the supplementary.) With both the stored old data and the new data together, the optimization objective of \textbf{anti-forgetting} can be formulated as:
\begin{equation}\label{eq:2}
    \min_{\theta, \phi}{\mathcal{L}_{AntiF}(\theta,\phi)} = \min_{\theta, \phi}{\mathcal{L}_{KD}(\theta,\phi)\!+\!\mathcal{L}_{Tri}(\theta)\!+\!\mathcal{L}_{Cls}(\theta,\phi)},
\end{equation}
where $\mathcal{L}_{KD}(\theta)$ represents the knowledge distillation loss for transferring already acquired knowledge from the maintained historical model to the current model, applied to the inferenced results of both old and new data. We design a novel knowledge distillation loss in line with person ReID task and leave its detailed introduction in the subsequent section. $\mathcal{L}_{Tri}(\theta)$ and $\mathcal{L}_{Cls}(\theta, \phi)$ denote the triplet loss and the classification loss respectively, similar to Eq.(\ref{eq:1}). Note that they are both applied for replaying the old data stored in the memory buffer. The general optimization objective of lifelong learning with the regular data replay is:
\begin{equation}\label{eq:3}
    \min_{\theta, \phi}\ {\mathcal{L}_{Adap}(\theta, \phi)} + {\mathcal{L}_{AntiF}(\theta, \phi)}.
\end{equation}

In our proposed CDR, we aim to align two different optimization objectives as described above via a meta-optimization strategy. We draw inspiration from Model-Agnostic Meta-learning (MAML) \cite{finn2017model} which splits the optimization into meta-train and meta-test processes and then involves a meta-update with a gradient-through-gradient mechanism such that the model is updated along an aligned direction between the meta-train and the meta-test. To coordinate \textbf{adaptation} and \textbf{anti-forgetting}, we propose to treat these two tasks as meta-train and meta-test in each iteration of parameter updating rather than splitting samples into meta-train and meta-test as in \cite{li2018learning,riemer2018learning}. With the task of adaptation as meta-train while the task of anti-forgetting as meta-test, the overall meta-optimization objective is:
\begin{equation}\label{eq:4}
\begin{aligned}
    &\min_{\theta, \phi}{\mathcal{L}_{Adap}(\theta, \phi)} + \mathcal{L}_{AntiF}(\theta - \Delta\theta, \phi - \Delta\phi), \\
    &\Delta\theta = \alpha\nabla_{\theta}\mathcal{L}_{Adap}(\theta, \phi),\
    \Delta\phi = \alpha\nabla_{\phi}\mathcal{L}_{Adap}(\theta, \phi),
\end{aligned}
\end{equation}
where $\alpha$ denotes the meta-learning rate. With the meta-optimization objective, the optimization of anti-forgetting is considered through the gradient calculated upon the pre-updated parameters after the meta-train process via one gradient descent step: $\theta' \gets \theta - \alpha\nabla_{\theta}\mathcal{L}_{Adap}(\theta, \phi)$ and $\phi' \gets \phi - \alpha\nabla_{\phi}\mathcal{L}_{Adap}(\theta, \phi)$. As common practices in \cite{finn2017model,dou2019domain} for the efficient implementation of meta-learning, we omit higher-order items during performing gradient back-propagation.

One natural question may raise: \textit{Why can the meta-optimization objective presented in Eq.(\ref{eq:4}) coordinate anti-forgetting  and adaptation for lifelong learning?} Inspired by the analysis in \cite{li2018learning}, we recall the first-order Taylor expansion for a general function $f(x,y)$ of two variables at $x=x_0, y=y_0$ as:
\begin{equation}\label{eq:5}
    f(x,y)\!=\!f(x_0, y_0)\!+\!f'_x(x_0, y_0)(x-x_0)\!+\!f'_y(x_0, y_0)(y-y_0),
\end{equation}
where $x_0$ is any point close to $x$. We instantiate the function $f$ as $\mathcal{L}_{AntiF}$, and set $x$ and $y$ to be $\theta-\alpha\nabla_{\theta}\mathcal{L}_{Adap}(\theta, \phi)$ and $\phi-\alpha\nabla_{\phi}\mathcal{L}_{Adap}(\theta, \phi)$, respectively. Further, we choose $x_0$ and $y_0$ to be $\theta$ and $\phi$, respectively. Thus, we can replace the second term $\mathcal{L}_{AntiF}(\theta - \Delta\theta, \phi - \Delta\phi)$ in Eq.(\ref{eq:4}) with its corresponding first-order Taylor expansion, and reformulate the overall meta-optimization objective of Eq.(\ref{eq:4}), as:
\begin{equation}\label{eq:6}
\begin{aligned}
    \min_{\theta, \phi}\ &\ {\mathcal{L}_{Adap}(\theta, \phi)} + \mathcal{L}_{AntiF}(\theta, \phi) \\
    &- \alpha\nabla_{\theta}\mathcal{L}_{Adap}(\theta, \phi)\nabla_{\theta}\mathcal{L}_{AntiF}(\theta, \phi) \\
    &- \alpha\nabla_{\phi}\mathcal{L}_{Adap}(\theta, \phi)\nabla_{\phi}\mathcal{L}_{AntiF}(\theta, \phi).
\end{aligned}
\end{equation}

Compared to the general optimization objective in Eq.(\ref{eq:3}), the above meta-optimization objective, \textit{i}.\textit{e}., Eq.(\ref{eq:6}), additionally maximizes the dot product of gradients of $\mathcal{L}_{Adap}(\theta, \phi)$ and $\mathcal{L}_{AntiF}(\theta, \phi)$ with respect to $\theta$ and $\phi$. Therefore it encourages both the feature extractor and the classifier to be optimized along a consistent/aligned direction between anti-forgetting  and adaptation so that these two tasks are coordinated for more effective life-long learning.

\subsection{Relational Consistency Learning}
\label{sec:RCL}

As aforementioned, a classical method to alleviate the catastrophic forgetting problem is to transfer the knowledge from a model preserved at a certain historical time instance to the current model via knowledge distillation \cite{li2017learning,iscen2020memory,wu2021generalising}. These methods are indeed effective but leave two problems for \textit{LUDA person ReID}: 1) The task characteristics and objectives of person ReID, \textit{i}.\textit{e}., learning to rank, have not been sufficiently considered in designing the loss functions for knowledge distillation; 2) The old model preserved at a certain historical moment lacks sufficient robustness for the potential training perturbation over time. We propose Relational Consistency Learning (RCL) to address these problem towards more effective knowledge distillation in line with the task characteristics of \textit{LUDA person ReID}.

We first introduce the idea of \textit{temporal ensembling} from semi-supervised learning \cite{tarvainen2017mean} into \textit{LUDA person ReID}~to build the historical model. Specifically, we initialize the historical model with the weights of source pre-trained model, then update it via a weighted summation where a momentum scalar $\beta$ is applied to historical model while $1-\beta$ is applied to the current model.

The goal of person ReID is learning to rank. In line with this goal, we design a regular term to encourage the historical model and the current model to output consistent ranking results for input samples. In each meta-optimization step, one batch of historically stored samples (abbreviated as ``old batch'', denoted by $\mathcal{B}^{o}$) is sampled from the memory while another batch of newly collected samples (abbreviated as ``new batch'', denoted by $\mathcal{B}^{n}$) is sampled from the current stream. Both $\mathcal{B}^{o}$ and $\mathcal{B}^{n}$ are fed into the historical model and the current model to get their corresponding ID feature vectors inferred by these two models.

\begin{figure*}[!t]
	\centering
	\includegraphics[width=0.99\textwidth]{figures_try/Figure1.png}
	\vspace{-0.30cm}
	\caption{Effectiveness analysis of \textit{CLUDA-ReID}~on the source domain (PersonX) and on the target domain (Market1501) in the stationary target scenario. In ``\textit{Stage-wise UDA (Base.)}'', we fine-tune the pre-trained model using the data collected in the current stage sequentially, without explicit considerations on anti-forgetting. In ``\textit{Base.+Data Replay}'', the data is stored into a memory buffer for replaying, wherein $\mathcal{L}_{Tri}$ and $\mathcal{L}_{Cls}$ are applied to both old data and new data for joint training, without $\mathcal{L}_{KD}$ used. ``\textit{Base.+CDR}'' denotes the model using our proposed CDR as in Eq.(\ref{eq:4}) (wherein $\mathcal{L}_{KD}$ is not adopted). In ``\textit{Base.+CDR+KL Reg.}'', we apply $\mathcal{L}_{KL}$ to both old and new data to implement $\mathcal{L}_{AntiF}$ in Eq.(\ref{eq:4}). In ``\textit{Base.+CDR+RCL}'', we further apply the proposed $\mathcal{L}_{Rel.}$ to both old and new data to achieve our proposed RCL. ``All-in-one UDA'' refers to the model combining all available target domain data for regular UDA training.}
    \vspace{-0.30cm}
	\label{fig:figure1}
\end{figure*}

We denote the feature vectors of the $i$-th and the $j$-th samples inferred by the current model as $\mathbf{f}_i^c$ and $\mathbf{f}_j^c$, respectively. Likewise, $\mathbf{f}_i^h$ and $\mathbf{f}_j^h$ represent their corresponding feature vectors extracted by the historical model. The relation/affinity between the $i$-th and the $j$-th samples inferred by the current model can be calculated by $r_{i,j}^c=\mathbf{f}_i^{c\top}\mathbf{f}_j^{c}/(\left\|\mathbf{f}_i^{c}\right\|_2\left\|\mathbf{f}_j^{c}\right\|_2)$. The relation/affinity inferred by the historical model $r_{i,j}^h$ is computed in the same way. As the core of our RCL, the regular term on inter-instance relations can be formulated as:
\begin{equation}\label{eq:7}
\mathcal{L}_{Rel.} = \sum_{i, j \in \mathcal{B}^{n}}(r_{i,j}^c-r_{i,j}^h)^2\!+\!\sum_{i', j' \in \mathcal{B}^{o}}(r_{i',j'}^c-r_{i',j'}^h)^2.
\end{equation}
We empirically find that merging the old batch $\mathcal{B}^{o}$ and the new batch $\mathcal{B}^{n}$ into one to calculate such regular term delivers very close performance to the version in Eq.(\ref{eq:7}). To be computation-efficient, we propose to calculate the affinity matrix for $\mathcal{B}^n$ and $\mathcal{B}^o$ individually. This regular term plays the regularization role in transferring the knowledge from the historical model to the current model on learning relative relations, which is required by ranking. Complementary to this, we additionally add another regular term to transfer the knowledge on learning absolute ID-related features, which is formulated as:
\begin{equation}\label{eq:8}
\mathcal{L}_{KL} = \sum_{i \in \mathcal{B}^{n}\cap\mathcal{B}^{o}}{KL}(\textbf{g}_{i}^c \| \textbf{g}_{i}^h),
\end{equation}
where $KL(\cdot\|\cdot)$ denotes the Kullback Leibler (KL) divergence distance between two distributions. $\textbf{g}_i^c\!=\!\sigma(\phi_c(\mathbf{f}_i^c))$ and $\textbf{g}_i^h\!=\!\sigma(\phi_h(\mathbf{f}_i^h))$ denotes the classification logits inferred by the current model and the historical model, respectively. Here, $\phi_c(\cdot)$ and $\phi_h(\cdot)$ are the corresponding classifiers while $\sigma(\cdot)$ is the Softmax function. As a result, in our proposed RCL, we implement the knowledge distillation loss $\mathcal{L}_{KD}(\theta,\phi)$ in Eq.(\ref{eq:2}) as: $\mathcal{L}_{KD} = \mathcal{L}_{Rel.} + \mathcal{L}_{KL}$.

\section{Experiments}
\label{sec:experiment}

\subsection{Datasets and Evaluation Metrics}

We employ a synthetic dataset PersonX (PX)~\cite{sun2019dissecting} for source pre-training and three public real-world image datasets Market1501 (MA)~\cite{zheng2015scalable}, CUHK-SYSU (SY)~\cite{xiao2017joint}, MSMT17 (MS)~\cite{wei2018person} for unsupervised fine-tuning. This shows a privacy-friendly practice since no ID annotations of real persons are required. Besides, for unseen-domain generalization evaluation, we build a new dataset called MMP-Retrieval upon the training and validation splits of MMPTRACK dataset released in ICCV 2021 multi-camera multiple people tracking workshop. MMP-Retrieval comprises 21 people in 5 simulated environments.
We have released it as aforementioned.
More details of the used public datasets can be found in the supplementary.
We use the cumulative matching characteristics (CMC) at Rank-1 (R-1) and mean average precision (mAP) for evaluation.

\subsection{Implementation Details}
Following common practices \cite{zhang2019densely,luo2019bag,he2020fastreid} in person ReID, we adopt ResNet50~\cite{he2016deep} pretrained on Imagenet \cite{deng2009imagenet} as our backbone. Similar to~\cite{luo2019bag}, the last spatial down-sampling in the ``conv5\_x'' block is removed. We resize images to 256 $\times$ 128, and set the batch size of both $\mathcal{B}^o$ and $\mathcal{B}^n$ to 64, including 16 identities and 4 images per identity for each batch. We adopt the commonly used data augmentation strategies of horizontal flipping, random cropping. Following~\cite{ge2020selfpaced,zheng2021exploiting}, we use the clustering algorithm of DBSCAN to generate pseudo labels. Unless otherwise specified, we train the model on the source domain for 60 epochs, and train the model on the stationary/dynamic target streams for 40/60 epochs per stage respectively. We adopt Adam~\cite{kingma2014adam} optimizer with its learning rate initialized as $3.5\!\times\!10^{-4}$. The size of memory buffer is set to 512. We provide the ablation study for the memory buffer size and more implementation details in the supplementary.

\subsection{Evaluation in the Stationary Target Scenario}

\noindent\textbf{Experiment configuration.}
We evaluate our proposed \textit{CLUDA-ReID}~in the first scenario introduced in Sec.\ref{subsec:setups}. We employ the PersonX~\cite{sun2019dissecting} as the source for supervised pre-training while employing the Market1501~\cite{zheng2015scalable} for performing LUDA. We sample 750 identities of the training data of Market1501, and uniformly split them into 5 subsets for a 5-stage LUDA training. At the end of each stage, we compute the R-1 and mAP accuracy on the entire test set of the source data and the target data to respectively assess the model capacities on anti-forgetting and adaptation.

\noindent\textbf{Effectiveness of \textit{CLUDA-ReID}.} We start with a basic model ``\textit{Stage-wise UDA}'' without anti-forgetting as the base model, then incrementally add different components upon it to assess their effectiveness.
As shown in Fig.\ref{fig:figure1}, the performances on the source domain (PersonX) and the target domain (Market1501) reflect the \textit{anti-forgetting} ability and the timely \textit{adaptation} ability of models, respectively. Except for \textit{All-in-one UDA}, all other models are trained stage by stage as new data arrives over time. \textit{Stage-wise UDA} does not explicitly consider the optimization for anti-forgetting. It suffers from a dramatic performance drop on the source domain data and is inferior to adapting to the target domain. As the results of \textit{Base.+Data Replay} show, data replaying boosts the performance on both source and target data by revisiting old data. Relative to \textit{Stage-wise UDA}, the model \textit{Base.+CDR} achieves significant improvements. This demonstrates our proposed CDR effectively promotes both the old knowledge memorization and the new knowledge capturing through their coordination. Upon our proposed coordinated optimization scheme, we further enhance the anti-forgetting ability by adding KL consistency regularization $\mathcal{L}_{KL}$ (KL Reg.) and relational consistency regularization $\mathcal{L}_{Rel.}$. The comparison of the model \textit{Base.+CDR+RCL} to the model \textit{Base.+CDR} shows striking improvements of our proposed RCL, thanks to the loss function designs on old knowledge distillation/inheritance in line with the task objective of person ReID.

\begin{figure}[!t]
	\begin{center}
		\includegraphics[width=0.98\linewidth]{figures_try/Figure3.png}
	\end{center}
	\vspace{-0.50cm}
	\caption{The ablation study on the meta-optimization strategies. $\mathcal{L}_{KD}$ denotes the loss function for knowledge distillation. $\mathcal{B}^{o}$ and $\mathcal{B}^{n}$ denotes the batches of old data and new data, respectively. ``M-tarin'' is short for meta-train, ``M-test'' is short for meta-test. In all shown models, the person ReID losses ($\mathcal{L}_{Tri}$ and $\mathcal{L}_{Cls}$) applied on the new data are adopted for the meta-train while the person ReID losses applied to the old data are adopted for the meta-test. }
	\vspace{-0.50cm}
	\label{fig:ablation-meta}
\end{figure}

\noindent\textbf{Ablation study for meta-optimization strategies.} In this part, we empirically study the practices of using different data $\mathcal{B}^{o}$ and $\mathcal{B}^{n}$ for $\mathcal{L}_{KD}$ in meta-optimization. As shown in Fig.\ref{fig:ablation-meta}, by comparing our proposed scheme ($\mathcal{L}_{KD}$ on $\mathcal{B}^{o}\cup\mathcal{B}^{n}$ for meta-test) to the one applying $\mathcal{L}_{KD}$ to $\mathcal{B}^{o}$ for meta-test and the one applying $\mathcal{L}_{KD}$ to $\mathcal{B}^{n}$ for meta-test, we find that both $\mathcal{B}^{o}$ and $\mathcal{B}^{n}$ can contribute to the knowledge distillation for anti-forgetting. Besides, we further compare our proposed task-oriented meta-train/meta-test splitting in CDR with the data-based meta-train/meta-test splitting (\textit{i}.\textit{e}., $\mathcal{L}_{KD}$ on $\mathcal{B}^{n}$ for meta-train while $\mathcal{L}_{KD}$ on $\mathcal{B}^{o}$ for meta-test) as in \cite{li2018learning,riemer2018learning}. We find our task-oriented splitting of meta-train and meta-test is more effective in coordinating the optimization objectives of anti-forgetting and adaptation.

\begin{figure}[!t]
	\begin{center}
		\includegraphics[width=0.98\linewidth]{figures_try/Figure2.png}
	\end{center}
	\vspace{-0.50cm}
	\caption{The ablation study on different design choices for data replay, historical model updating and consistency regularization designs. This is conducted in the stationary target scenario. ``\textit{Data Replay (FIFO)}'' denotes the scheme storing seen samples into the memory buffer with the rule of First-In-First-Out. ``\textit{Instance-wise RS}'' refers to the regular version of Reservoir Sampling as introduced in \cite{vitter1985random}. ``\textit{Old Model (wo. momentum)}'' denotes we preserve a model at a certain old moment as the historical model. ``\textit{only KL}'' and ``\textit{only Rel.}'' means using $\mathcal{L}_{KL}$ and using $\mathcal{L}_{Rel.}$ as the knowledge distillation loss $\mathcal{L}_{KD}$, respectively.}
	\vspace{-0.50cm}
	\label{fig:design-choice}
\end{figure}

\noindent\textbf{Ablation study for different design choices.} We conduct an ablation study on different design choices in \textit{CLUDA-ReID}~by replacing the components in the \textit{Full Model} of \textit{CLUDA-ReID}~(the same as \textit{Base.+CDR+RCL} in Fig.\ref{fig:figure1}) with other design choices. The results are shown in Fig.\ref{fig:design-choice}. Compared to the First-In-First-Out (FIFO) rule and the regular (instance-wise) reservoir sampling algorithm, our modified ID-wise reservoir sampling adopted in \textit{Full Model} is superior since it enables stored samples to be diverse and ID-balanced. Compared to the historical model preserved at a certain historical moment, our design in \textit{Full Model} is more effective thanks to the temporal averaging via the momentum updating strategy. In terms of the loss function design for consistency learning, we find $\mathcal{L}_{KL}$ and $\mathcal{L}_{Rel.}$ are complementary for the old knowledge distillation from the historical model to the current model, since $\mathcal{L}_{KL}$ aims to learn absolute ID-related features while $\mathcal{L}_{Rel.}$ captures the relative information about inter-instance relations.

\begin{table*}[tb]
	\centering
	\footnotesize
	\vspace{-0.20cm}
	\resizebox{\linewidth}{!}{
		\begin{tabular}{l||cc||cc||cc||cc||cc||cc}
			\Xhline{3\arrayrulewidth}
			          \multicolumn{1}{c||}{\multirow{2}{*}{Methods}}& \multicolumn{2}{c||}{MA (t=1)} & \multicolumn{2}{c||}{SY (t=2)} & \multicolumn{2}{c||}{MS (t=3)} & \multicolumn{2}{c||}{MA (t=4)} & \multicolumn{2}{c||}{SY (t=5)} & \multicolumn{2}{c}{MS (t=6)} \\ \cline{2-13}
          & R-1 & mAP & R-1 & mAP & R-1 & mAP & R-1 & mAP & R-1 & mAP & R-1 & mAP \\ \Xhline{2\arrayrulewidth}
        Stage-wise UDA (Base.) & 72.23 & 49.32 & 64.59 & 60.76 & 19.80 & 7.24  & 72.92 & 50.46 & 63.93 & 60.29 & 20.23 & 7.18 \\
        Base. + Data Replay & 72.51 & 50.82 & 66.22 & 61.75 & 20.98 & 7.86  & 74.12 & 51.03 & 69.43 & 64.44 & 21.73 & 8.48 \\
        Base. + CDR & 73.12 & 51.11 & 69.23 & 64.54 & 23.56 & 9.33  & 76.93 & 53.46 & 73.46 & 69.29 & 25.90 & 10.43 \\
        Base. + CDR + KL Reg. & 74.24 & 51.76 & 71.55 & 67.88 & 26.16 & 9.94  & 79.26 & 59.48 & 76.76 & 74.45 & 29.79 & 12.44 \\
        \rowcolor[gray]{0.9}Base. + CDR + RCL  & \textbf{75.21} & \textbf{52.96} & \textbf{75.38} & \textbf{71.35} & \textbf{28.67} & \textbf{11.04} & \textbf{82.79} & \textbf{64.87} & \textbf{81.86} & \textbf{78.39} & \textbf{33.91} & \textbf{14.64} \\
        \hline
        All-in-one UDA & 85.12 & 68.59 & 86.76 & 84.70 & 36.37 & 17.84 & 85.12 & 68.59 & 86.76 & 84.70 & 36.37 & 17.84 \\
			\Xhline{3\arrayrulewidth}
		\end{tabular}
	}
	 \vspace{-0.20cm}
	 \caption{Adaptation performance (\%) evaluation in the dynamic target scenario. We test the model instantly at the end of each stage, on its corresponding test set. The training order is PX$\rightarrow$MA$\rightarrow$SY$\rightarrow$MS$\rightarrow$MA$\rightarrow$SY$\rightarrow$MS. Our \textit{CLUDA-ReID}~is marked in gray shading.}
	 \vspace{-0.30cm}
	\label{table:adaptation}
\end{table*}

\begin{table*}[tb]
	\centering
	\footnotesize
	\resizebox{\linewidth}{!}{
		\begin{tabular}{l||cc|cc|cc||cc|cc|cc}
		\Xhline{3\arrayrulewidth}
          \multicolumn{1}{c||}{\multirow{3}{*}{Methods}} & \multicolumn{6}{c||}{t=3}                                       & \multicolumn{6}{c}{t=6} \\ \cline{2-13}
          & \multicolumn{2}{c|}{PX} & \multicolumn{2}{c|}{MA} & \multicolumn{2}{c||}{SY} & \multicolumn{2}{c|}{PX} & \multicolumn{2}{c|}{MA} & \multicolumn{2}{c}{SY} \\ \cline{2-13}
          & R-1    & mAP   & R-1    & mAP   & R-1    & mAP   & R-1    & mAP   & R-1    & mAP   & R-1    & mAP \\ \hline
    Stage-wise UDA (Base.) & 52.71 & 30.76 & 49.76 & 24.59 & 52.97 & 55.99 & 46.92 & 24.59 & 50.63 & 19.64 & 51.17 & 51.65 \\
    Base. + Data Replay & 56.33 & 38.21 & 57.46 & 31.73 & 54.46 & 56.33 & 48.78 & 27.33 & 60.34 & 32.37 & 58.93 & 57.11 \\
    Base. + CDR & 63.93 & 44.43 & 61.43 & 33.46 & 60.52 & 60.43 & 58.46 & 39.64 & 65.34 & 39.46 & 65.33 & 62.77 \\
    Base. + CDR + KL Reg. & 73.75 & 54.33 & 65.83 & 40.30 & 68.55 & 62.11 & 65.45 & 47.43 & 71.43 & 44.10 & 72.33 & 69.48 \\
    \rowcolor[gray]{0.9}Base. + CDR + RCL & \textbf{80.66} & \textbf{69.48} & \textbf{69.97} & \textbf{45.60} & \textbf{73.24} & \textbf{69.44} & \textbf{76.47} & \textbf{58.23} & \textbf{76.25} & \textbf{49.12} & \textbf{78.28} & \textbf{75.43} \\ \hline
    Pre-trained Model (t=0) & 94.86 & 86.34 & 54.04 & 27.67 & 46.52 & 48.62 & 94.86 & 86.34 & 54.04 & 27.67 & 46.52 & 48.62 \\
    All-in-one UDA & 40.43 & 16.44 & 85.12 & 68.59 & 86.76 & 84.70 & 40.43 & 16.44 & 85.12 & 68.59 & 86.76 & 84.70 \\

    \Xhline{3\arrayrulewidth}
    \end{tabular}%
	}
	\vspace{-0.20cm}
	\caption{Anti-forgetting performance (\%) evaluation in the dynamic target scenario. We test the model on the test-sets of all domains at the end of the 3rd stage (t=3) and the 6th stage (t=6). The training order is PX$\rightarrow$MA$\rightarrow$SY$\rightarrow$MS$\rightarrow$MA$\rightarrow$SY$\rightarrow$MS.  Note that we omit the MS dataset for brevity because it appears in the final, whose results can not reflect the anti-forgetting ability. \textit{CLUDA-ReID}~is marked in gray.}
	\vspace{-0.40cm}
	\label{table:anti-forgetting}
\end{table*}

\subsection{Evaluation in the Dynamic Target Scenario}

\noindent\textbf{Experiment configuration.} We evaluate \textit{CLUDA-ReID}~in the scenario with dynamic target stream introduced in Sec.\ref{subsec:setups}. This scenario is not only ID-incremental but also domain-incremental. One synthesis dataset PersonX (PX) is employed to simulate the source domain while three real-world datasets Market1501 (MA), CUHK-SYSU (SY), and MSMT17 (MS) are employed to simulate the dynamic target domain. We perform LUDA training on MA, SY, and MS domains in order, and repeat this process again to simulate the domain recurring cases in the real-world dynamic scenario. There are 6 stages in all for LUDA training in our experiment. Each stage includes a sub-set of 350 identities selected from the corresponding dataset via a random sampling without replacement. Furthermore, we also evaluate the model at the end of the final stage on MMP-Retrieval to assess its generalization ability on unseen domains.

\noindent\textbf{Adaptation performance.} We evaluate the models at the end of each stage. As shown in Tab.\ref{table:adaptation}, compared to the scheme \textit{Stage-wise UDA (Base.)}, the scheme \textit{Base.+CDR} achieves 0.89\%/1.79\%, 4.64\%/3.78\%, 3.76\%/2.09\% improvements in R-1/mAP on MA, SY and MS respectively when these domains first appear, and achieves 4.01\%/3.00\%, 9.53\%/9.00\%, 5.67\%/3.25\% improvements in R-1/mAP on MA, SY and MS respectively when these domains show up for the second time. The scheme \textit{Base.+CDR+RCL} is superior to \textit{Stage-wise UDA} by 2.98\%/3.64\%, 10.79\%/10.59\%, 8.87\%/3.80\% respectively in R-1/mAP on MA, SY and MS when these domains first appear, by 9.87\%/14.41\%, 17.93\%/18.10\%, 13.68\%/7.46\% respectively in R-1/mAP on MA, SY and MS when they appear for the second time. These demonstrate the effectiveness of our proposed CDR and RCL in timely adapting to new environments. The improvements are especially significant when the similar or same domain re-appears thanks to the coordinated old knowledge memorization.

\noindent\textbf{Anti-forgetting performance.} We measure the performance at the end of the 3rd stage ( \textit{i}.\textit{e}., t=3, all domains are traversed once) and at the end of the 6th stage (\textit{i}.\textit{e}., t=6, all domains are seen for the second time), for evaluating the anti-forgetting ability of our proposed method. As shown in Tab.\ref{table:anti-forgetting}, relative to the model pre-trained on PX, the scheme \textit{Base.+CDR+RCL} ranks the first with the lowest performance degradation on PX at the end of the 3rd and the 6th stages. Besides, comparing the results in Tab.\ref{table:anti-forgetting} to the timely measured results in Tab.\ref{table:adaptation}, we find the scheme \textit{Base.+CDR+RCL} is of the lowest performance degradation over all domains. It demonstrates the effectiveness of our \textit{CLUDA-ReID}~in alleviating catastrophic forgetting.

\noindent\textbf{Generalization performance on unseen domains.} We evaluate the trained model directly on MMP-Retrieval. As shown in Fig.\ref{fig:unseen-domain}, the Rank-1 and mAP of \textit{Base.+CDR} and \textit{Base.+CDR+RCL} on MMP-Retrieval increases constantly as the LUDA training goes on. This demonstrates the effectiveness of our proposed CDR and RCL of \textit{CLUDA-ReID}~in improving the generalization ability for unseen domains through coordinated anti-forgetting and adaptation.

\begin{figure}[!t]
	\begin{center}
		\includegraphics[width=0.98\linewidth]{figures_try/Figure5.png}
	\end{center}
	\vspace{-0.50cm}
	\caption{Performance (\%) of unseen-domain generalization evaluation on our built MMP-Retrieval dataset.}
	\vspace{-0.50cm}
	\label{fig:unseen-domain}
\end{figure}

\section{Conclusion}
In this paper, we propose a new and practical task, \textit{LUDA person ReID}, which aims to enable person ReID models to achieve continuous domain adaptation using unlabeled streaming data. This facilitates exploiting increased samples and achieves timely adaptation for real-world streaming data. Besides, it helps privacy protection of customer data as the practices in our experiments. For this task, we design an effective scheme \textit{CLUDA-ReID}~in which the Coordinated Data Replay (CDR) and Relational Consistency Learning (RCL) are proposed to explicitly coordinate anti-forgetting and adaptation. We set up two practical evaluation schemes to simulate the real applications for method evaluation. Extensive experiment results demonstrate the effectiveness of \textit{CLUDA-ReID}~in achieving LUDA for scenarios with stationary or dynamic target streams and enhancing the generalization capacity on unseen domains.

{\small
\bibliographystyle{ieee_fullname}


\section{Introduction}

Researchers are looking for collaborations more than ever~\citep{beaver2001reflections, freeman20151,lariviere2015team,viana2013time}. Over the past few decades, team sizes have been increasing across many research fields in science, with scholars seeking collaborations to increase productivity, enrich knowledge by sharing experiences with colleagues, access new resources, attain higher impact, among many other reasons~\citep{bukvova2010studying, abramo2009research}. Projects bridging two or more fields are usually undertaken by larger teams with researchers from different disciplines. However, this is a relatively recent notion in Science and may not have spread uniformly across different disciplines as some areas incorporate collaborations in the research process most naturally than others~\citep{qin1997types}.

Collaborations can emerge in different contexts. Sometimes, it happens between graduate students, researchers affiliated to the same institutions, supervisors and supervised, etc.  In general, it is expected that authors have few collaborators at the beginning of their academic life, working predominantly with their supervisors more than other researchers. At the same time, different research fields may have different forms of measuring success (e.g., through productivity, citations, etc)~\citep{abramo2013individual,abramo2014you}. In addition to that, even though the use of similar metrics, such a task can be challenging once different disciplines also present different dynamics on how authors collaborate and beginning of the author's academic career.

In the literature, we can find various approaches aiming to quantify scholars' academic productivity, contribution and impact~\citep{garcia2012extension, abramo2014you, fenner2014altmetrics,correa2017patterns,brito2021associations}. However, these characterizations rarely take into account the authors' collaborations nuances, for example, how distributed are the citations across different team sizes. It is not trivial to quantify the individual impact on authors' success given such a variety of patterns and scales of collaborations. In this work, we aim to characterize authors productivity taking into account their collaborations, and compare these patterns across different disciplines.

We focus our analyses on understanding the effect of collaboration ties on different fields of study for established authors. In particular for researchers that already published at least a minimum number of papers. We consider the co-authorship of papers as a proxy for collaboration ties between authors. The analysis is then performed by means of author-level success metrics grouped by research fields of study. We use metrics such as the h-index, the number of citations, the number of publications and verify how they vary with the presence or absence of their prolific collaborator (or top collaborator). In this context, the top collaborator is the collaborator of an author whose coauthored papers received more citations. Our analysis is guided by the following research questions:
\begin{enumerate}
    \item How does the collaborations strength change in different fields of study?
    \item What is the impact of the top collaborator on authors' productivity?
\end{enumerate}

We found that the top collaborator influences to authors metrics have different patterns depending on their fields of study. In particular, three main patterns were observed across disciplines. First, humanities disciplines were found to have authors predominantly publishing single-authored papers or with a few collaborators. In this case, the top collaborator does not seem to have a strong influence on individual metrics. The second type of pattern was observed mostly for natural and applied disciplines, with authors having many collaborators but  with the top collaborator also not influencing much on their success metrics. The third group of patterns is composed of formal and applied sciences. These  disciplines display authors metrics highly influenced by their top collaborators. Interestingly, these tendencies are different for the specific case of highly cited authors since their success metrics are not highly influenced by their top collaborators. This pattern was evident across all studied fields of study.
Our results may shed light on the understanding of the importance of collaborations to researchers' visibility.

\section{Related works}
\label{sec:related}

\subsection{Comparing productivity in different disciplines}

In order to measure individual contributions, \cite{batista2006possible} normalized the traditional h-index by the average number of authors co-authoring papers in the h-set. The study compared Brazilian researchers in four disciplines, namely Physics, Chemistry, Biology and Mathematics.
Lists comprising the top 10 Brazilian authors were generated according to the traditional and the proposed normalized h-index. The overlap between these two lists was found to be field dependent. The highest overlap occurred in Mathematics (90\%), which indicates that the normalization barely impacts the rank. Conversely, Physics presented the lowest overlap value, 10\%. The results suggest that the consideration of the number of collaborators can highly impact the ranking of authors. \cite{batista2006possible} advocates, however, that the proposed normalization allows comparing h-indexes across fields.

\cite{ajiferuke2010citer} and \cite{ajiferuke2010comparison} proposed the use of \emph{citers} instead of citations to quantify academic influence. The idea is to count the number of individuals influenced by the author's work.
In addition to using traditional citation metrics such as citation counts, they also proposed the ch-index. This measurement is analogous to the traditional h-index.  But instead of counting citations, the authors count the number of \emph{citers} in publications. Therefore, ch-index = $x$ if $x$ is the highest integer for an author with $x$ publications that are cited by at least $x$ different \emph{citers}.
Significant correlations were found between the ch-index and  traditional citations metrics. However,  the ch-index seems to play a complementary and relevant role to investigate \emph{citers} and citations variations in different fields or to compare individuals with lower citation counts.

\cite{ajiferuke2010comparison} extended the study of \cite{ajiferuke2010citer} in order to compare \emph{citer} patterns across disciplines. In addition to the already mentioned metrics, they introduced the \emph{reciter} rate, which is defined as the number of unique authors citing a paper in a recurrent way. \cite{ajiferuke2010comparison}  analyzed 90 highly cited authors from three different disciplines: Social Sciences, Mathematical/Engineering Sciences, and Biological/Medical Sciences. In general, \emph{citer} and citation measurements were found to be correlated. However, some different patterns were found in different disciplines.
In Social Sciences, the number of authors per paper and reciter rates are lower than the other fields. The authors conclude that \emph{citer}-based metrics seem to be useful when the number of collaborations in the field is low. Conversely, in Mathematical, Engineering, Biological and Medical Sciences, {\emph{citer} and \emph{citation} metrics may present distinct values, even though they are correlated.
}
Visibility analysis based on \emph{citer/reciter} counts also possibilities to identify if a large number of citations corresponds to large number of authors being influenced.

\cite{ioannidis2016multiple} proposed a composition of indexes to quantify authors visibility. Their analysis a large list of citations metrics: number of citations, number of citations for the papers single-authored or first author, citations for single, first or last author, h-index and Schreiber co-authorship adjusted Hm-index. The combination of these indexes, referred to as Composite Score, was to used to
they identify the top $1000$ researchers in the considered dataset.
The authors found that an expressive number of notorious authors appear in their list while being absent in the list of top cited researchers. \cite{ioannidis2020updated} provided an updated version of the list of most influential researchers according to the Composite Score.

\subsection{Collaborations and productivity}

\cite{abramo2009research} advocates that the relationship between collaboration and productivity is not trivial. The authors studied the
Italian academic system across eight disciplines. To measure the productivity they used the total number of papers.
{The relevance (referred to as quality index) of the research conducted by a group of researchers was computed by considering not only the number of papers published, but also journals impact factor.}
The study found that the way collaborations influence productivity depends  on the research discipline. A strong correlation was observed for industrial and information engineering. In both mathematics and computer science fields, a correlation {between collaboration intensity and the average quality of the publications was found.}
{For most of the disciplines investigated, the average quality {index} turned out to be positively affected by inter-university collaborations.}
This work also found that interdisciplinary fields have usually display a more collaborative behavior.

\cite{lariviere2015team} investigated papers published in two broad fields of study: natural/medical sciences and social sciences/humanities. They studied collaboration at the author level. Inter-institutional and country collaborations were also investigated. The results showed that all three types of collaborations are increasing in both fields. Single authored papers were found to be less usual, mainly in the natural and medical sciences. Most of the papers were found to be result of inter-institutional collaborations.
Most importantly, \cite{lariviere2015team} showed that scientific impact seems to be influenced by the number of authors of the papers. They found no correlation between the diversity of authors country and impact.

\cite{abramo2015relationship} conducted a similar investigation for the Italian case, most of their findings confirmed results the results obtained by \cite{lariviere2015team}. The main conclusions pointed to the positive correlation between the number of authors of the papers and the number of citations received. Surprisingly, the correlating was even stronger for Social Sciences, Art, and Humanities.

\section{Methodology}
\label{sec:meth}

\subsection{Dataset and fields of study}

The Microsoft Academic Graph (MAG) is a large dataset containing scientific publications, citations, publications metadata such as authors and their institutions, journals, conferences, and fields of study~\citep{wang2020microsoft}. In this paper, we use papers published between 1950 and 2020. Because we are mostly interested in analyzing the collaborative patterns of mid-career and senior researchers, we considered only authors with at least $10$ papers and 200 citations in the dataset. We also disregarded papers co-authored by more than 10 authors, since the actual collaboration between authors in these cases is not trivial to measure. This same procedure has been applied in similar studies on collaboration networks~\citep{li2019reciprocity}.
{Figure \ref{fig:num-authors} of the Supplementary Information (SI) shows the distribution of the number of authors per publication.} After this filtering step, the resulting number of authors and papers was 2,630,275 and 243,030,343; respectively.

Because we are also interested in collaboration patterns arising from diverse fields, one must first classify authors in fields of study. Here we employ the MAG fields of study, which are defined for each paper. Fields and subfields are organized in a hierarchy represented by a directed acyclic graph. However, because some subfields can be too specific, we did not use them directly. For example, the topic \emph{Katz centrality} is a child of \emph{Network science}, which in turn is a child of \emph{Complex Networks}. Instead, we map papers to fields at a hierarchy level corresponding to the major knowledge fields, such as Mathematics, Computer Science and Physics. This is accomplished by first mapping all the subfields to \emph{top fields} by walking upwards (towards the root) across the hierarchy until we reach a field of study at the desired level (major areas of knowledge). For instance, papers associated to the \emph{Katz centrality} field of study, are mapped both to \emph{Mathematics} and \emph{Computer Science}. A list of fields considered in this work is illustrated in Figure \ref{fig:authorsdist}. To account for multiple fields of study associated to a paper (and subfields associated to multiple top fields) we also employ a weight $w_P(f_{top})$ indicating the relevance of the a top field of study $f_{top}$ to a paper $P$, which is computed as:

\begin{equation}
    w_P(f_{top}) = \frac{1}{|F_P|} \sum_{f\,\in\,F_P} \frac{|\textrm{Parents}(f) \cap \{f_{top}\}|}{|\textrm{Parents}(f)|},
\end{equation}
where $F_P$ is the set of subfields of paper $P$ and $\textrm{Parents}(f)$ is the set of top fields obtained after mapping a subfield $f$ upwards across the hierarchy.

The next step is assigning fields for authors based on their published papers. Here we considered each paper contribution as having the same relevance to define the authors field (and respective weight). Thus the weight $w_A'(f_{top})$ associating an author $A$ to a top field $f_{top}$ can be given by:
\begin{equation}
w_A'(f_{top}) = \sum_{p\,\in\,P_A} w_p(f_{top}),
\end{equation}
where $P_A$ is the list of papers published by author $A$.

Finally, the field of study of an author $A$ is the field of study with the highest weight:
\begin{equation}
F(A) = \argmax_{f_{top}}~w_A'(f_{top}).
\end{equation}

The obtained distribution of fields of study at the author-level is shown in Figure \ref{fig:authorsdist}. As expected, fields size are diverse. While Medicine and Biology comprises almost half of all authors, Environmental Sciences encompasses less than $0.1\%$ of the universe of considered researchers.

\begin{figure}[ht!]
    \centering
    \includegraphics[width=0.7\textwidth]{authors_distribution_2020.pdf}
    \caption{Number of authors  per field of study considering papers published between 1950 and 2020. We also show after each bar the corresponding fraction of authors in the respective field.

    }
    \label{fig:authorsdist}
\end{figure}

\subsection{Network of influencies}

We propose a directed and weighted network to quantify collaborations importance. All nodes and edges are established as in a traditional collaboration network~\citep{amancio2015topological,amancio2012use,pelacho2021analysis,viana2013time}. Two authors are linked if they co-authored at least one paper.  We now aim at quantifying for an author A how important is the collaborator B. Here we \emph{illustrate} the importance of collaborations in terms of citations of scientific works accrued in the collaboration. As we shall show, any relevance index can be used to define this weight.
If $c_{AB}$ is the number of citations accrued by papers co-authored by $A$ and $B$, and $c_A$ is the number of citations received by $A$, then the weight $w_{AB}$ is computed as
\begin{equation} \label{eq:besos}
    w_{AB} = \frac{c_{AB}}{c_A}.
\end{equation}
Note that $w_{AB}$ can be interpreted as the importance of the collaboration between $A$ and $B$ for researcher $A$. Note that $w_{AB}$ may not be equal to $w_{BA}$.
For this reason, we are given a directed network of influence. In our analysis, we assign the weight $w_{AB}$ for the edge with $A$ and $B$ and source and target nodes, respectively. Thus,
out-going edge weights are normalized, i.e.
$\sum_X w_{AX} = 1,$
where $X$ is co-author of $A$. The \emph{top-collaborator} of $A$, $T(A)$, is defined as:
\begin{equation} \label{eq:topa}
    T(A) = \argmax_X w_{AX}.
\end{equation}

Figure \ref{fig:toynet} illustrates an example of the network of influence with edges weights defined according to equation \ref{eq:besos}. $A$ and $B$ accrued respectively $c_A = 200$ and $c_B = 300$ citations. Papers co-authored by $A$ and $B$ received $c_{AB} = 50$ citations. Taking $A$ as reference, the importance of $B$ is $w_{AB} = 0.25$, i.e. $B$ contributes to $25\%$ of all citations received by $A$. Note that, in this example, $A$ contributes to only 17\% of the citations received by $B$, i.e. $w_{BA} = 0.17$. $B$ is more benefited from collaborations with $D$, since 50\% of citations to B comes from papers co-authored with $D$, i.e. $w_{BD} = 0.50$.
\begin{figure}[h]
    \centering
    \includegraphics[width=0.7\textwidth]{toynet.pdf}
    \caption{A toy example of a network of influences. Author A and B received $c_A = 200$ and $c_B = 300$ citations. Considering only the set of paper co-authored by $A$ and $B$, they received $c_{AB} = 50$ citations. For this reason, the importance of $B$ for author $A$ is $w_{AB} = 50/200 = 0.25$. Analogously, the importance of $B$ for $A$ is $w_{BA} = 50/300 = 0.17$.  }
    \label{fig:toynet}
\end{figure}

In addition to the number of citations, we also computed the weight in equation \ref{eq:besos} in terms of the productivity (i.e. number of published papers). Both productivity and visibility were also considered by using the h-index. Because we are interested in ranking authors, the traditional h-index is not enough because many authors may share the same h-index value. For this reason,
we used an extended version of the h-index that considers the distribution of citations in the $h$-set~\citep{garcia2012extension}. The extended version of the h-index ($h^{(E)}$) is computed as a sequence of $h$'s, i.e.  $h^{(E)} = \{h_1, h_2,h_3\ldots\}$. To compute $h^{(E)}$, papers are sorted in decreasing order of citations, as shown in Figure \ref{fig:extendedhindex}. $h_1$ corresponds to the traditional h-index. $h_2$ denotes the $h$-index computed in the $h_1$ set, but considering that every paper in the $h_1$ set has $h_1$ less citations than it actually has. This process in then recursively applied to compute $h_2, h_3\ldots$. A graphical illustration of this recursive process is illustrated in Figure \ref{fig:extendedhindex}.
\begin{figure}[h]
    \centering
    \includegraphics[width=0.55\textwidth]{hindex.pdf}
    \caption{Extended h-index example. The traditional h-index ($h_1$) is computed by using all set of papers (green square). $h_1$ is the side length of the largest square fitting within the distribution. The square has its left down vertex located at the position $(0,0)$.
    A recursive idea is used to computed $h_2$ and $h_3$. To compute $h_2$, we detect the side length of the largest square fitting within the distribution (see red square). In this case, the the considered square has its left down vertex located at the position $(0,h_1)$. The same procedure is applied to compute $h_3$, but now with the left down vertex located at the position $(0, h_1+h_2)$. }
    \label{fig:extendedhindex}
\end{figure}

\section{Results} \label{sec:results}

\subsection{Top-collaborator influence across fields}

Here we aim at understanding the importance of top collaborators in authors productivity and visibility. Because some patterns may arise due to the different characteristics of the disciplines, we first analyze the main features of our dataset to better understand if the patterns we find can be trivially explained by simple subfield characteristics. For this reason, we analyze the distribution of the number of citations, number of papers and authors' birth year of each subfield.

Figure \ref{fig:r1} shows some basic statistics extracted from our database. The shape of author citation distribution is similar across fields (Figure \ref{fig:r1}(a)), with differences in the number of citations received by different areas.
Typically authors from Biology and Medicine are the ones receiving more citations, while other areas are much less cited ({see e.g. History, Art and Geography}). The number of citations received seems to be related with productivity, as shown in Figure \ref{fig:r1}(b). As expected, different areas have different productivity and visibility patterns.

Figure \ref{fig:r1}(c) shows the cumulative distribution of authors birth year. The birth year here is defined as the year of the author’s first publication. We show as a dashed horizontal line the median value. Once again the differences across fields are evident, even though shapes are similar. Apart from History, Art, Philosophy and Population, all other subfields have authors with median birth year between 1990 and 2000. Surprisingly, a difference of almost 30 years is observed when comparing the median average birth year of Chemistry and History authors.

We investigated the influence of the top-collaborator (as defined in equation \ref{eq:topa}) in different subfields. We analyzed the weight associated with the top-collaborator of A (i.e. $\max_X w_{AX}$).
{The median values of the distribution of $\max_X w_{AX}$ when defining weights in terms of the publication citation counts is shown in Table \ref{tab:my_label} of the SI.}
In Figure \ref{fig:sub4}(a), we show the cumulative distribution of authors for $\max_X w_{AX}$, where weights are defined in terms of authors productivity. Equivalently, the figure illustrates  the cumulative distribution of the fraction of papers published with the top collaborator. Interestingly, there are significant differences across fields. The median top collaborator influence (denoted as dashed horizontal line) ranges between 7\% and can reach roughly 50\%.  History, Art, Philosophy and Sociology are the areas displaying lowest influence of top collaborators in publication counts. Conversely, Material Sciences, Chemistry, Biology and Medicine are the areas with a high influence of top collaborators. For instance, for half of all Chemistry authors, top collaborators accounts for roughly 50\% of publication counts.
\begin{figure}[h]
  \centering
  \includegraphics[width=0.9\textwidth]{papers_cits_dist.pdf}
  \caption{Basic author statistics. Each curve represents authors in a specific field. {Gray dashed horizontal lines indicates the median}. \textbf{(a)} Distribution of number of papers. \textbf{(b)} Distribution of citation counts. \textbf{(c)} Cumulative distribution of authors birth year.
  }
  \label{fig:r1}
\end{figure}

Figure \ref{fig:sub4}(b) shows the cumulative density of top-collaborators influence when considering citation counts. The shapes are very similar to the ones found for publication counts. However, when considering citations, the influence of top-collaborators seems to be stronger. The median influence can increase by a margin of $20\%$ in some disciplines. In Material Sciences, the median influence based on citation reaches $66\%$.
\begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{top_colab_perc.pdf}
    \caption{Cumulative distributions of top-collaborators influence considering in different fields of study. The grey line indicates the median. The top-collaborator influence is measured in terms of (a) number of papers; and (b) citation counts. }
    \label{fig:sub4}
\end{figure}

We note that there is no trivial correlation between the features of areas (as shown in Figure \ref{fig:r1}) and influence indexes found in Figure \ref{fig:sub4}. While Biology and Medicine are the disciplines with the largest number of papers and citations, the top-collaborator seems to be more influential in both Chemistry and Material Sciences. Similarly, Art is the area with the lowest number of papers and citations, however, the lowest influence of top-collaborators is observed in History.
We could also observe that authors' birth year can not totally explain top-collaborators influence. While Computer Science seems to be one of the youngest fields, the median dependence is much higher in fields such as Biology and Chemistry. These results suggest that the influence of top-collaborators might be related to additional factors other than productivity/citation behavior or authors age distribution.

An alternative way to investigate the influence of top-collaborators concerns the analysis of how top-collaborators can affect authors visibility metrics. In this context, we analyzed the variation of authors visibility indexes when the contribution of the top-collaborator is removed. In this analysis, we should expect that if a single top collaborator accounts for most of the success of an author, if the contribution (i.e. co-authored papers) of that collaborator is disregarded, the visibility of the author is affected by a large margin. Conversely, if collaborations are diverse in quantity and quality, one should expect that disregarding top-collaborators contributions would cause only a minor decrease in the considered visibility indexes.

In Figure \ref{fig:cits} we analyze the robustness of authors metrics when the contribution of top-collaborators are disregarded. More specifically, we analyze how \emph{citation counts} are affected when papers with the top-collaborators are disregarded from the analysis. {A similar study analyzing the effect on \emph{publication counts} is available in Figure \ref{fig:papers} of the SI.}
For each subpanel, the x-axis corresponds to the original author citation counts, and the y-axis denotes the number of citations accrued by authors in papers \emph{not co-authored with their top-collaborators}. While there are noteworthy differences across fields, it is possible to identify that, for authors with low citations, removing the top-collaborator can strongly affect citation performance. This is not a surprising result, since this might be the case of young researchers who mostly collaborated with their supervisors. This effect might not only be restricted to younger researchers, since only a small percentage of authors have birth date before 2010 (as shown in Figure \ref{fig:r1}(c)). In fact, a correlation analysis  between authors age and top-collaborators influence showed that there is no strong relationship between the two variables (see Figure \ref{fig:agecor} of the SI).

The influence of top-collaborators on citation counts is field dependent. Particularly, a small dependence can be observed in History, Art, Philosophy, Sociology, Population and Environment Sciences. Even for highly cited authors, when removing the top-collaborator, citation counts are not affected by a large margin. Conversely, it is interesting to note that, for some fields, removing the top-collaborator may cause a large impact on author citations. This pattern emerges in several fields, including Engineering, Computer Science, Physics,  Medicine, Biology, Chemistry and Material Sciences. It is also worthy noting that even highly-cited authors can be strongly affected by removing top-collaborators publications. In Medicine, authors with more than $4,000$ citations can share more than $3,000$ citations with their single top-collaborators. In Economics, Mathematics and Psychology the removal of top-collaborators from the analysis can also impact significantly citation counts of highly-cited authors. However, this effect is not as frequent as observed in Medicine and Chemistry.

\begin{figure}
    \centering
    \includegraphics[width=0.95\textwidth]{fos_hist2d_before_after_2020_citations.pdf}
    \caption{Total number of citations (x-axis) vs. citations obtained disregarding papers co-authored with top-collaborators (y-axis). While in History, Art, Philosophy and Sociology top-collaborators  account for a small percentage of citations, in other disciplines such as Medicine and Chemistry, top-collaborators may play an important individual role to authors citation counts.

    }
    \label{fig:cits}
\end{figure}

In Figure \ref{fig:rankhindex} we conducted a similar experiment by considering the \emph{generalized h-index} as visibility metric. The x-axis corresponds to authors' rank when sorting author according to their \emph{h-indexes}. The y-axis is the analogous ranking, but disregarding the contributions of top-collaborators. The best ranked authors  are located at the top left region of each subpanel.
We observe again that the importance in terms of h-indexes is clearly field dependent.
Once again the main differences across areas arises for the most visible (best ranked) researchers. In History, Art, Philosophy, Sociology, Population and Environmental Sciences, the original rank is affected mostly  for the authors with the lowest h-indexes values. The h-indexes of the best ranked authors seems not to be strongly dependent on the contributions of top-collaborators for these disciplines.

\begin{figure}
    \centering
    \includegraphics[width=0.95\textwidth]{fos_hist2d_hrank_2020.pdf}
    \caption{Analysis of how $h$-based authors ranking is affected by top-collaborators contributions. The x-axis represents the ranking obtained with the generalized h-index and the y-axis corresponds to the ranking of the same metrics but disregarding top-collaborator contributions.

    }

    \label{fig:rankhindex}
\end{figure}

The disciplines mostly dependent on top-collaborators are Engineering, Computer Science, Physics, Medicine, Biology, Chemistry and Materiaks Sciences. For some authors in these areas, their ranking can be strongly impacted if top-collaborators contributions are disregarded. Even top-ranked researchers can be affected by removing top-collaborators papers. This result suggests that a single, recurrent collaboration may play a prominent role in establishing a high visibility level in these disciplines.

\subsection{Relationship between number of co-authors and top-collaborators influence}

The previous section showed that top-collaborators influence based on visibility metrics is field dependent. It becomes thus interesting to investigate whether these patterns can be explained by the differences in the typical number of collaborators in each field. This is an issue worthy studying because, when authors publish several single-authored papers, the lack of top-collaborators can be trivially explained. As we shall show, the predominance of single-authored papers in humanities could be one reason for the low influence of top-collaborators in disciplines such as History, Art and Philosophy~\citep{sabharwal2013comparing}.

Figure \ref{fig:ncolabs} shows the distribution of the number of collaborators for each discipline. We observe that for some disciplines the low influence of top-collaborators may be correlated with the typical low number of collaborators. This is exactly the case of humanities disciplines. A large dependence of top-collaborators also might be correlated with a large number of collaborations, and this is the case of Medicine and Biology. However, not all influence patterns can be explained totally by the number of collaborations. Geology and Psychology have similar top-collaborator influence profiles (see Figure \ref{fig:rankhindex}). However, the typical number of collaborators are very distinct: Geology has roughly 75\% more collaborators than Psychology. In a similar fashion, Geology and Biology share a similar typical number of collaborators, but top-collaborators influence is clearly stronger in the Biology field.

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{number_of_colabs_per_fos_2020_percentile95.pdf}
    \caption{Distribution of number of collaborators per field of study. The average value is calculated ignoring the values greater than the 0.95 percentile.

    }
    \label{fig:ncolabs}
\end{figure}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.7\textwidth]{parallel_rank_metrics.pdf}
    \caption{Parallel coordinates illustrating the relationship between the number of collaborators, the influence of top-collaborators on citations and the influence of  top-collaborators on publication counts. Metrics are normalized by the maximum quantity in each axis. }
    \label{fig:comparison}
\end{figure}

Figure \ref{fig:comparison} ranks the disciplines according to different authors' metrics: the average number of collaborators and the median of the influence of the top-collaborator on citations and number of papers. The values in each each axis is normalized by the maximum value observed for the specific variable. The non-normalized median values of top-collaborators influence are displayed in Table \ref{tab:my_label} of the SI. The figure confirms that the relationship between top-collaborators influence and the number of collaborators is not trivial. Medicine is the discipline with the highest number of collaborations, but the influence of top-collaborators is not as high as in other disciplines, such as Material Sciences and Chemistry. The curve observed for Geology is similar to the Medicine curve. An interesting behavior is also observed for Business. Despite being an area with a relative low number of collaborators, the average top-collaborator influence on citations is high.

All in all our analysis showed that more collaborative disciplines are more likely to have top-collaborators with a higher level of influence on authors productivity and visibility. In some cases, however, top-collaborators influence are relevant even in disciplines characterized by a lower number of collaborators. It remains to be shown, therefore, that other factors other than the number of collaborators may affect top-collaborators influence.

\section{Conclusions}
\label{sec:conc}

In scientific research, collaborations play a fundamental role in promoting and spreading diverse ideas. Despite the large number of works conducted to study collaboration networks, the influence of a single collaborator on authors productivity and visibility has been limited to a few works. In this paper, we analyzed the influence of the most relevant collaborators (referred to as \emph{top-collaborator}) on author metrics. The influence of top-collaborators on the number of papers, citations and h-index was studied in several disciplines.

The influence of the top-collaborator was defined as the fraction of papers/citations obtained in studies co-authored with the top-collaborator. Several interesting patterns distinguishing disciplines were found. We identified that disciplines with a typical low number of collaborators (such as Philosophy, History and Art) are more likely to have a high top-collaborator importance. In this sense, the number of papers and citations are not highly affected if top-collaborators contributions are not affected. A second group of discipline are formed by authors with more collaborators and moderate influence of the top collaborators. This group includes e.g. Economics and Mathematics. A third group of disciplines are those displaying an inversely proportional relationship between number of collaborators and influence of the top-collaborator. Medicine and Geology are the two most collaborative disciplines, however, the influence of top-collaborators is surpassed by other disciplines. In an opposite behavior, Business is a typically a discipline with a relative low number of collaborations, but the influence of top-collaborators in citations is roughly the same the influence observed for Geology, which is a much more collaborative discipline.

Our results showed that the top-collaborator may play an important role in particular disciplines even for highly cited authors. This implies disentangling individual's success from collaborative their teams has become a challenging task and will get more complex as science becomes even more collaborative. In addition to that, we found different patterns of collaboration influence among different disciplines. Thus, any new metric to measure individual research impact should be versatile enough to account for the specificities of each discipline, which also poses as a challenging as science has become more interdisiplinary over the past years.

In future works, we are interested in using top-collaborator influence metrics to investigate individual careers. We are particularly interested in investigating if collaboration patterns with top-collaborators could predict a higher future visibility or other relevant author metrics~\citep{brito2021associations}.
In this case, we could use the proposed network representation to measure the effective number of collaborators via accessibility or symmetry metrics~\citep{correa2017patterns,tohalino2018extractive}. Another interesting topic worthy studying is the contribution performed by top-collaborators~\citep{correa2017patterns}. In other words, we could investigate, e.g. if top-collaborators are more likely to contribute in a specific task, such as writing or research design.

\newpage

\section*{Acknowledgments}

A.C.M.B. acknowledges financial support from São Paulo Research Foundation (FAPESP Grant no. 2020/14817-2) and Capes-Brazil for sponsorship. D.R.A. acknowledges financial support from FAPESP (grant no. 20/06271-0) and CNPq-Brazil (grant no. 304026/2018-2).

\bibliographystyle{abbrvnat}


\section{Introduction}
It is a common observation that in the field of high-performance computing (HPC)
scientists only slowly adopt new software engineering techniques that are already successful
in e.g., web development or commercial applications.
This was described from the software engineer's point of view in~\cite{Basili2008}.
We approach the topic from the HPC engineer's point of view.
In our opinion, improved training of HPC developers is an important step,
but it needs to address specific challenges inherent to HPC software. In contrast
to other fields, HPC software always has the design goal of achieving high hardware
efficiency, which in turn ensures energy efficiency~\cite{Zwart2020} and makes extreme-scale
applications feasible in the first place.
In addition to training, tools for programming and testing must be adjusted to work
correctly in an HPC environment.
In this paper, we present key aspects of software design, testing and performance engineering
for HPC software.

\section{Challenges in HPC software development}
We identify three key challenges that seem to be invariant with respect to
circumstances such as the actual application, hardware or programming skills of the developers.

\paragraph*{First challenge} The life-cycle of HPC hardware is significantly shorter than
that of HPC
software, while at the same time software must be tailored to the hardware in order to
achieve optimal performance. In the course of a decade the
supercomputer hardware evolves dramatically (e.g. from vector processors to clusters of
CPUs, from single to multi-core processors, from commodity hardware to graphics or tensor
processing units). In contrast, much of the code base in use is at least twenty or thirty years old, and
developing e.g. a new aerodynamics code for industrial use may take decades
even with a large team and modern software engineering technology.

\paragraph*{Second challenge} The number of possible code paths grows exponentially in order
to provide
high performance.
A user's call to a simple basic linear algebra subroutine (BLAS)
may trigger any of dozens of implementations, differing in arithmetic (real, complex),
precision (half/single/double/quad, or vendor-specific variants thereof),
data layout (e.g. row- or column major matrix storage), threading mechanisms or GPU programming model,
SIMD hardware (SSE/AVX/ARM/...).
This leads to an explosion of combinations of (possibly generated) code paths.
In some cases the testing responsibility is with hardware-specific vendor libraries (like the Intel MKL or CUBLAS),
but `hand-optimized' code for special purposes must still be tested efficiently and comprehensively.

\paragraph*{Third challenge} It is difficult to reproduce performance results.
Due to the fast pace at which the hardware develops, another user of a code or algorithm
may not have a comparable machine in terms of speed, memory, parallelism, or even architecture.
Simple and general machine models allow
 assessing the efficiency of an implementation across platforms, as we will discuss in
Section~\ref{sec:perf_port}. They can also ensure that the system's hardware and software
are configured appropriately as even small changes can reduce the performance by a factor of
two or more.

\section{Designing HPC software}
In order to meet the challenge of the mismatched software/hardware life-cycle it is crucial
to achieve \emph{separation of concerns} in HPC applications. The climate scientist who
develops a new model component, or the numerical mathematician who develops a new algorithm,
cannot port the software to the next few generations of hardware in the life-cycle
of the code. Instead, they need robust interfaces through which the application,
algorithms and low-level implementations (kernels) are separated.
For decades, the libraries BLAS and LAPACK~\cite{LAPACK} provide a commonly used interface
to linear algebra building blocks.
However, the choice of the granularity of the \emph{building blocks} as well as their interfaces
are \emph{architectural decisions}.
In particular, to obtain high efficiency, one needs to optimize the node-level performance as well as
the communication. Both of these optimizations often affect the code globally e.g.,
through the memory-layout and the distribution of data.
So new advances such as communication-avoiding algorithms (or better: data-transfer avoiding algorithms, see~\cite{Demmel2012})
cannot always be implemented just under the hood, see~\cite{Springer2018,RoehrigZoellner2021preprint} for examples.

In~\cite{Thies2016lncs} we described a layered software
architecture for a sparse eigenvalue solver library with applications in quantum physics.
The kernel interface we proposed (see also the PHIST software,~\cite{Thies2020phist}) allows
the algorithms and applications layers to work with multiple backends, among which are large
open source libraries optimized for portability (e.g. Trilinos) and hand-optimized
hardware-specific ones like GHOST~\cite{Kreutzer2016ghost}. PHIST provides both unit tests
for the backends and performance models for all operations used in its algorithms. That way,
a new development on the hardware side can be met by either the extension of an existing
implementation or a completely new one, and the new component can be readily tested in terms
of correctness and performance. The algorithms and applications layers only have to be
modified or extended if new needs arise on their respective level. The significantly larger
HPC software project Trilinos~\cite{trilinos-website} takes the approach of offering a large
number of interoperable `packages' which may have different life cycles. While this also
results in a manageable overall software, it may incur smaller or larger interface
adaptations for users from time to time. The package concept is taken to the next level by the xSDK
project (\url{https://xsdk.info}), which aims at gradually improving the software quality
and interoperability of a whole landscape of HPC libraries and applications by defining
common rules and recommendations.

\section{Testing}
Above, we mentioned the potentially large amount of (generated) code that needs to be covered by unit testing.
In addition, HPC software often employs multiple parallelization levels at once
(e.g., OpenMP for CPU multi-threading, MPI for communication between nodes and CUDA for GPUs).
This can lead to functionality that is available but not well-tested.
We propose to anticipate typical bugs in HPC codes and to design unit tests specifically to trigger them
(similar to \emph{white-box testing} but with multiple different possible implementations in mind).
In PHIST, for instance, all basic linear algebra tests are executed for aligned and unaligned memory cases
to locate invalid use of SIMD operations. Other typical `parallel bugs' include race
conditions and deadlocks.
Beyond such HPC-specific tests, one needs to explore the space of available combinations of
hardware features with a finite test-matrix
by selecting a hopefully representative subset.

A practical problem is that test frameworks typically lack support for MPI applications,
as well as for other parallelization techniques such as OpenMP or CUDA.
At least MPI support is crucial to run the tests on current supercomputers.
An exception is pFUnit~\cite{pFUnit} for Fortran which supports MPI and OpenMP.
For C++ we provide an extended version of GoogleTest with MPI support at \url{https://github.com/DLR-SC/googletest_mpi}.
It features correct I/O and handling of test results in parallel, as well as collective
assertions.

\section{Performance Portability}\label{sec:perf_port}
In many papers, performance results are reported in terms of `scalability' of a
parallel program: either the speed-up achieved by using more processes to solve the same
problem (strong scalability), or the parallel efficiency when increasing the problem size
with the number of processes (weak scalability).
Such results are not necessarily helpful for comparing the performance on different machines.
A better way is to identify the bottleneck in the computation and to report resource utilization
with respect to that bottleneck: In the vast majority of HPC codes, the bottleneck is either
floating point arithmetic (`compute bound' applications), or data movement (`memory bound' or `communication bound').
This allows estimating the attainable performance by the roofline performance
model~\cite{Williams2009}.
With some measurements of cache/memory/network bandwidths and counting of operations and data volumes,
one can calculate the achieved performance relative to the (modeled) attainable performance.
This relative roofline performance provides a criterion that is independent of the underlying hardware.

Unfortunately, tools cannot easily compute this automatically as it requires high-level insight into the algorithms.
For instance, an unfavorable memory access pattern may or may not be avoidable by code or
algorithm restructuring. A performance model can be formulated to predict the optimal runtime of the bad access pattern
(labelling a good implementation as efficient).
Alternatively, a model can predict the runtime of the actual amount of data traffic needed to perform the operation in an ideal setting
(highlighting this part of the algorithm as inefficient).
We therefore decided to build the roofline model manually into the timing functionality
for all basic operations of the PHIST software, giving the user a choice of these two
variants (realistic vs. idealized)~\cite{Thies2016lncs,Thies2020phist}. When running the
same application on two different machines, one can then compare the overall roofline performance,
or the performance achieved by individual operations, even for different hardware and/or backends.

\section{Summary}
In this overview of software engineering challenges specific to HPC, we argued that HPC
applications are particularly vulnerable to poor software engineering because their
development and use typically outlasts several generations of HPC hardware.
Basic functionality needs to be implemented `close to the hardware',
so that supporting (combinations of) multiple architectures and programming models
leads to additional complexity and to a large amount of (generated) code which has to be tested.
And finally, as the hardware develops rapidly, it is difficult to compare performance results on different machines and hardware architectures.

We illustrated some aspects of software design, unit testing and of the portability of performance results
 with a practical solution from our own field of research, (sparse) linear algebra.
The points we would like to highlight are \emph{separation of concerns} when designing the software,
\emph{anticipating HPC-specific bugs}, and using \emph{performance models} to validate the efficiency of an implementation
across different hardware.

\bibliographystyle{IEEEtran}