TensorFI: A Flexible Fault Injection Framework for TensorFlow Applications

Zitao Chen, Niranjhana Narayanan, Bo Fang, Guanpeng Li, Karthik Pattabiraman, Nathan DeBardeleben

As machine learning (ML) moves from recommendation engines to the driver’s seat of autonomous vehicles (AVs), "reliability" is no longer just a metric—it’s a safety requirement. But how do we know if a deep neural network will behave predictably when a cosmic ray flips a bit in memory or a software bug corrupts a calculation?

In their paper, "TensorFI: A Flexible Fault Injection Framework for TensorFlow Applications," researchers from the University of British Columbia and their collaborators introduce a tool designed to answer exactly that. TensorFI allows developers to "break" their TensorFlow models in controlled ways to see how resilient they truly are.

The Challenge: Reliability in Safety-Critical ML

Traditional software testing isn't enough for ML. In safety-critical domains like autonomous driving, systems must meet strict standards (like ISO 26262), which mandate extremely low failure rates. To reach these standards, engineers use Fault Injection (FI)—deliberately introducing errors to see if the system recovers or crashes.

However, existing FI tools are often too low-level (operating on assembly code) or too rigid. TensorFlow, a dominant ML framework, executes its heavy lifting in optimized C++ and assembly "behind the scenes," making it difficult for developers to intercept and modify values at the high-level "operator" level (like a convolution or an addition) where they actually write their code.

Methods: The Graph Duplication Approach

TensorFI is a high-level "Software-Implemented Fault Injection" (SWiFI) tool that operates at the graph level. Its core innovation is Graph Duplication:

  1. The FI Graph: Instead of trying to modify TensorFlow’s immutable execution graph, TensorFI creates a parallel "FI graph." This twin graph mirrors the original but replaces standard operators with custom Python-based versions capable of injecting faults.
  2. Interface-Level Injection: It injects faults into the outputs of operators. This abstracts away the complex hardware/software cause and focuses on the effect: a corrupted value.
  3. Minimal Intervention: At runtime, the system chooses whether to run the "golden" (original) graph or the "faulty" graph. This ensures that when you aren't testing, there is zero performance penalty.
TensorFI's graph duplication mechanism for fault injection.

Configurability

Users define the "who, what, and where" of the faults using a simple YAML file. This allows for precise control over bit-flips in specific layers or randomizing values in certain math operations without changing the underlying model code.

Datasets and Evaluation

The researchers evaluated TensorFI across 12 different ML programs using four major datasets:

  • MNIST: Handwritten digits.
  • GTSRB: German Traffic Sign Recognition Benchmark.
  • ImageNet: Large-scale general image database.
  • comma.ai driving dataset: Real-world video frames used to predict steering angles for autonomous vehicles.

Key Insights

  • The "Aha" of Abstraction: By injecting faults at the operator interface rather than the assembly level, the results are immediately actionable. Developers can see exactly which layer or math operation (e.g., ArgMax) is the "weakest link."
  • Structural Resilience: Recurrent Neural Networks (RNNs) proved surprisingly resilient to single bit-flips because their internal state can "dampen" the error over time. However, they are highly vulnerable if multiple faults occur across different time steps.
  • The Danger of Decision Operators: Operators like ArgMax (which picks the highest probability class) and Equal have nearly a 100% Silent Data Corruption (SDC) rate. Because these operators sit at the very end of the pipeline, any error there almost guaranteed a wrong final classification.
  • Error Amplification: Faults in convolution layers are particularly dangerous because the error propagates and "amplifies" through the complex math of subsequent layers.

Key Results and Visual Impact

The "Silent Data Corruption" rate (where the model gives a wrong answer without crashing) varied wildly across models. Some models were highly robust, while others failed frequently with even a single bit-flip.

Visual examples of Silent Data Corruption (SDC) where input images are misclassified due to injected faults.

As shown above, faults can lead to catastrophic misclassifications, such as a bus being identified as a graduation cap or a stop sign being interpreted as a command to go straight.

Performance Overhead

  • Instrumentation: Setting up the twin graph is fast, adding only about 1.5x overhead on average.
  • Injection Cost: Actually running the faulty graph is significantly slower (~77x overhead) because the operators are emulated in Python. However, this is acceptable for offline resilience testing where accuracy is more important than real-time speed.

Limitations and Future Work

The primary limitation is execution speed due to Python emulation. Future work could involve moving the injection logic into the C++ layer for better performance, expanding support to other frameworks like PyTorch, and developing automated "pruning" techniques to focus testing on the most sensitive parts of a graph.

Check out the tool: The authors have made TensorFI publicly available on GitHub.

Summary updated

BibTeX
@inproceedings{chen2020tensorfi,
  author = {Zitao Chen and Niranjhana Narayanan and Bo Fang and Guanpeng Li and Karthik Pattabiraman and Nathan DeBardeleben},
  title = {{TensorFI: A Flexible Fault Injection Framework for TensorFlow Applications}},
  booktitle = {ISSRE},
  year = {2020},
  doi = {10.1109/issre5003.2020.00047},
}
Figure