Principled and practical static analysis for Python: Weakest precondition inference of hyperparameter constraints
- 22 November 2023
- journal article
- research article
- Published by Wiley in Software: Practice and Experience
- Vol. 54 (3) , 363-393
Abstract
Application programming interfaces often have correctness constraints that cut across multiple arguments. Violating these constraints causes the underlying code to raise runtime exceptions, but at the interface level, these are usually documented at most informally. This article presents novel principled static analysis and the first interprocedural weakest‐precondition analysis for Python to extract inter‐argument constraints. The analysis is mostly static, but to make it tractable for typical Python idioms, it selectively switches to the concrete domain for some cases. This article focuses on the important case where the interfaces are machine‐learning operators and their arguments are hyperparameters, rife with constraints. We extracted hyperparameter constraints for 429 functions and operators from 11 libraries and found real bugs. We used a methodology to obtain ground truth for 181 operators from 8 machine‐learning libraries; the analysis achieved high precision and recall for them. Our technique advances static analysis for Python and is a step towards safer and more robust machine learning.Keywords
Funding Information
- National Science Foundation of Sri Lanka (#1814898)
This publication has 24 references indexed in Scilit:
- Python probabilistic type inference with natural language support2016
- Reim & ReImInferACM SIGPLAN Notices, 2012
- UrACM SIGPLAN Notices, 2010
- /*icomment2007
- Fast online pointer analysisACM Transactions on Programming Languages and Systems, 2007
- Boogie: A Modular Reusable Verifier for Object-Oriented Programs2006
- Javari2005
- Efficient weakest preconditionsInformation Processing Letters, 2005
- Extended static checking for JavaACM SIGPLAN Notices, 2002
- An axiomatic basis for computer programmingCommunications of the ACM, 1969