Interview
Python, OCaml, and Machine Learning with Laurent Mazare
- Laurent Mazarin intends to divide his time equally between production-critical OCaml development and Python-based research, aiming to leverage OCaml's long-term reliability for deployment while utilizing Python's dynamic typing for speed in exploratory algorithms and data analysis.
- The outlook anticipates Python's ecosystem expanding in popularity for machine learning due to superior notebook visualization capabilities and the elimination of initial static type negotiations, whereas OCaml offers higher library quality but fewer options and faces challenges with numerical runtime errors that static types do not always catch.
- A proposed future workflow involves developing and training models in Python for efficiency, followed by deploying the infrastructure and trading systems in OCaml to prevent failures in long-running jobs caused by late-discovered bugs, utilizing the PyML library to compile OCaml into shared libraries accessible to Python without wrapper code.
- Jane Street plans to enhance internal Python tooling by adding type annotations, generating documentation, and strengthening testing cultures, while also seeking to replicate existing Python models in OCaml to ensure consistency, despite the ongoing difficulty of keeping dual implementations synchronized.
- Risks in mixed-runtime environments include potential memory leaks caused by cycles between OCaml and Python garbage collectors, and the current inability of OCaml's type system to effectively capture bugs in numerical code, leading to the consideration of "Polynode" as an alternative to Jupyter with a more explicit state model, albeit with limitations regarding deep object mutations.
- Future development focuses on implementing algebraic effects and linear types in OCaml to enable precise resource management for GPUs and file handles, with a Jane Street developer hired specifically for this task to eventually match Rust's safety guarantees without its ergonomic overhead.
- Jane Street will continue expanding OCaml editor integrations for Emacs and Vim using OCaml extensions, while broader industry trends such as Google exploring Swift compilation for specialized hardware (GPUs/TPUs) are noted for their potential reference-counting advantages in managing large machine learning models compared to OCaml's garbage collection.