{"id":28712830,"url":"https://github.com/nirw4nna/dsc","last_synced_at":"2026-01-21T13:25:19.814Z","repository":{"id":299090652,"uuid":"1002009262","full_name":"nirw4nna/dsc","owner":"nirw4nna","description":"Tensor library \u0026 inference framework for machine learning","archived":false,"fork":false,"pushed_at":"2025-10-03T17:13:57.000Z","size":826,"stargazers_count":117,"open_issues_count":6,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-19T22:58:05.193Z","etag":null,"topics":["cuda","gpu","large-language-models","machine-learning","pytorch","tensor-algebra"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nirw4nna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"nirw4nna"}},"created_at":"2025-06-14T14:16:50.000Z","updated_at":"2026-01-14T19:50:32.000Z","dependencies_parsed_at":"2025-07-04T11:05:32.087Z","dependency_job_id":"f625f139-66e5-4063-a72b-cb24e766a191","html_url":"https://github.com/nirw4nna/dsc","commit_stats":null,"previous_names":["nirw4nna/dsc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nirw4nna/dsc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirw4nna%2Fdsc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirw4nna%2Fdsc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirw4nna%2Fdsc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirw4nna%2Fdsc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nirw4nna","download_url":"https://codeload.github.com/nirw4nna/dsc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirw4nna%2Fdsc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28633757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["cuda","gpu","large-language-models","machine-learning","pytorch","tensor-algebra"],"created_at":"2025-06-15T00:00:42.964Z","updated_at":"2026-01-21T13:25:19.794Z","avatar_url":"https://github.com/nirw4nna.png","language":"C++","funding_links":["https://github.com/sponsors/nirw4nna"],"categories":["C++"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"docs/logo.png\" alt=\"Logo\" width=\"200\"\u003e\n\n\u003ch3\u003e\nDSC\n\u003c/h3\u003e\n\n[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![Unit Tests](https://github.com/nirw4nna/dsc/actions/workflows/tests.yml/badge.svg)](https://github.com/nirw4nna/dsc/actions/workflows/tests.yml)\n\n\u003c/div\u003e\n\n---\n\n## About\nDSC is a PyTorch-compatible tensor library and inference framework for machine learning models.\nIt features a C-compatible low-level API that is wrapped in a modern Python API very similar to NumPy / PyTorch but\nwith some nice usability improvements.\n\n\nSome key features of DSC include:\n- **Intuitive API**: DSC Python API closely resembles NumPy / PyTorch.\n\n\n- **Built-in neural networks support**: DSC comes with `nn.Module` built-in. Porting a model from PyTorch to DSC\nis trivial (check out the [examples](https://github.com/nirw4nna/dsc/tree/main/examples/models)).\n\n\n- **Multiple backends**: DSC supports both **CPU** and **CUDA** with other backends being worked on.\nPrograms written using DSC can seamlessly switch between backends by simply adding a `dsc.set_default_device('...')`\ninstruction, no changes needed.\n\n\n- **Minimal external dependencies**: DSC doesn't require external libraries to be efficient.\nOn CPU the core operations are written from scratch in portable C++, this makes code written using DSC extremely portable.\n\n\n- **No runtime allocations**: DSC has its own custom memory allocator, memory is pre-allocated\nonly once so no extra calls to `malloc()` or `free()` are required. It's also possible\nto switch to a linear allocator to remove the (minimal) overhead introduced by a general purpose allocator.\n\n\n---\n\n\n## Quick start\nGetting started with DSC is very simple. The only requirements are:\n- A compiler with good support for C++20\n- GNU Make for building\n\nOn a Linux-based system these can be obtained with:\n```shell\nsudo apt update\nsudo apt install build-essential\n```\n\n### Installation\nThe recommended way to install DSC is from source:\n```shell\ngit clone git@github.com:nirw4nna/dsc.git\ncd dsc/\npython3 -m venv venv\nsource venv/bin/activate\npython3 -m pip install -e .\n```\n\nTo build the C++ library:\n```shell\nmake clean; make shared DSC_FAST=1\n```\nThis will compile DSC without any debug information, you can specify different options\nto enable/disable specific features:\n\n| Option        | Description                                                                  |\n|---------------|------------------------------------------------------------------------------|\n| DSC_LOG_LEVEL | Configure the logging level (values: [0-3] with 0 meaning everything on)     |\n| DSC_FAST      | Turn off logging (level=2) and compile with the highest optimisation level   |\n| DSC_GPU       | Enable GPU support (**default=0**)                                           |\n| DSC_MAX_OBJS  | Max number of DSC tensors that can be used at the same time (**default=1K**) |\n| DSC_TRACING   | Enable tracing (**default=0**)                                               |\n\nTo verify that everything worked out as expected try a simple operation:\n```shell\npython3 -c \"import dsc; x = dsc.arange(10); print(x)\"\n```\n\n### Environment Variables\n| Variable        | Description                                                                                                                                                                                                                                                         |\n|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| DSC_NUM_THREADS | Use multiple threads (CPU). If you set it to -1 it will use half of your available cores (**default=1**)                                                                                                                                                            |\n| TRACE           | Enable tracing DSC kernels. Values: [0-3] with 0 meaning no tracing, 1 dump only to the console, 2 dump only as Perfetto-compatible json, 3 dump as both console and Perfetto. This option requires DSC to be compiled with tracing support enabled (**default=0**) |\n\n### Notes on GPU support\nDSC supports both AMD and NVIDIA GPUs. If compiled with `DSC_GPU=1` it will automatically detect the appropriate backend.\nYou can see which backend has been selected by checking the output of the Makefile or, once the compilation is done,\nuse the Python API:\n```python\nimport dsc\n\nif dsc.gpu.is_available(): # If a GPU backend has been detected you can check if it's ROCm or CUDA\n    dsc.gpu.is_rocm()\n    dsc.gpu.is_cuda()\n```\n\n### CUDA backend\nThis provides GPU acceleration on NVIDIA GPUs. To get started make sure to have the [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit)\ninstalled.\n\nTo build the C++ library with CUDA enabled simply specify `DSC_GPU=1`. CUDA will be detected automatically if you installed it.\n\n**Note:** if you see errors when compiling with CUDA support make sure that the CUDA installation path specified in the Makefile\nis correct. If this is not the case you have to manually update the Makefile or set the `CUDA` environment variable before calling `make`.\n\nTo verify that the CUDA backend is working try:\n```shell\npython3 -c \"import dsc; print(dsc.gpu.is_available() and dsc.gpu.is_cuda())\"\n```\n\n### HIP backend\nThis provides GPU acceleration on AMD GPUs. To get started make sure to have the [ROCm](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/quick-start.html#rocm-install-quick)\ninstalled.\n\nTo build the C++ library with ROCm enabled simply specify `DSC_GPU=1`. ROCm will be detected automatically if you installed it.\n\n**Note:** if you see errors when compiling with ROCm support make sure that the ROCm installation path specified in the Makefile\nis correct. If this is not the case you have to manually update the Makefile or set the `ROCM` environment variable before calling `make`.\n\nTo verify that the ROCm backend is working try:\n```shell\npython3 -c \"import dsc; print(dsc.gpu.is_available() and dsc.gpu.is_rocm())\"\n```\n\n## Setting a default device\nThe default device in DSC is the CPU. This means that, if you don't specify anything, all the operations will be\nperformed on the CPU even when a GPU device is available. To set a different device as default you can use\n```python\ndsc.set_default_device('gpu')\n```\nThis will make the GPU the default device and DSC will perform all the operations there by default.\n\n## Running tests\nDSC uses `pytest` to run unit tests against NumPy which is the reference for correctness.\n\nThe tests are structured as follows:\n- `test_ops_common` and `test_indexing` are used to test operations both on CPU and GPU using NumPy as reference\n- `test_ops_cpu` are CPU-specific\n- `test_ops_gpu` are GPU-specific and they use PyTorch as reference\n\nThe device on which tests are run can be configured by setting the environment variable `DSC_DEVICE` before calling pytest.\n\n**Note:** to use PyTorch with a ROCm-compatible GPU please refer to https://pytorch.org/get-started/locally/.\n\nTo run all the tests simple do:\n```bash\ncd python/tests/\npytest -s \u003ctest_file\u003e.py --no-header --no-summary -q\n```\n**Note:** there are quite a few tests so to run them it's better to compile DSC with `DSC_FAST=1`.\n\n## License\nBSD-3-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirw4nna%2Fdsc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnirw4nna%2Fdsc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirw4nna%2Fdsc/lists"}