NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Distributed Function Minimization in Apache Spark

Andrea SchioppaarXiv 2019

Abstract: This paper presents distfom, an open-source Scala library designed for large-scale distributed function minimization on Apache Spark. By sharding both data and model parameters across a cluster, the library overcomes the "memory wall" inherent in traditional Spark-ML implementations. We demonstrate the library's capabilities through applications in Optimal Transport and massive-scale regression, showing it can handle models with up to one billion parameters on commodity, preemptible cloud resources.

Introduction

As machine learning models grow in complexity, particularly in domains like e-commerce, genomics, and natural language processing, the number of parameters often reaches the millions or billions. Standard distributed computing frameworks, including Apache Spark’s MLlib, typically rely on broadcasting the entire model weight vector to every worker node. This "broadcast-and-aggregate" pattern creates a significant "memory wall" when the model size exceeds the memory capacity of individual nodes.

Furthermore, high-performance computing (HPC) environments are often expensive and inaccessible for many researchers. There is a growing need for frameworks that can leverage "commodity" cloud infrastructure, specifically preemptible or "spot" instances. These instances offer significant cost savings (up to 80%) but come with the risk of being reclaimed at any time. The distfom library, developed by Andrea Schioppa, addresses these challenges by providing a mathematically robust, fault-tolerant optimization framework built directly on Spark’s Resilient Distributed Datasets (RDDs).

Architecture and Implementation

The core innovation of distfom lies in its treatment of model parameters as first-class distributed objects.

Distributed Vectors

Instead of treating the weight vector as a local array to be broadcast, distfom introduces the FomDistVec abstraction. This includes:

  • DistributedDenseVector (DDV): Shards a single large vector across the cluster.
  • DistributedStackedDenseVectors (DSDV): Manages multiple distributed vectors, which is essential for complex models like Factorization Machines where different feature sets require separate parameter blocks.

Optimization Algorithms

While many distributed systems rely on Stochastic Gradient Descent (SGD) due to its simplicity, distfom implements more sophisticated quasi-Newton methods:

  • LBFGS (Limited-memory Broyden–Fletcher–Goldfarb–Shanno): Provides faster convergence than SGD by approximating the Hessian matrix.
  • OWLQN (Orthant-Wise Limited-memory Quasi-Newton): An extension of LBFGS designed for $l_1$-regularized problems, enabling sparse model training at scale.

Implementing these algorithms in a distributed environment requires careful management of state and communication. The library utilizes Spark’s treeAggregate to efficiently compute gradients and update the distributed Hessian approximation without overwhelming the driver node.

Hybrid Parallelism and Macro-Batching

The library employs a hybrid approach, combining data parallelism (partitioning training examples) with model parallelism (partitioning weights). For specialized tasks like Optimal Transport, it uses a grid-based partitioning of the cost matrix to minimize network overhead.

A key technical contribution is the "macro-batching" strategy. In large-scale optimization, using the same data batch for both gradient calculation and line search (step-size selection) can lead to aggressive overfitting to that specific batch. distfom allows for "refreshing" the data batch during the line search phase, ensuring that the chosen step size generalizes better to the overall dataset.

Applications and Scalability

The library was evaluated across three demanding scenarios to test its limits and practical utility.

Massive-Scale Regression

To test the "memory wall," a synthetic $l_2$-regression problem was constructed with one billion parameters and 100 million examples. Standard Spark-ML would fail this task as the 10^9 parameters (roughly 8GB in double precision) plus the overhead of broadcasting and local storage would exceed the memory limits of typical worker nodes. distfom successfully minimized the function, proving that sharding weights allows for models of virtually unlimited size.

Optimal Transport

Optimal Transport (OT) is a powerful mathematical tool for comparing probability distributions, but it is computationally expensive. The author applied distfom to an OT problem involving 250,000 sampled points in a 55-dimensional space. This resulted in a cost matrix significantly larger than those handled in previous literature—approximately 156 times larger than the benchmarks in Genevay et al. (2016). The library achieved convergence in just 10 LBFGS iterations, demonstrating its efficiency for complex mathematical optimization.

Multi-classification and Generalization

In tests involving a 10-category classification task with 50 million parameters, the "macro-batch" strategy proved its worth. By using different batches for the line search, the optimizer achieved a 20% lower loss after only four iterations compared to standard fixed-batch approaches. This suggests that the library is not just about handling more data, but about optimizing more effectively.

Conclusion and Future Directions

The distfom library demonstrates that high-end optimization is possible on commodity Spark clusters. By moving away from the broadcast model and embracing distributed parameter management, it opens the door for training massive models on "cheap" cloud resources.

Future development aims to incorporate a dedicated "Parameter Server" architecture to enable asynchronous updates, which could further reduce synchronization bottlenecks. Additionally, exploring "warm-up" phases using mini-batch SGD before switching to the more sensitive LBFGS could improve stability during the initial stages of training.

Summary updated

BibTeX
@misc{schioppa2019distributed,
  author = {Andrea Schioppa},
  title = {{Distributed Function Minimization in Apache Spark}},
  year = {2019},
  eprint = {1909.07922},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1909.07922},
}
Figure