Introduction to Endia 24.5.0
Endia is a cutting-edge library designed for scientific computing. It offers several robust features that cater to both beginner and advanced users engaged in scientific research and applications. Here's what makes Endia stand out:
Key Features
- Automatic Differentiation: Endia can compute derivatives of any order, allowing users to work with complex mathematical models with ease.
- Complex Numbers: The library supports complex numbers, enabling sophisticated scientific computations that are required in various research fields.
- Dual Interface: Endia provides flexibility by offering a choice between an imperative interface similar to PyTorch and a functional interface resembling JAX.
- JIT Compilation: Through integration with an advanced compiler like MAX, Endia boosts the speed of both training and inference in machine learning models.
User Guidance and Configuration
Before diving into using Endia, users should note that it is in the early stages of development. Therefore, it might not be suited for production environments just yet, and changes to the API may occur as new features are developed.
Installation Instructions
To get started with Endia:
- Install Mojo 24.5 - This is a foundational step, as Mojo is a required component that underpins Endia's functionality.
- Include the Endia Package - Users can download the package directly using the provided curl command. Remarkably, Endia doesn’t require additional internal dependencies, simplifying the setup process.
curl -o "endia.📦" https://raw.githubusercontent.com/endia-org/Endia/main/endia.mojopkg
Practical Example
To demonstrate Endia's versatility, let's walk through computing the value, gradient, and Hessian of a function, using both PyTorch-like and JAX-like interfaces.
PyTorch-like Approach
Using Endia's imperative interface involves explicitly handling the computational graph and computing gradients by calling a backward method:
from endia import Tensor, sum, arange
import endia.autograd.functional as F
def foo(x: Tensor) -> Tensor:
return sum(x ** 2)
def main():
x = arange(1.0, 4.0, requires_grad=True)
y = foo(x)
y.backward(create_graph=True)
dy_dx = x.grad()
d2y_dx2 = F.grad(outs=sum(dy_dx), inputs=x)[0]
print(y) # 14.0
print(dy_dx) # [2.0, 4.0, 6.0]
print(d2y_dx2) # [2.0, 2.0, 2.0]
JAX-like Approach
In contrast, using the functional interface allows the computation of derivatives more implicitly:
from endia import grad, jacobian
from endia.numpy import sum, arange, ndarray
def foo(x: ndarray) -> ndarray:
return sum(x**2)
def main():
foo_jac = grad(foo)
foo_hes = jacobian(foo_jac)
x = arange(1.0, 4.0)
print(foo(x)) # 14.0
print(foo_jac(x)[ndarray]) # [2.0, 4.0, 6.0]
print(foo_hes(x)[ndarray]) # [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]]
Purpose and Vision
Endia is designed from the ground up to be a powerful yet transparent scientific computing library. Unlike many existing libraries built on older code, Endia uses a minimalistic stack that provides clarity and educational insight into the underlying algorithms.
Endia's development aims to offer an intuitive experience for users, prioritizing explainability and education over sheer complexity. It stands as a testament to the idea that complex scientific tools can be both understandable and efficient.
Contribution and Support
For those interested in contributing to Endia, detailed guidelines are available in the project's GitHub repository.
Conclusion
Endia represents a bold step forward in scientific computing, balancing cutting-edge capabilities with transparency and ease of use. As development continues, users can expect additional features like GPU support, broadening the potential applications even further. Happy computing with Endia!