Microsoft introduces “ONNX Script,” a Python library for crafting machine learning models

TL;DR:

  • Microsoft introduces “ONNX Script,” a Python library for crafting machine learning models.
  • ONNX Script emphasizes clean, idiomatic Python syntax and composability using ONNX-native functions.
  • ONNX (Open Neural Network Exchange) defines a standard for machine learning interoperability, enabling usage across various frameworks and tools.
  • The ONNX Script project democratizes ONNX model development, reducing the need for deep ONNX expertise.
  • Key components include a converter for ONNX Script functions to ONNX graphs and runtime support for eager-mode evaluation.
  • ONNX Script supports idiomatic Python constructs like conditionals, loops, and operators, enhancing natural model authoring.
  • Microsoft envisions ONNX Script as a foundational element for its PyTorch ONNX exporter, serving TorchDynamo—a Python-level JIT compiler for accelerated PyTorch programs.
  • The integration of ONNX Script into the PyTorch ecosystem signifies Microsoft’s commitment to innovation in machine learning.

Main AI News:

In a pioneering move, Microsoft has introduced the world to “ONNX Script,” a groundbreaking library tailored to crafting cutting-edge machine learning models using Python. Renowned as the go-to programming language for data science and machine learning, Python is now elevated to new heights of efficiency and versatility through the ONNX Script project. This revolutionary venture focuses on delivering pristine, idiomatic Python syntax and seamless composability using ONNX-native functions.

ONNX, standing for Open Neural Network Exchange, stands as a pivotal open standard for achieving machine learning interoperability. It defines a universal framework of fundamental building blocks called operators, which are essential components for constructing machine learning and deep learning models. These operators are accompanied by a standardized file format, empowering AI developers to harness models across diverse frameworks, tools, runtimes, and compilers with effortless finesse.

The ONNX Script initiative, headquartered on GitHub, ushers in a new era of accessibility and democratization in machine learning. Prior to this innovative approach, developing ONNX models necessitated an in-depth grasp of the specification and serialization format itself. However, Microsoft’s ONNX Script changes the game by providing a user-friendly gateway, allowing coders to write ONNX machine learning models with proficiency, regardless of their prior ONNX expertise.

The core attributes of ONNX Script are rooted in its dedication to achieving the following:

  • Expressiveness: Enabling the creation of all ONNX functions with unparalleled clarity.
  • Simplicity and Conciseness: Crafting function code that mirrors the natural simplicity of Python.
  • Debuggability: Facilitating eager-mode evaluation that empowers developers to debug code seamlessly using standard Python debuggers.

The ONNX Script methodology forges a deeper integration with Python, leveraging two fundamental components:

  1. A robust, strongly typed API for all ONNX operators (all 186 as of opset 19). This integration empowers existing Python tools, linters, and integrated development environments (IDEs) to offer invaluable insights and enforce coding accuracy.
  2. ONNX Script ingeniously incorporates idiomatic Python language constructs, embracing conditionals, loops, binary and unary operators, subscripting, slicing, and more. This includes translating familiar Python expressions, such as ‘a + b,’ into ONNX-native operators like ‘Add(a, b).’

The architecture of this innovative endeavor revolves around key components, including:

  • A converter that seamlessly translates Python ONNX Script functions into ONNX graphs. This is achieved by meticulously navigating the Python Abstract Syntax Tree to construct an equivalent ONNX graph.
  • A runtime shim empowers the evaluation of these functions in an “eager mode.” Currently reliant on the ONNX Runtime, a Python-exclusive reference runtime for ONNX is in development to further support this functionality.
  • A converter that facilitates the translation of ONNX models and functions into ONNX Script, enabling complete round-trip conversions between ONNX Script and ONNX graphs.

ONNX Script’s design places a strong emphasis on debuggability and incorporates front-and-center IntelliSense support. This is exemplified through the integrated development environment, as demonstrated by a Visual Studio Code screenshot displaying a hover tooltip for the ONNX Expand operator, complete with inline documentation and links to comprehensive online resources.

Beyond its role in democratizing ONNX machine learning model creation, Microsoft underscores that the ONNX Script initiative serves as the bedrock for its groundbreaking PyTorch ONNX exporter, specifically tailored to support TorchDynamo—what Microsoft terms as “the future of PyTorch.” TorchDynamo, a Python-level JIT compiler, is engineered to accelerate unmodified PyTorch programs.

PyTorch, an open source machine learning and deep learning framework, is rooted in the Torch library and finds applications in diverse fields such as computer vision and natural language processing. Developed by Facebook’s AI Research lab, PyTorch is a testament to the synergy of open source and innovation.

As PyTorch 2.1 inches closer to general availability, Microsoft promises to divulge further details about the PyTorch ONNX exporter. In the meantime, ONNX Script stands as a pervasive force in the company’s renewed approach, setting the stage for the future of machine learning innovation.

Moving forward, Microsoft envisions ONNX Script as a vehicle for defining and extending ONNX itself. The prospect of crafting new core operators and higher-order functions using ONNX Script is tantalizing, streamlining the evolution of the ONNX standard. This strategic vision is validated by the development of Torchlib, a testament to the viability of the approach. In the ensuing months, Microsoft plans to facilitate seamless conversions from ONNX to ONNX Script, enabling effortless editing of existing models. This not only plays a role in optimization passes but also facilitates the maintenance and evolution of ONNX models in a natural manner. Microsoft’s intent to propose ONNX Script for inclusion within the ONNX GitHub organization, under the umbrella of the Linux Foundation, further underscores the company’s commitment to fostering innovation in the realm of machine learning.

Conclusion:

Microsoft’s ONNX Script introduces a paradigm shift in Python-based machine learning model development. By simplifying and democratizing ONNX model creation, this innovation holds the potential to accelerate the adoption of advanced machine learning techniques across the market. The seamless integration with PyTorch underscores Microsoft’s commitment to driving innovation and accessibility in the machine learning landscape.

Source