Reproducibility, energy efficiency and performance of pseudorandom number generators in machine learning: a comparative study of python, numpy, tensorflow, and pytorch implementations

📄 arXiv: 2401.17345v2 📥 PDF

作者: Benjamin Antunes, David R. C Hill

分类: cs.MS, cs.LG

发布日期: 2024-01-30 (更新: 2024-02-10)

备注: 20 pages, 10 tables, 1 figure


💡 一句话要点

比较Python、NumPy、TensorFlow和PyTorch中的伪随机数生成器性能与能效

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 伪随机数生成器 机器学习 可重复性 能效 性能比较 Python TensorFlow PyTorch

📋 核心要点

  1. 现有伪随机数生成器在可重复性和能耗方面存在挑战,影响机器学习的可靠性和资源利用效率。
  2. 本文通过比较不同编程语言和库中的PRNG实现,评估其统计质量、时间效率和能耗,旨在提升可重复性和能效。
  3. 实验表明,机器学习框架的时间性能与C实现相当,能耗仅高出10%,但在数值可重复性方面仍存在不足。

📝 摘要(中文)

伪随机数生成器(PRNGs)在机器学习技术中广泛应用,然而其可重复性和能耗问题仍然存在。本文研究了Python、NumPy、TensorFlow和PyTorch中主要PRNG的统计质量和数值可重复性,并与C语言实现进行比较。实验结果显示,机器学习技术的时间性能与C实现相近,甚至在某些情况下更优,而能耗仅比C实现高出10%。然而,不同平台间对于相同种子和算法的数值可重复性未能实现。

🔬 方法详解

问题定义:本文旨在解决伪随机数生成器在机器学习中的可重复性和能耗问题。现有方法在不同平台间的数值可重复性不足,且能耗较高,影响了科学研究的可靠性和资源的有效利用。

核心思路:通过比较Python、NumPy、TensorFlow和PyTorch中的主要PRNG实现,评估其统计质量、时间效率和能耗,以验证这些实现是否能够保持与C语言实现相当的性能和可重复性。

技术框架:研究采用Mersenne Twister、PCG和Philox算法,设计实验以比较不同实现的性能。实验流程包括选择算法、实现比较、性能测试和能耗测量等主要模块。

关键创新:本研究的创新在于系统性地比较了多种流行机器学习框架中的PRNG实现,揭示了它们在时间性能和能耗上的优势,同时指出了数值可重复性的问题。

关键设计:实验中对比了不同实现的时间性能和能耗,设置了相同的种子和算法进行测试,确保了实验的公平性和可比性。

📊 实验亮点

实验结果显示,机器学习框架的时间性能与C实现相近,甚至在某些情况下更优,能耗仅比C实现高出10%。然而,不同平台间对于相同种子和算法的数值可重复性未能实现,表明仍需改进。

🎯 应用场景

该研究对机器学习领域的伪随机数生成器实现提供了重要的参考,尤其是在需要高可重复性和低能耗的应用场景中,如科学计算、模拟和优化等。未来,研究成果可为开发更高效的机器学习框架提供指导。

📄 摘要(原文)

Pseudo-Random Number Generators (PRNGs) have become ubiquitous in machine learning technologies because they are interesting for numerous methods. The field of machine learning holds the potential for substantial advancements across various domains, as exemplified by recent breakthroughs in Large Language Models (LLMs). However, despite the growing interest, persistent concerns include issues related to reproducibility and energy consumption. Reproducibility is crucial for robust scientific inquiry and explainability, while energy efficiency underscores the imperative to conserve finite global resources. This study delves into the investigation of whether the leading Pseudo-Random Number Generators (PRNGs) employed in machine learning languages, libraries, and frameworks uphold statistical quality and numerical reproducibility when compared to the original C implementation of the respective PRNG algorithms. Additionally, we aim to evaluate the time efficiency and energy consumption of various implementations. Our experiments encompass Python, NumPy, TensorFlow, and PyTorch, utilizing the Mersenne Twister, PCG, and Philox algorithms. Remarkably, we verified that the temporal performance of machine learning technologies closely aligns with that of C-based implementations, with instances of achieving even superior performances. On the other hand, it is noteworthy that ML technologies consumed only 10% more energy than their C-implementation counterparts. However, while statistical quality was found to be comparable, achieving numerical reproducibility across different platforms for identical seeds and algorithms was not achieved.