Skip to content

Commit

Permalink
Merge pull request #152 from gizatechxyz/develop
Browse files Browse the repository at this point in the history
merge develop into main
  • Loading branch information
raphaelDkhn authored Jul 13, 2023
2 parents 7a9922b + 0ec2272 commit e1eea70
Show file tree
Hide file tree
Showing 790 changed files with 37,696 additions and 7,870 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on: [push, pull_request]

env:
ARCHIVE_LINK: https://github.com/starkware-libs/cairo/releases/download/v1.1.0/release-x86_64-unknown-linux-musl.tar.gz
ARCHIVE_LINK: https://github.com/starkware-libs/cairo/releases/download/v2.0.2/release-x86_64-unknown-linux-musl.tar.gz
ARCHIVE_NAME: cairo.zip

jobs:
Expand Down
41 changes: 14 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,31 @@
[![Join the community](https://dcbadge.vercel.app/api/server/FR3Cd88x6r?style=flat-square)](https://discord.gg/FR3Cd88x6r)
</div>


# Orion: Cairo library for Validity ML ✨
# Orion: An Open-source Framework for Validity and ZK ML ✨
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Orion is an open-source, community-driven framework dedicated to Provable Machine Learning. It provides essential components and a new ONNX runtime for building verifiable Machine Learning models using [STARKs](https://starkware.co/stark/).

## 🤔 What is ONNX Runtime?

Orion is a Cairo library that provides two high-level features:

* Tensor computation (like Numpy) in Cairo 1.0.
* Verifiable Machine Learning models using STARKS.

### 🤔 What is ONNX Runtime inference?

ONNX Runtime is an open-source, high-performance inference engine for machine learning models in the Open Neural Network Exchange (ONNX) format. ONNX is an interoperable format that allows deep learning models to be represented, shared, and executed across different AI frameworks and platforms.

ONNX Runtime inference can enable faster user experiences and lower costs, supporting models from deep learning frameworks such as PyTorch and TensorFlow/Keras as well as classical machine learning libraries such as scikit-learn, LightGBM, XGBoost, etc. ONNX Runtime is compatible with various hardware, drivers, and operating systems, and provides optimal performance by leveraging hardware accelerators where applicable alongside graph optimizations and transforms. [Learn more →](https://www.onnxruntime.ai/docs/#onnx-runtime-for-inferencing)

This library proposes a new ONNX runtime built with [Cairo](https://www.cairo-lang.org/). The purpose is to provide a runtime implementation for verifiable ML model inferences using [STARKs](https://starkware.co/stark/).

✨🚀 **New contributors are welcome to implement new ONNX Operators in Cairo 1.0!** 🌟💡

## 📚 How to use our docs
ONNX (Open Neural Network Exchange), is an open-source standard created to represent deep learning models. The aim of its development was to enable interoperability among diverse deep learning frameworks, like TensorFlow or PyTorch. By offering a universal file format, ONNX allows models trained in one framework to be readily applied in another for inference, eliminating the need for model conversion.

You can check our official docs [here](https://orion.gizatech.xyz/).

- ⚙️ **APIs** includes our Getting Started guide, API Reference, and more advanced features of the core like Tensor, Operators and Optimizations.
Ensuring compatibility with ONNX operators facilitates integration into the ONNX ecosystem. This enables researchers and developers to pre-train models using their preferred framework, before executing verifiable inferences with Orion.

- 🧩 **Algorithms** is an open collection of algorithms implemented using Orion to be used by the community.
## 🌱 Where to start?

- 🧠 **Knowledge base** is a self-serve library of tips, step-by-step tutorials, and articles that answer your questions about creating verifiable ML models in Cairo.
You can check our official docs [here](https://orion.gizatech.xyz/welcome/readme).
- 🧱 [Framework](https://orion.gizatech.xyz/v/develop/framework/get-started): The building blocks for Verifiable Machine Learning models.
- 🏛 [Hub](https://orion.gizatech.xyz/v/develop/hub/algorithms): A curated collection of ML models and spaces built by the community using Orion framework.
- 🎓 [Academy](https://orion.gizatech.xyz/v/develop/academy/tutorials): Resources and tutorials for learning how to build ValidityML models using Orion.

## 🌟 What's new
## What's new?

For a detailed list of changes, please refer to the [CHANGELOG](./docs/CHANGELOG.md) file.
For a detailed list of changes, please refer to the [CHANGELOG](https://github.com/franalgaba/onnx-cairo/blob/main/docs/CHANGELOG.md) file.

## 🤝 Join the community!
## 💖 Join the community!

Join the community and help build a safer and transparent AI in our [Discord](https://discord.gg/Kt24CsMb5k)!

Expand All @@ -69,7 +56,7 @@ For a full list of all authors and contributors, see [the contributors page](htt

This project is licensed under the **MIT license**.

See [LICENSE](LICENSE) for more information.
See [LICENSE](https://github.com/franalgaba/onnx-cairo/blob/main/LICENSE/README.md) for more information.

## Contributors ✨

Expand Down
7 changes: 4 additions & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "orion"
version = "0.0.1"
description = "ONNX Runtime built in Cairo 1.0"
homepage = "https://github.com/franalgaba/onnx-cairo"
version = "0.1.0"
cairo-version = ">=2.0.1"
description = "ONNX Runtime in Cairo for verifiable ML inference using STARK"
homepage = "https://github.com/gizatechxyz/orion"

[scripts]
sierra = "cairo-compile . -r"
Expand Down
28 changes: 18 additions & 10 deletions docgen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
use regex::Regex;
use std::fs;
use std::path::Path;
use regex::Regex;

fn main() {
// TENSOR DOC
let trait_path = "src/operators/tensor/core.cairo";
let doc_path = "docs/apis/operators/tensor";
let doc_path = "docs/framework/operators/tensor";
let label = "tensor";
let trait_name = "TensorTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// NN DOC
let trait_path = "src/operators/nn/core.cairo";
let doc_path = "docs/apis/operators/neural-network";
let doc_path = "docs/framework/operators/neural-network";
let label = "nn";
let trait_name = "NNTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// FIXED POINT DOC
let trait_path = "src/numbers/fixed_point/core.cairo";
let doc_path = "docs/apis/numbers/fixed-point";
let doc_path = "docs/framework/numbers/fixed-point";
let label = "fp";
let trait_name = "FixedTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// SIGNED INTEGER DOC
let trait_path = "src/numbers/signed_integer/integer_trait.cairo";
let doc_path = "docs/apis/numbers/signed-integer";
let doc_path = "docs/framework/numbers/signed-integer";
let label = "int";
let trait_name: &str = "IntegerTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// PERFORMANCE DOC
let trait_path = "src/performance/core.cairo";
let doc_path = "docs/apis/performance";
let doc_path = "docs/framework/performance";
let label = "performance";
let trait_name = "PerfomanceTrait";
doc_trait(trait_path, doc_path, label);
Expand Down Expand Up @@ -94,9 +94,11 @@ fn doc_functions(trait_path: &str, doc_path: &str, trait_name: &str, label: &str
let contents = fs::read_to_string(filepath).expect("Something went wrong reading the file");

// Find the trait block
let trait_re = Regex::new(
&format!(r"(?s)trait\s+{}\s*(<[\w\s,]*>)?\s*\{{.*?\n\s*\}}", trait_name)
).unwrap();
let trait_re = Regex::new(&format!(
r"(?s)trait\s+{}\s*(<[\w\s,]*>)?\s*\{{.*?\n\s*\}}",
trait_name
))
.unwrap();

let trait_match = trait_re.captures(&contents).unwrap();
let trait_block = trait_match.get(0).unwrap().as_str();
Expand All @@ -112,7 +114,13 @@ fn doc_functions(trait_path: &str, doc_path: &str, trait_name: &str, label: &str

let transformed_comment = doc_comment
.lines()
.map(|line| line.trim_start().trim_start_matches("///").trim())
.map(|line| {
line.trim_start().strip_prefix("/// ").unwrap_or(
line.trim_start()
.strip_prefix("///")
.unwrap_or(line.trim_start()),
)
})
.collect::<Vec<_>>()
.join("\n");

Expand Down
Binary file added docs/.gitbook/assets/Orion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/article_header_ORION.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 126 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,138 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2023-07-12

### Removed
- Removed check_gas()


## [Unreleased] - 2023-07-11

### Changed
- Refactored Perfomance trait to take two generic parameters:
- `T`, the type of the unquantized tensor. Currently support `FixedType` and `i32`.
- `Q`, the type of the quantized tensor. Currently support `i8`.


## [Unreleased] - 2023-07-10

### Added
- Implement Tensor int8
- Implement NN int8
- Added DequantizeLinear operator

### Fixed
- Fixed docgen

## [Unreleased] - 2023-07-09

### Added
- implement TensorSerde

## [Unreleased] - 2023-07-04

### Added
- Added arcsin implementation and tests

## [Unreleased] - 2023-07-08

### Added

- Added arctangent operator
## [Unreleased] - 2023-07-06

### Added

- Add QuantizeLinear

## [Unreleased] - 2023-07-01

### Added
- Added cosine implementation and tests

## [Unreleased] - 2023-06-29

### Added

- Added acosh operator

## [Unreleased] - 2023-06-29

### Added

- Added flatten operator

## [Unreleased] - 2023-06-28

### Added

- Added asinh operator

## [Unreleased] - 2023-06-28

### Added

- Added cosh operator

## [Unreleased] - 2023-06-27

### Added

- Added tanh operator

## [Unreleased] - 2023-06-27

### Added

- Added sinh operator

## [Unreleased] - 2023-06-24

### Added

- Added cumsum operator

## [Unreleased] - 2023-06-23

### Changed

- Replace array.at with IndexView

## [Unreleased] - 2023-06-30

### Added
- Added sine implementation and tests

## [Unreleased] - 2023-06-21

### Changed

- Refactor nn tests to cover n-dimensions

## [Unreleased] - 2023-06-21

### Changed

- Refactor tensor tests to cover n-dimensions

## [Unreleased] - 2023-06-20

### Changed

- Upgrade Cairo version to v2.0.0-rc

## [Unreleased] - 2023-06-17

### Added

- Into trait to signed integers

## [Unreleased] - 2023-06-16

### Changed
- Updated argmax function parameters

- Updated argmax function parameters
- Restructured tests for argmax and argmin

## [Unreleased] - 2023-06-11
Expand All @@ -21,10 +144,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Added ln functionality to tensor trait. Added Logsoftmax implementation for nn trait.
- Added tests for both.

## [Unreleased] - 2023-06-08

### Added

- Added argmin tensor operator

## [Unreleased] - 2023-06-07
Expand Down
17 changes: 7 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
---
description: ONNX Runtime in Cairo 1.0
description: An Open-source ecosystem for Validity and ZK ML.
---

# Orion

Orion is a Cairo library that provides two high-level features:
Orion is an open-source, community-driven framework dedicated to Provable Machine Learning. It provides essential components and a new ONNX runtime for building verifiable Machine Learning models using [STARKs](https://starkware.co/stark/).

* Tensor computation (like Numpy) in Cairo 1.0.
* Verifiable Machine Learning models using STARKS.
<figure><img src=".gitbook/assets/Orion.png" alt="" width="563"><figcaption></figcaption></figure>

### 🤔 What is ONNX Runtime inference?
### 🤔 What is ONNX Runtime?

ONNX Runtime is an open-source, high-performance inference engine for machine learning models in the Open Neural Network Exchange (ONNX) format. ONNX is an interoperable format that allows deep learning models to be represented, shared, and executed across different AI frameworks and platforms.
ONNX (Open Neural Network Exchange), is an open-source standard created to represent deep learning models. The aim of its development was to enable interoperability among diverse deep learning frameworks, like TensorFlow or PyTorch. By offering a universal file format, ONNX allows models trained in one framework to be readily applied in another for inference, eliminating the need for model conversion.

ONNX Runtime inference can enable faster user experiences and lower costs, supporting models from deep learning frameworks such as PyTorch and TensorFlow/Keras as well as classical machine learning libraries such as scikit-learn, LightGBM, XGBoost, etc. ONNX Runtime is compatible with various hardware, drivers, and operating systems, and provides optimal performance by leveraging hardware accelerators where applicable alongside graph optimizations and transforms. [Learn more →](https://www.onnxruntime.ai/docs/#onnx-runtime-for-inferencing)

This library proposes a new ONNX runtime built with [Cairo](https://www.cairo-lang.org/). The purpose is to provide a runtime implementation for verifiable ML model inferences using [STARKs](https://starkware.co/stark/).
Ensuring compatibility with ONNX operators facilitates integration into the ONNX ecosystem. This enables researchers and developers to pre-train models using their preferred framework, before executing verifiable inferences with Orion.

### 🌱 Where to start?

<table data-view="cards"><thead><tr><th align="center"></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"></td><td>🧱 <strong>APIs</strong></td><td>Three APIs that will help you to build your Validity ML models.</td><td><a href="apis/get-started.md">get-started.md</a></td></tr><tr><td align="center"></td><td>🧩 <strong>Algorithms</strong></td><td>Discover all algorithms built by the community, or build your own.</td><td><a href="community/algorithms.md">algorithms.md</a></td></tr><tr><td align="center"></td><td>📖 <strong>Tutorials</strong></td><td>Try out the awesome guides and tutorials created by the community.</td><td><a href="resources/tutorials/">tutorials</a></td></tr></tbody></table>
<table data-view="cards"><thead><tr><th align="center"></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"></td><td>🧱 <strong>Framework</strong></td><td>The building blocks for Verifiable Machine Learning models.</td><td><a href="broken-reference">Broken link</a></td></tr><tr><td align="center"></td><td>🏛 <strong>Hub</strong></td><td>A curated collection of ML models and spaces built by the community using Orion framework.</td><td><a href="broken-reference">Broken link</a></td></tr><tr><td align="center"></td><td>🎓 <strong>Academy</strong></td><td>Resources and tutorials for learning how to build ValidityML models using Orion.</td><td><a href="broken-reference">Broken link</a></td></tr></tbody></table>

### ✨ What's new?

Expand Down
Loading

0 comments on commit e1eea70

Please sign in to comment.