{"id":37758757,"url":"https://github.com/zakuro-ai/sakura","last_synced_at":"2026-01-16T14:34:03.620Z","repository":{"id":52939020,"uuid":"221662222","full_name":"zakuro-ai/sakura","owner":"zakuro-ai","description":"Sakura is the ML library of the Zakuro framework. It provides asynchronous distributed training for Pytorch. ","archived":false,"fork":false,"pushed_at":"2025-06-27T02:58:50.000Z","size":56821,"stargazers_count":16,"open_issues_count":11,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-27T03:48:25.551Z","etag":null,"topics":["asynchronous-programming","deeplearning","machine-learning","ml","p2p","p2p-network","python","sakura","sakura-ml","zakuro","zakuro-ai"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zakuro-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-14T09:44:13.000Z","updated_at":"2025-01-30T07:26:05.000Z","dependencies_parsed_at":"2023-01-30T20:31:06.406Z","dependency_job_id":"53877af1-6971-4658-a360-e2d2b322d6a3","html_url":"https://github.com/zakuro-ai/sakura","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zakuro-ai/sakura","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakuro-ai%2Fsakura","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakuro-ai%2Fsakura/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakuro-ai%2Fsakura/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakuro-ai%2Fsakura/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zakuro-ai","download_url":"https://codeload.github.com/zakuro-ai/sakura/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakuro-ai%2Fsakura/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous-programming","deeplearning","machine-learning","ml","p2p","p2p-network","python","sakura","sakura-ml","zakuro","zakuro-ai"],"created_at":"2026-01-16T14:34:03.564Z","updated_at":"2026-01-16T14:34:03.612Z","avatar_url":"https://github.com/zakuro-ai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003cimg src=\"https://drive.google.com/uc?id=1Mz2WqXHrwEOjwtWfJVHV7NiRwC_64Shh\"\u003e\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#modules\"\u003eModules\u003c/a\u003e •\n  \u003ca href=\"#code-structure\"\u003eCode structure\u003c/a\u003e •\n  \u003ca href=\"#code-design\"\u003eCode design\u003c/a\u003e •\n  \u003ca href=\"#installing-the-application\"\u003eInstalling the application\u003c/a\u003e •\n  \u003ca href=\"#makefile-commands\"\u003eMakefile commands\u003c/a\u003e •\n  \u003ca href=\"#environments\"\u003eEnvironments\u003c/a\u003e •\n  \u003ca href=\"#running-the-application\"\u003eRunning the application\u003c/a\u003e\n\u003c/p\u003e\n\n\n--------------------------------------------------------------------------------\n\nSakura is a simple but powerfull tool to reduce training time by running the train/test asynchronously. It provides two features:\n- A simple ML framework for asynchronous training.\n- An integration with PyTorch. \n\n\nYou can reuse your favorite Python framework such as Pytorch, Tensorflow or PaddlePaddle.\n\n\n# Modules\n\nAt a granular level, Sakura is a library that consists of the following components:\n\n| Component | Description |\n| ---- | --- |\n| **sakura** | Contains the sakura modules. |\n| **sakura.ml** | Contains the code related to ml processing |\n\n\n\n# Code structure\n```python\nfrom setuptools import setup\nfrom sakura import __version__\n\nsetup(\n    name=\"sakura-ml\",\n    version=__version__,\n    short_description=\"Sakura provides asynchronous training for DNN.\",\n    long_description=\"Sakura provides asynchronous training for DNN.\",\n    url='https://zakuro.ai',\n    packages=[\n        \"sakura\",\n        \"sakura.lightning\",\n    ],\n    include_package_data=True,\n    package_data={\"\": [\"*.yml\"]},\n    install_requires=[r.rsplit()[0] for r in open(\"requirements.txt\")],\n    license='MIT',\n    author='ZakuroAI',\n    python_requires='\u003e=3.6',\n    author_email='git@zakuro.ai',\n    description='Sakura provides asynchronous training for DNN.',\n    platforms=\"linux_debian_10_x86_64\",\n    classifiers=[\n        \"Programming Language :: Python :: 3\",\n        \"License :: OSI Approved :: MIT License\",\n    ]\n)\n```\n# Code design\nIf you worked with PyTorch in your project your would find a common structure. \nSimply change the `test` and `train` in your trainer as shown in `mnist_demo`. \n```python\nimport os\nimport lightning as L\nimport torch\nfrom torch import nn\nfrom torch.nn import functional as F\nfrom torch.utils.data import DataLoader\nfrom torchvision import transforms\nfrom torchvision.datasets import MNIST\nimport argparse\nfrom sakura.lightning import SakuraTrainer\n\n\nclass MNISTModel(L.LightningModule):\n    def __init__(self):\n        super(MNISTModel, self).__init__()\n        self.conv1 = nn.Conv2d(1, 32, 3, 1)\n        self.conv2 = nn.Conv2d(32, 64, 3, 1)\n        self.dropout1 = nn.Dropout(0.25)\n        self.dropout2 = nn.Dropout(0.5)\n        self.fc1 = nn.Linear(9216, 128)\n        self.fc2 = nn.Linear(128, 10)\n\n    def forward(self, x):\n        x = self.conv1(x)\n        x = F.relu(x)\n        x = self.conv2(x)\n        x = F.relu(x)\n        x = F.max_pool2d(x, 2)\n        x = self.dropout1(x)\n        x = torch.flatten(x, 1)\n        x = self.fc1(x)\n        x = F.relu(x)\n        x = self.dropout2(x)\n        x = self.fc2(x)\n        output = F.log_softmax(x, dim=1)\n        return output\n\n    def training_step(self, batch, batch_nb):\n        x, y = batch\n        loss = F.cross_entropy(self(x), y)\n        return loss\n\n    def validation_step(self, batch, batch_nb):\n        with torch.no_grad():\n            x, y = batch\n            loss = F.cross_entropy(self(x), y)\n        return loss\n\n    def configure_optimizers(self):\n        return torch.optim.Adam(self.parameters(), lr=0.02)\n\n\nif __name__ == \"__main__\":\n    PATH_DATASETS = os.environ.get(\"PATH_DATASETS\", \".\")\n    BATCH_SIZE = 2000 if torch.cuda.is_available() else 64\n    # Init our model\n    mnist_model = MNISTModel()\n\n    # Init DataLoader from MNIST Dataset\n    train_ds = MNIST(\n        PATH_DATASETS, train=True, download=True, transform=transforms.ToTensor()\n    )\n    train_loader = DataLoader(train_ds, batch_size=BATCH_SIZE)\n\n    # Init DataLoader from MNIST Dataset\n    val_ds = MNIST(\n        PATH_DATASETS, train=False, download=True, transform=transforms.ToTensor()\n    )\n    val_loader = DataLoader(val_ds, batch_size=BATCH_SIZE)\n\n    trainer = SakuraTrainer(\n        accelerator=\"auto\",\n        max_epochs=10,\n    )\n\n    trainer.run(\n        mnist_model, train_loader, val_loader, model_path=\"models/best_model.pth\"\n    )\n\n```\n\n# Installing the application\nTo clone and run this application, you'll need the following installed on your computer:\n- [Git](https://git-scm.com)\n- Docker Desktop\n   - [Install Docker Desktop on Mac](https://docs.docker.com/docker-for-mac/install/)\n   - [Install Docker Desktop on Windows](https://docs.docker.com/desktop/install/windows-install/)\n   - [Install Docker Desktop on Linux](https://docs.docker.com/desktop/install/linux-install/)\n- [Python](https://www.python.org/downloads/)\n\n### Clone the code and install the binary\n```bash\n# Clone this repository and install the code\ngit clone https://github.com/zakuro-ai/sakura\n\n# Go into the repository\ncd sakura\n\n# Update global variables\nsource .env\n\n# Install sakura\ncurl https://get.zakuro.ai/sakura/install | sh\n```\n\n### Check that the binary has been downloaded\n```bash\nwhich sakura\n```\n\n# Running the application\n\n```bash\nsakura main.py\n```\nYou should be able to see this output with no delay between epochs (asynchronous testing).\n```\n   _____           _                               __  __   _      \n  / ____|         | |                             |  \\/  | | |     \n | (___     __ _  | | __  _   _   _ __    __ _    | \\  / | | |     \n  \\___ \\   / _` | | |/ / | | | | | '__|  / _` |   | |\\/| | | |     \n  ____) | | (_| | |   \u003c  | |_| | | |    | (_| |   | |  | | | |____ \n |_____/   \\__,_| |_|\\_\\  \\__,_| |_|     \\__,_|   |_|  |_| |______|\n\n(0) MNIST | Epoch: 1/10 | Acc: 0.0000 / (0.0000) | Loss:0.0000 / (0.0000): 100%|██████████| 18/18 [00:06\u003c00:00,  2.69it/s]\n(1) MNIST | Epoch: 2/10 | Acc: 0.0000 / (0.0000) | Loss:0.0000 / (0.0000): 100%|██████████| 18/18 [00:05\u003c00:00,  3.36it/s]\n(2) MNIST | Epoch: 3/10 | Acc: 90.4600 / (90.4600) | Loss:0.4034 / (0.4034): 100%|██████████| 18/18 [00:05\u003c00:00,  3.42it/s]\n(3) MNIST | Epoch: 4/10 | Acc: 95.3246 / (95.3246) | Loss:0.1907 / (0.1907): 100%|██████████| 18/18 [00:05\u003c00:00,  3.43it/s]\n(4) MNIST | Epoch: 5/10 | Acc: 96.9332 / (96.9332) | Loss:0.1379 / (0.1379): 100%|██████████| 18/18 [00:05\u003c00:00,  3.38it/s]\n(5) MNIST | Epoch: 6/10 | Acc: 97.3693 / (97.3693) | Loss:0.1167 / (0.1167): 100%|██████████| 18/18 [00:05\u003c00:00,  3.42it/s]\n(6) MNIST | Epoch: 7/10 | Acc: 97.7237 / (97.7237) | Loss:0.1040 / (0.1040): 100%|██████████| 18/18 [00:05\u003c00:00,  3.41it/s]\n(7) MNIST | Epoch: 8/10 | Acc: 98.0172 / (98.0172) | Loss:0.0938 / (0.0938): 100%|██████████| 18/18 [00:05\u003c00:00,  3.31it/s]\n(8) MNIST | Epoch: 9/10 | Acc: 98.2402 / (98.2402) | Loss:0.0886 / (0.0886): 100%|██████████| 18/18 [00:05\u003c00:00,  3.41it/s]\n```\n\nFYI the meaning of the above notation is:\n```\n([best_epoch]) [name_exp] | Epoch: [current]/[total] | Acc: [current_test_acc] / ([best_test_acc]) | Loss:[current_test_loss] / ([best_test_loss]): 100%|███| [batch_k]/[batch_n] [[time_train]\u003c[time_left], [it/s]]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakuro-ai%2Fsakura","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzakuro-ai%2Fsakura","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakuro-ai%2Fsakura/lists"}