Lune

FSE2021Top-tier venue

FLEX: fixing flaky tests in machine learning projects by updating assertion bounds

Saikat Dutta, August Shi, Sasa Misailovic

Abstract

Many machine learning (ML) algorithms are inherently randommultiple executions using the same inputs may produce slightly different results each time. Randomness impacts how developers write tests that check for end-to-end quality of their implementations of these ML algorithms. In particular, selecting the proper thresholds for comparing obtained quality metrics with the reference results is a non-intuitive task, which may lead to flaky test executions.

We present FLEX, the first tool for automatically fixing flaky tests due to algorithmic randomness in ML algorithms. FLEX fixes tests that use approximate assertions to compare actual and expected values that represent the quality of the outputs of ML algorithms. We present a technique for systematically identifying the acceptable bound between the actual and expected output quality that also minimizes flakiness. Our technique is based on the Peak Over Threshold method from statistical Extreme Value Theory, which estimates the tail distribution of the output values observed from several runs. Based on the tail distribution, FLEX updates the bound used in the test, or selects the number of test re-runs, based on a desired confidence level.

We evaluate FLEX on a corpus of 35 tests collected from the latest versions of 21 ML projects. Overall, FLEX identifies and proposes a fix for 28 tests. We sent 19 pull requests, each fixing one test, to the developers. So far, 9 have been accepted by the developers.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

6 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications cites A study on the lifecycle of flaky tests
  • Free Lunch for Testing: Fuzzing Deep-Learning Libraries from Open Source cites Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications
  • Free Lunch for Testing: Fuzzing Deep-Learning Libraries from Open Source cites Detecting numerical bugs in neural network architectures
  • Free Lunch for Testing: Fuzzing Deep-Learning Libraries from Open Source cites Detecting flaky tests in probabilistic and machine learning applications
  • Understanding and Improving Flaky Test Classification cites Detecting flaky tests in probabilistic and machine learning applications
  • Understanding and Improving Flaky Test Classification cites TERA: optimizing stochastic regression tests in machine learning projects
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites Repairing Order-Dependent Flaky Tests via Test Generation
  • Repairing Order-Dependent Flaky Tests via Test Generation cites Preempting Flaky Tests via Non-Idempotent-Outcome Tests
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites Detecting flaky tests in probabilistic and machine learning applications
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites A study on the lifecycle of flaky tests
  • Repairing Order-Dependent Flaky Tests via Test Generation cites Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications
  • Repairing Order-Dependent Flaky Tests via Test Generation cites Detecting flaky tests in probabilistic and machine learning applications
  • Detecting flaky tests in probabilistic and machine learning applications cites A study on the lifecycle of flaky tests
  • TERA: optimizing stochastic regression tests in machine learning projects cites Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications
  • TERA: optimizing stochastic regression tests in machine learning projects cites Detecting numerical bugs in neural network architectures
  • TERA: optimizing stochastic regression tests in machine learning projects cites Audee: Automated Testing for Deep Learning Frameworks
  • TERA: optimizing stochastic regression tests in machine learning projects cites Detecting flaky tests in probabilistic and machine learning applications
  • TERA: optimizing stochastic regression tests in machine learning projects cites A study on the lifecycle of flaky tests
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers6

  1. Free Lunch for Testing: Fuzzing Deep-Learning Libraries from Open SourceAnjiang Wei, Yinlin Deng, Chenyuan Yang, Lingming ZhangICSE 2022 · 91 citations
  2. Repairing Order-Dependent Flaky Tests via Test GenerationChengpeng Li, Chenguang Zhu, Wenxi Wang, August ShiICSE 2022 · 22 citations
  3. Preempting Flaky Tests via Non-Idempotent-Outcome TestsAnjiang Wei, Pu Yi, Zhengxi Li, Tao Xie et al.ICSE 2022 · 20 citations
  4. TERA: optimizing stochastic regression tests in machine learning projectsSaikat Dutta, Jeeva Selvam, Aryaman Jain, Sasa MisailovicISSTA 2021 · 12 citations
  5. Understanding and Improving Flaky Test ClassificationShanto Rahman, Saikat Dutta, August ShiOOPSLA 2025 · 5 citations

Builds on8

  1. A study on the lifecycle of flaky testsWing Lam, Kivanç Muslu, Hitesh Sajnani, Suresh ThummalapentaICSE 2020 · 107 citations
  2. Audee: Automated Testing for Deep Learning FrameworksQianyu Guo, Xiaofei Xie, Yi Li, Xiaoyu Zhang et al.ASE 2020 · 83 citations
  3. Detecting flaky tests in probabilistic and machine learning applicationsSaikat Dutta, August Shi, Rutvik Choudhary, Zhekun Zhang et al.ISSTA 2020 · 71 citations
  4. Detecting numerical bugs in neural network architecturesYuhao Zhang, Luyao Ren, Liqian Chen, Yingfei Xiong et al.FSE 2020 · 66 citations
  5. Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined SpecificationsPeilun Zhang, Yanjie Jiang, Anjiang Wei, Victoria Stodden et al.ICSE 2021 · 26 citations

Related papers

  1. Balancing Effectiveness and Flakiness of Non-Deterministic Machine Learning TestsChunqiu Steven Xia, Saikat Dutta, Sasa Misailovic, Darko Marinov et al.ICSE 2023 · 5 citations
  2. Higher income, larger loan? monotonicity testing of machine learning modelsArnab Sharma, Heike WehrheimISSTA 2020 · 12 citations
  3. FlakeFlagger: Predicting Flakiness Without Rerunning TestsAbdulrahman Alshammari, Christopher Morris, Michael Hilton, Jonathan BellICSE 2021 · 63 citations
  4. Neurosymbolic Repair of Test FlakinessYang Chen, Reyhaneh JabbarvandISSTA 2024 · 8 citations
  5. Do Automatic Test Generation Tools Generate Flaky Tests?Martin Gruber, Muhammad Firhard Roslan, Owain Parry, Fabian Scharnböck et al.ICSE 2024 · 12 citations
Dusk over the sea between two cliffs drawn in fine vertical lines