GithubHelp home page GithubHelp logo

chainyo / tensorshare Goto Github PK

View Code? Open in Web Editor NEW
30.0 1.0 0.0 656 KB

๐Ÿค Trade any tensors over the network

Home Page: https://chainyo.github.io/tensorshare/

License: MIT License

Dockerfile 0.27% Python 99.73%
machine-learning network tensors fastapi jax numpy paddlepaddle pydantic pytorch safetensors

tensorshare's Introduction

TensorShare

๐Ÿค Trade any tensors over the network


TensorShare is a powerful tool enabling โšก lightning-fast tensor sharing across networks.

This project leverages the best open-source tools to provide a simple and easy-to-use interface for sharing tensors:

  • safetensors for secure tensor serialization and deserialization.
  • pydantic for data validation and settings management.
  • fastapi for building APIs (and because it's too good to avoid it).

This project is heavily in development and is not ready for production use. Feel free to contribute to the project by opening issues and pull requests.

Usage

Example of tensors serialization with torch:

import torch
from tensorshare import TensorShare

tensors = {
    "embeddings": torch.zeros((2, 2)),
    "labels": torch.zeros((2, 2)),
}
ts = TensorShare.from_dict(tensors, backend="torch")
print(ts)
# tensors=b'gAAAAAAAAAB7ImVtYmVkZGluZ3MiOnsiZHR5cGUiO...' size=168

You can now freely send the tensors over the network via any means (e.g. HTTP, gRPC, ...).

On the other side, when you receive the tensors, you can deserialize them in any supported backend:

from tensorshare import Backend

np_tensors = ts.to_tensors(backend=Backend.NUMPY)
print(np_tensors)
# {
# 	'embeddings': array([[0., 0.], [0., 0.]], dtype=float32),
# 	'labels': array([[0., 0.], [0., 0.]], dtype=float32)
# }

For more examples and details, please refer to the Usage section.

Roadmap

tensorshare's People

Contributors

chainyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tensorshare's Issues

Add task tracking

For production environments, keeping track of the tasks sent to a server with a tracking tool, including a lightweight database system, could be nice.

Add client and router usage

Add the new TensorShareClient usage to the documentation and provide a code snippet to share FastAPI router integration.

Prepare client sending requests

To send any TenshorShare object across the network, we need prepared functions that allow this in one line.

  • takes a dict of tensors + metadata + backend as inputs
  • include headers with tokens
  • prepare payload
  • send request
  • sync + async?

Add Tensorflow

Tensorflow can be added when the v2.14.0 is released for pydanticv2 compatibility.

Add router server implementation

Users should be able to easily integrate into their FastAPI application the required endpoints from TensorShare with custom return functions and logic.

-> Leverages the APIRouter and Depends from FastAPI

Format tensors to dict function

Create a utility function that takes any tensors and formats them in a Dict.

  • use embeddings or embeddings_N when no key is provided
  • ensure keys are different

TensorConverter interface

To allow the user to convert the tensors without using a specific method, we will create an interface class that handles the conversion process automatically based on the input tensors.

The input tensors could have different formats like np.ndarray and torch.Tensor.

Add codecov

Add a coverage tool and a badge in the README.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.