Grounding Deep Learning Framework Testing in Data Flow
Organizations: State Key Laboratory for Novel Software Technology, Nanjing University, Nanjing, China · UNIST, Ulsan, Republic of Korea
Abstract
Data flow underlies deep learning (DL) framework execution, including automatic differentiation and operator-fusion optimization. Bugs involving data flow can cause incorrect results or unexpected behavior. Existing testing methods represent models primarily by operator topology, omitting runtime tensor values and properties and operator input requirements. They therefore cannot distinguish data flows in models with similar topologies, even when these differences affect framework behavior. We introduce the Tensor Flow Graph (TFG) to capture runtime tensor states and operator input requirements. Its nodes represent operators and their input requirements, while its edges record tensor values and properties. Building on the TFG, we propose FlowMuT, a mutation-based testing method grounded in data flow. Mutations are represented as constrained subgraph replacements, with mutation operators derived from prior work and an analysis of mutable data flow objects. In each round, FlowMuT builds a TFG for the seed model, pairs mutation operators with TFG sites, and filters illegal candidates using data flow constraints. It uses LinUCB to select a candidate based on coverage and impact, executes the mutant, updates selection feedback, and uses each accepted mutant as the next seed. We evaluate FlowMuT on PyTorch and MindSpore using representative models from diverse application scenarios. FlowMuT submitted 55 bug reports for cases missed by all baseline methods; developers confirmed 41 reports and fixed the bugs described in 7 reports. FlowMuT achieves 43.4% higher data flow diversity than the strongest baseline and a legal mutant rate of 96.7%, compared with 86.4% without constraints. These results show that testing from a data flow perspective is practical and effective.
Figures & tables
| Mutation category | CG-derived construction | TFG-derived construction | Final pool | |||||
|---|---|---|---|---|---|---|---|---|
| Object | Primitive | Extracted | Removed | Retained | Derived | Overlap | TFG-only | Total |
| Tensor | Update | 19 | 14 | 5 | 8 | 5 | 3 | 8 |
| Tensor | Insertion | 1 | 0 | 1 | 4 | 1 | 3 | 4 |
| Tensor subtotal | 20 | 14 | 6 | 12 | 6 | 6 | 12 | |
| Operator | Update | 46 | 9 | 37 | 6 | 5 | 1 | 38 |
| Operator | Insertion | 6 | 3 | 3 | 3 | 2 | 1 | 4 |
| Scene Task | Model | Input | Parameters |
| Image Classification | ConvNeXt V2-Tiny | 224 224 | 28,635,496 |
| Swin V2-Tiny | 256 256 | 28,347,154 | |
| EfficientNetV2-S | 384 384 | 21,458,488 | |
| Object Detection | YOLOv10-S | 640 640 | 8,128,272 |
| RT-DETRv2-S | 640 640 | 20,226,500 | |
| Semantic Segmentation | SegFormer-B1 | 512 512 | 13,715,798 |
| Developer status | Symptom category | ||||
|---|---|---|---|---|---|
| Status | PyTorch | MindSpore | Category | PyTorch | MindSpore |
| Reported | 14 (100.0%) | 41 (100.0%) | Crash | 0 (0.0%) | 31 (75.6%) |
| Confirmed | 8 (57.1%) | 33 (80.5%) | Numerical Error | 12 (85.7%) | 6 (14.6%) |
| Fixed | 7 (50.0%) | 0 (0.0%) | State Error | 2 (14.3%) | 4 (9.8%) |
| Test Case Diversity at Round 250 | Framework Coverage (%) | Execution Time (s/test case) | |||||||
| Method | LIC ( ) | LPC ( ) | LSC ( ) | DFSD ( ) | Python | API | C++ | Generation | Detection |
| LEMON | 2.89 | 1.37 | 0.44 | 28.08 | 27.8 | 28.0 | 34.8 | 0.85 | 3.19 |
| COMET | 3.37 | 3.09 | 0.65 | 32.11 | 28.0 | 28.1 | 35.0 | 7.60 | 3.76 |
| DevMuT | 3.17 | 1.36 | 0.58 | 30.80 | 30.8 | 32.0 | 41.5 | 1.20 | 3.98 |
| FlowMuT | 5.95 | 4.48 | 1.04 | 46.06 | 37.8 | 42.2 | 48.1 | 6.04 | 4.58 |
| Configuration | Ops | Test Case Diversity | Framework Coverage (%) | |||||
| Configuration | LIC ( ) | LPC ( ) | LSC ( ) | DFSD ( ) | Python | API | C++ | |
| Operator-source ablation | ||||||||
| Full operator pool | 147 | 5.95 | 4.48 | 1.04 | 46.06 | 37.8 | 42.2 | 48.1 |
| CG-derived pool | 120 | 3.17 | 3.42 | 0.71 | 30.51 | 29.9 | 32.4 | 37.7 |
| TFG-derived pool | 48 | 2.04 | 0.68 | 0.18 | 20.01 | 20.1 | 20.1 | 21.8 |
| TFG object ablation (within the TFG-derived pool) | ||||||||
| Mutation legality | Filter outcomes | Filter selectivity (%) | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Configuration | Ret. (%) | LMR (%) | TN | FN | FP | TP | Prec. | Rec. | FRR | Leak. |
| Full constraints | 88.0 | 96.7 | 851 | 29 | 13 | 107 | 89.2 | 78.7 | 1.5 | 21.3 |
| w/o input | 92.7 | 92.3 | 856 | 71 | 8 | 65 | 89.0 | 47.8 | 0.9 | 52.2 |
| w/o internal | 90.7 | 94.2 | 854 | 53 | 10 | 83 | 89.2 | 61.0 | 1.2 | 39.0 |
| w/o output | 91.6 | 93.3 | 855 | 61 | 9 | 75 | 89.3 | 55.1 | 1.0 | 44.9 |
| w/o all | 100.0 | 86.4 | 864 | 136 | 0 | 0 | N/A | 0.0 | 0.0 | 100.0 |
| Test Case Diversity | Framework Coverage (%) | Distinct signatures | |||||
| Configuration | LIC ( ) | LPC ( ) | LSC ( ) | DFSD ( ) | C++ | API | |
| Selection-policy comparison | |||||||
| One-shot | 3.68 | 1.32 | 0.41 | 43.63 | 35.5 | 27.3 | 460.9 |
| Random search | 4.56 | 1.50 | 0.62 | 45.55 | 33.3 | 22.7 | 481.2 |
| Fixed priority | 1.99 | 0.56 | 0.17 | 10.97 | 28.4 | 17.2 | 115.9 |
| UCB1 | 4.38 | 1.44 | 0.52 | 41.65 | 32.2 | 20.3 | 440.0 |
Automated Software Testing
Automated software testing uses tools and algorithms to generate, run, and evaluate tests that find defects and prevent regressions.
See all 135 papers