An Empirical Study Towards Characterizing Deep Learning Development and Deployment Across Different Frameworks and Platforms

Qianyu Guo, Sen Chen, Xiaofei Xie, Lei Ma, Qiang Hu, Hongtao Liu, Yang Liu, Jianjun Zhao, Xiaohong Li

Introduction

In the ideal world of software engineering, a model trained in one environment should behave identically in another. However, deep learning (DL) frameworks like TensorFlow, PyTorch, CNTK, and MXNet rely on different low-level implementations and mathematical libraries. This paper presents a comprehensive empirical study revealing that DL models are not "framework-agnostic." Even with identical weights and configurations, models behave differently across frameworks and face significant accuracy and performance regressions when migrated to mobile or web platforms.

Methodology

The researchers conducted a systematic study involving over ten man-months of effort to address two major gaps: development divergence and deployment decay.

The approach included:

  • Cross-Framework Comparison: Training 7 popular DNN architectures (e.g., ResNet-20, GRU) across 4 major frameworks.
  • Weight-Sharing Tests: Using the MMDNN tool to isolate framework differences by sharing exact weights and biases.
  • Multi-Platform Deployment: Migrating models to 6 real-world mobile devices (Android and iOS) and 3 web browsers.
  • Quantization Analysis: Testing the impact of 8-bit and 16-bit quantization on speed and accuracy.

The study utilized benchmarks including MNIST, CIFAR-10, and IMDb, along with 106,000 mutated samples generated via TensorFuzz and DeepHunter to test reliability.

Key Insights: Development Divergence

The study identified a "Deep Divergence" effect: while initial layers might produce similar outputs, tiny numerical differences amplify as data moves deeper into the network, potentially leading to different final classifications.

Training accuracy curves for LeNet-5, VGG-16, and GRU across different frameworks, showing divergence in performance.

Key findings during development include:

  • PyTorch Stability: PyTorch exhibited more stable training behavior and generally achieved higher training accuracy.
  • CNTK Robustness: Models trained in Microsoft’s CNTK were consistently more robust against adversarial attacks compared to PyTorch or MXNet.

Key Results: Deployment Decay

Migrating models from powerful PCs to resource-constrained environments reveals significant hurdles:

  • Accuracy Loss: Converting a ResNet-20 model from TensorFlow to CNTK caused an accuracy drop from 82.66% to 74.35%, despite identical weights.
  • Web Resource Intensity: Running ResNet-20 on Safari consumed over 4GB of system memory. Web platforms also showed a compatibility issue, with accuracy dropping by over 5% for certain models.
  • Mobile Performance: Android devices generally outperformed iOS for simpler models like LeNet, while iOS showed advantages for complex models like ResNet and VGG.
  • Quantization Paradox: On iOS (Core ML), quantization sometimes slowed down prediction speeds, contrary to its intended purpose.
  • Bug Discovery: The study identified a real-world bug in TensorFlow.js related to WebGL handling of 1x1 Conv2D kernels, which was subsequently fixed.

Conclusion

The study warns developers that "state-of-the-art" results on a PC might not hold up on a smartphone or browser. Future work should focus on automated testing tools for migration bugs and more efficient cross-platform conversion tools to minimize the "Deep Divergence" effect.

Summary updated

BibTeX
@inproceedings{guo2019empirical,
  author = {Qianyu Guo and Sen Chen and Xiaofei Xie and Lei Ma and Qiang Hu and Hongtao Liu and Yang Liu and Jianjun Zhao and Xiaohong Li},
  title = {{An Empirical Study Towards Characterizing Deep Learning Development and Deployment Across Different Frameworks and Platforms}},
  booktitle = {ASE},
  year = {2019},
  doi = {10.1109/ase.2019.00080},
}
Figure