Skip to content

Commit 17b8eca

Browse files
Feature/colab notebooks (#51)
Add colab notebooks
1 parent 17a2ec0 commit 17b8eca

25 files changed

+1945
-199
lines changed

examples/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The following are the currently available examples:
44

5-
- [Dot Product](./dot_product)
6-
- [Matrix Multiplication](./matrix_multiplication)
7-
- [Broadcasting](./broadcasting/)
8-
- [Rational Numbers](./rational_numbers/)
5+
- **Dot Product** [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NillionNetwork/nada-numpy/blob/main/examples/dot_product/dot_product.ipynb)
6+
- **Matrix Multiplication** [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NillionNetwork/nada-numpy/blob/main/examples/matrix_multiplication/matrix_multiplication.ipynb)
7+
- **Broadcasting** [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NillionNetwork/nada-numpy/blob/main/examples/broadcasting/broadcasting.ipynb)
8+
- **Rational Numbers** [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NillionNetwork/nada-numpy/blob/main/examples/rational_numbers/rational_numbers.ipynb)

examples/broadcasting/README.md

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,23 @@
11
# Broadcasting Tutorial
22

3-
This tutorial shows how to efficiently use broadcasting in Nada using Nada Numpy.
3+
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NillionNetwork/nada-numpy/blob/main/examples/broadcasting/broadcasting.ipynb)
44

5-
```python
6-
from nada_dsl import *
5+
This tutorial shows how to efficiently use broadcasting in Nada using Nada Numpy.
76

8-
# Step 0: Nada Numpy is imported with this line
9-
import nada_numpy as na
7+
## 🚨 Limitations
8+
The choice for blind computing implies certain trade-offs in comparison to conventional computing. What you gain in privacy, you pay in extra computational overhead & capacity constraints.
109

10+
Therefore, you will notice that large-scale computational workloads may lead to long compilation and/or execution times or hitting network capacity guardrails.
1111

12-
def nada_main():
13-
# Step 1: We use Nada Numpy wrapper to create "Party0", "Party1" and "Party2"
14-
parties = na.parties(3)
12+
That said, the Nillion team is working around the clock to push the boundaries of this technology and bring the potential of blind computing to reality 🚀
1513

16-
# Step 2: Party0 creates an array of dimension (3, ) with name "A"
17-
a = na.array([3], parties[0], "A", SecretInteger)
14+
👉 This example has been tested on local devnet with arrays of up to 1000 elements.
1815

19-
# Step 3: Party1 creates an array of dimension (3, ) with name "B"
20-
b = na.array([3], parties[1], "B", SecretInteger)
16+
## ➡️ Stay in touch
17+
If you want to get involved in the blind computing community and be the first to know all big updates, join our Discord
2118

22-
# Step 4: Party0 creates an array of dimension (3, ) with name "C"
23-
c = na.array([3], parties[0], "C", SecretInteger)
19+
[![Discord](https://img.shields.io/badge/Discord-nillionnetwork-%235865F2?logo=discord)](https://discord.gg/nillionnetwork)
2420

25-
# Step 5: Party1 creates an array of dimension (3, ) with name "D"
26-
d = na.array([3], parties[1], "D", SecretInteger)
21+
And if you want to contribute to the blind computing revolution, we welcome open-source contributors!
2722

28-
# Step 4: The result is of computing SIMD operations on top of the elements of the array
29-
# SIMD operations are performed on all the elements of the array.
30-
# The equivalent would be: for i in range(3): result += a[i] + b[i] - c[i] * d[i]
31-
result = a + b - c * d
32-
# Step 5: We can use result.output() to produce the output for Party2 and variable name "my_output"
33-
return result.output(parties[2], "my_output")
34-
```
35-
36-
0. We import Nada Numpy using `import nada_numpy as na`.
37-
1. We create an array of parties, with our wrapper using `parties = na.parties(3)` which creates an array of parties named: `Party0`, `Party1` and `Party2`.
38-
2. We create our input array `a` with `na.array([3], parties[0], "A")`, meaning our array will have dimension 3, `Party0` will be in charge of giving its inputs and the name of the variable is `"A"`.
39-
3. We create our input array `b` with `na.array([3], parties[1], "B")`, meaning our array will have dimension 3, `Party1` will be in charge of giving its inputs and the name of the variable is `"B"`.
40-
4. We create our input array `c` with `na.array([3], parties[1], "C")`, meaning our array will have dimension 3, `Party0` will be in charge of giving its inputs and the name of the variable is `"C"`.
41-
5. We create our input array `d` with `na.array([3], parties[1], "D")`, meaning our array will have dimension 3, `Party1` will be in charge of giving its inputs and the name of the variable is `"D"`.
42-
5. Finally, we use Nada Numpy to produce the outputs of the array like: `result.output(parties[2], "my_output")` establishing that the output party will be `Party2`and the name of the output variable will be `my_output`.
43-
# How to run the tutorial.
44-
45-
1. First, we need to compile the nada program running: `nada build`.
46-
2. (Optional) Then, we can test our program is running with: `nada test`.
47-
3. Finally, we can call our Nada program via the Nillion python client by running: `python3 main.py`
23+
[![GitHub Discussions](https://img.shields.io/badge/GitHub_Discussions-NillionNetwork-%23181717?logo=github)](https://github.com/orgs/NillionNetwork/discussions)

0 commit comments

Comments
 (0)