Partial FC: Training 10 Million Identities on a Single Machine

Xiang An, Xuhan Zhu, Yang Xiao, Lan Wu, Ming Zhang, Yuan Gao, Bin Qin, Debing Zhang, Ying Fu, Jiankang Deng

Training state-of-the-art face recognition models is increasingly a game of scale. As datasets grow from thousands to millions of identities, the computational and memory costs of the final classification layer—the "softmax" head—become a massive bottleneck. In their paper, "Partial FC: Training 10 Million Identities on a Single Machine," Xiang An and colleagues present a scalable solution that breaks through these limits, allowing researchers to train on tens of millions of identities using standard hardware.

TL;DR

Partial FC (PFC) is a distributed training framework that enables face recognition models to scale to over 64 million identities on a single 8-GPU machine. By preserving all positive class centers while sparsely sampling negatives, it drastically reduces memory and compute requirements and even improves robustness to label noise and long-tailed data.

What Problem Does This Paper Address?

In large-scale face recognition, we typically learn embeddings by classifying images into millions of distinct identity classes. The standard tool for this is the softmax function. However, softmax has a scaling problem: its memory and computational costs grow linearly with the number of classes.

Even if you shard the classifier across multiple GPUs (model parallelism), you eventually hit a "memory wall." As you add more GPUs to handle more classes, each GPU still has to compute "logits" (scores) for the entire global batch against its local shard of classes. Eventually, the memory required just to store these scores exceeds the GPU's capacity, even if the model weights themselves fit (see Figure 3).

The "Memory Wall": As the number of GPUs ($k$) increases to handle more classes, logit memory begins to dominate, eventually leading to out-of-memory errors.

Methods

The authors propose Partial FC (PFC), which is built on a key observation: positive and negative classes play fundamentally different roles. The positive center (the correct identity) is indispensable for "attracting" the embedding, whereas most negative centers are already well-separated and contribute very little to the final gradient.

Positive-Preserving Negative Sampling

Instead of comparing an image against every single class, PFC:

  1. Retains every positive class center present in the current mini-batch.
  2. Samples a small subset of negative centers (e.g., only 10%).

This asymmetric treatment maintains the necessary supervisory signal while avoiding exhaustive interaction with millions of uninformative negatives.

Distributed Implementation (MP-PFC)

To make this work at scale, the authors developed a sophisticated distributed system:

  • Class Ownership: Each GPU owns a specific shard of the total identities.
  • Local Activation: Each GPU identifies which of its owned classes are "positives" for the current batch and then fills a fixed budget with random negatives from its shard.
  • Pipelined Prefetching: To save even more GPU memory, the full classifier can reside in host RAM or NVMe storage. Active rows are prefetched to the GPU in an asynchronous, double-buffered pipeline, ensuring the GPU always has the data it needs without storing the entire multi-gigabyte classifier (Figure 7).
Comparison of Full Softmax, Partial FC, and Contrastive Softmax. PFC keeps the positive center exact while sampling negatives from persistent parameters.

Datasets

The authors validated PFC on a massive scale using:

  • Training: Standard sets like CASIA-WebFace and MS1MV2, plus massive ones like Glint360K (17M images, 360K IDs) and the WebFace260M family (up to 42M images).
  • Evaluation: LFW, CFP-FP, AgeDB-30, IJB-C, and the ICCV21-MFR (Masked Face Recognition) challenge.
  • Robustness Tests: They created synthetic versions of WebFace12M to test performance under severe label noise (up to 40%) and extreme long-tailed distributions.

Key Insights and Ideas

  • Efficiency through Asymmetry: You don't need to look at every "wrong" answer to learn the "right" one. Sampling negatives reduces the active class dimension, which is the only way to truly scale beyond the memory wall.
  • Sampling as a Regularizer: Surprisingly, PFC isn't just a speed hack. By reducing exposure to noisy or conflicting negative centers, sampling acts as a robust regularizer. It prevents the model from "over-learning" from mislabeled data or duplicate identities that appear as negatives.
  • GEMM Geometry Matters: By sharding and sampling, PFC changes the shape of the matrix multiplications (GEMMs) performed on the GPU. This leads to better cache reuse and higher arithmetic intensity compared to standard data-parallel sampling (Figure 6).
GEMM layout comparison. MP-PFC (ours) results in "tall and narrow" blocks that allow for much better center reuse and lower memory traffic.

Key Results

  • Extreme Scaling: The system successfully trained on 64 million identities using a single machine with 8 GPUs.
  • Accuracy Parity: Activating only 10-20% of classes is sufficient to match or even slightly exceed the accuracy of full softmax on clean data (97.2% TAR on IJB-C).
  • Massive Robustness Gains: Under 40% label noise, PFC combined with a simple conflict filter improved accuracy on ICCV21-MFR from 43.9% to 80.2%. On long-tailed data, it improved TAR from 87.4% to 92.0%.
  • Speedup: At 32M identities, PFC achieved a 3.5x to 5.2x reduction in compute kernel time compared to standard sharded implementations.

Limitations and Future Work

While PFC is highly effective for supervised classification with persistent class centers (proxies), the authors note that extending this positive-preserving principle to dynamic contrastive learning (like CLIP) is a promising but challenging next step. In contrastive learning, candidates are transient embeddings from another encoder, meaning gradients must flow through both sides of the comparison, requiring new communication and synchronization strategies.

Summary updated

BibTeX
@misc{an2020partial,
  author = {Xiang An and Xuhan Zhu and Yang Xiao and Lan Wu and Ming Zhang and Yuan Gao and Bin Qin and Debing Zhang and Ying Fu and Jiankang Deng},
  title = {{Partial FC: Training 10 Million Identities on a Single Machine}},
  year = {2020},
  eprint = {2010.05222},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2010.05222},
}
Figure