TL;DR
This paper introduces a set of simple, generic "smoke tests" for machine learning libraries, adapted from traditional software testing techniques. By applying these tests with a combinatorial approach to hyperparameters, the authors discovered 11 previously unknown bugs, including critical ones, in mature ML libraries, demonstrating the continued relevance of fundamental testing principles.
What Problem Does This Paper Address?
Machine learning (ML) is now integral to many software applications, but ensuring the quality of ML software presents unique challenges. Traditional software testing often struggles with ML due to the lack of clear test oracles (i.e., knowing the "correct" output for a given input). While much research focuses on evaluating ML model performance (accuracy, precision, etc.) or addressing specific algorithmic issues, there's a need for more general, low-effort testing strategies that can catch fundamental bugs in ML libraries themselves. This paper aims to bridge this gap by adapting established software testing techniques to create a practical suite of "smoke tests" for ML algorithms.
Methods
The core of this work is the adaptation of equivalence class analysis and boundary value analysis for ML testing.
- Smoke Tests: The authors define a set of 22 smoke tests for classification and 15 for clustering algorithms. These tests focus on ensuring that the most crucial functions (training and prediction) execute without crashing, using carefully crafted input data designed to expose potential issues.
- Equivalence Classes: Instead of traditional numeric/categorical distinctions, they define equivalence classes based on problematic data characteristics like extreme values (close to machine precision), skewed distributions, outliers, and special cases for categorical data (e.g., starved categories).
- Combinatorial Testing: Recognizing that hyperparameters significantly influence ML algorithm behavior, the authors propose a method to test combinations of hyperparameters. To avoid the exponential explosion of a naive grid search, they adopt a strategy of modifying only one parameter at a time while keeping others at default values. This approach achieves linear complexity with respect to the number of hyperparameters.
- Data Generation: The tests use synthetically generated data. For classification, they employ "rectangle" labeling (informative labels) and "random" labeling (uninformative labels).
Datasets
The paper does not introduce new datasets for training. Instead, it focuses on generating synthetic test data for evaluating ML algorithms. The evaluation is performed on three mature ML libraries:
- Weka: Tested version 3.9.2.
- scikit-learn: Tested version 0.23.1 with NumPy 1.15.0.
- Spark MLlib: Tested version 3.0.0.
- TensorFlow: Tested version 2.3.0 (used as a proof-of-concept for a multi-layer perceptron).
Key Insights and Ideas
- Traditional Testing Still Matters: The most significant insight is that fundamental software testing principles like equivalence class analysis and boundary value analysis are highly relevant and effective for ML software, even for mature libraries.
- Hyperparameters are Critical for Bug Discovery: Simply testing with default hyperparameters is insufficient. Combinatorial testing, even in a simplified form, is crucial for uncovering bugs that manifest only under specific parameter configurations.
- Extreme Values are Bug Magnets: Data points close to machine precision limits (both very small and very large) are particularly effective at triggering bugs, especially those related to numeric overflows and underflows.
- Corner Cases are Important: Tests focusing on edge cases like starved categories, empty classes, or all-zero features are vital for robustness and can reveal non-trivial bugs.
- Low Effort, High Impact: The proposed smoke tests are designed to be simple to implement and execute, offering a high return on investment in terms of bug detection.
Key Results
- 11 Bugs Found: The authors discovered and reported 11 previously unknown bugs across the three ML libraries.
- Critical Bugs Identified: Two of these bugs were classified as critical, capable of crashing applications due to uncontrolled memory consumption.
- Broad Applicability: The tests found bugs in a range of algorithms, including classification and clustering, across different programming languages (Java, Python, Scala).
- Combinatorial Testing Impact: The paper estimates that six bugs would have been missed without the combinatorial approach to hyperparameter testing.
- Efficiency: Most tests executed very quickly (under one second), with the exception of the
MANYCATStest, which was designed to induce stress and took significantly longer but did not find bugs.
Limitations and Future Work
- Subject Selection: The study used purposive sampling of mature ML libraries. While this increases the likelihood of finding subtle bugs, it might not be representative of all ML libraries, especially less mature ones. However, the authors hypothesize that their approach would be even more effective for less mature libraries.
- Test Oracle: The primary test oracle used was application crashes. While this is a valid indicator of bugs, it might miss more subtle functional errors.
- TensorFlow Scope: The TensorFlow testing was limited to a proof-of-concept with a multi-layer perceptron, due to the vast complexity of deep learning frameworks.
- Future Work: The authors suggest exploring more advanced combinatorial strategies (e.g., pairwise testing), considering algorithms as state machines for state-based testing, and investigating the application of these tests at the application level for input validation. They also note that while their tests found bugs, the developers' responses varied, with some bugs being fixed, others under discussion, and one marked as "Won't Fix."
Summary updated