pyaccelerate 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyaccelerate-0.1.0/LICENSE +21 -0
- pyaccelerate-0.1.0/PKG-INFO +271 -0
- pyaccelerate-0.1.0/README.md +198 -0
- pyaccelerate-0.1.0/VERSION +1 -0
- pyaccelerate-0.1.0/pyproject.toml +112 -0
- pyaccelerate-0.1.0/setup.cfg +4 -0
- pyaccelerate-0.1.0/src/pyaccelerate/__init__.py +52 -0
- pyaccelerate-0.1.0/src/pyaccelerate/benchmark.py +308 -0
- pyaccelerate-0.1.0/src/pyaccelerate/cli.py +156 -0
- pyaccelerate-0.1.0/src/pyaccelerate/cpu.py +324 -0
- pyaccelerate-0.1.0/src/pyaccelerate/engine.py +326 -0
- pyaccelerate-0.1.0/src/pyaccelerate/gpu/__init__.py +44 -0
- pyaccelerate-0.1.0/src/pyaccelerate/gpu/cuda.py +135 -0
- pyaccelerate-0.1.0/src/pyaccelerate/gpu/detector.py +363 -0
- pyaccelerate-0.1.0/src/pyaccelerate/gpu/dispatch.py +171 -0
- pyaccelerate-0.1.0/src/pyaccelerate/gpu/intel.py +93 -0
- pyaccelerate-0.1.0/src/pyaccelerate/gpu/opencl.py +161 -0
- pyaccelerate-0.1.0/src/pyaccelerate/memory.py +144 -0
- pyaccelerate-0.1.0/src/pyaccelerate/profiler.py +253 -0
- pyaccelerate-0.1.0/src/pyaccelerate/py.typed +0 -0
- pyaccelerate-0.1.0/src/pyaccelerate/threads.py +410 -0
- pyaccelerate-0.1.0/src/pyaccelerate/virt.py +248 -0
- pyaccelerate-0.1.0/src/pyaccelerate.egg-info/PKG-INFO +271 -0
- pyaccelerate-0.1.0/src/pyaccelerate.egg-info/SOURCES.txt +33 -0
- pyaccelerate-0.1.0/src/pyaccelerate.egg-info/dependency_links.txt +1 -0
- pyaccelerate-0.1.0/src/pyaccelerate.egg-info/entry_points.txt +2 -0
- pyaccelerate-0.1.0/src/pyaccelerate.egg-info/requires.txt +31 -0
- pyaccelerate-0.1.0/src/pyaccelerate.egg-info/top_level.txt +1 -0
- pyaccelerate-0.1.0/tests/test_cpu.py +67 -0
- pyaccelerate-0.1.0/tests/test_engine.py +47 -0
- pyaccelerate-0.1.0/tests/test_gpu.py +98 -0
- pyaccelerate-0.1.0/tests/test_memory.py +57 -0
- pyaccelerate-0.1.0/tests/test_profiler.py +83 -0
- pyaccelerate-0.1.0/tests/test_threads.py +101 -0
- pyaccelerate-0.1.0/tests/test_virt.py +35 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Guilherme Pinheiro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyaccelerate
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: High-performance Python acceleration engine — CPU, threads, virtual threads, multi-GPU and virtualization.
|
|
5
|
+
Author-email: Guilherme Pinheiro <guilherme@example.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Guilherme Pinheiro
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/GuilhermeP96/pyaccelerate
|
|
29
|
+
Project-URL: Repository, https://github.com/GuilhermeP96/pyaccelerate
|
|
30
|
+
Project-URL: Issues, https://github.com/GuilhermeP96/pyaccelerate/issues
|
|
31
|
+
Keywords: acceleration,gpu,cuda,opencl,threads,performance,optimization
|
|
32
|
+
Classifier: Development Status :: 3 - Alpha
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
42
|
+
Classifier: Topic :: System :: Hardware
|
|
43
|
+
Classifier: Topic :: Scientific/Engineering
|
|
44
|
+
Classifier: Typing :: Typed
|
|
45
|
+
Requires-Python: >=3.10
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
License-File: LICENSE
|
|
48
|
+
Requires-Dist: psutil>=5.9
|
|
49
|
+
Provides-Extra: cuda
|
|
50
|
+
Requires-Dist: cupy-cuda12x>=13.0; extra == "cuda"
|
|
51
|
+
Provides-Extra: opencl
|
|
52
|
+
Requires-Dist: pyopencl>=2024.1; extra == "opencl"
|
|
53
|
+
Provides-Extra: intel
|
|
54
|
+
Requires-Dist: dpctl>=0.16; extra == "intel"
|
|
55
|
+
Requires-Dist: dpnp>=0.14; extra == "intel"
|
|
56
|
+
Provides-Extra: all-gpu
|
|
57
|
+
Requires-Dist: cupy-cuda12x>=13.0; extra == "all-gpu"
|
|
58
|
+
Requires-Dist: pyopencl>=2024.1; extra == "all-gpu"
|
|
59
|
+
Provides-Extra: numpy
|
|
60
|
+
Requires-Dist: numpy>=1.26; extra == "numpy"
|
|
61
|
+
Provides-Extra: dev
|
|
62
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
63
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
64
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
65
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
66
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
67
|
+
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
68
|
+
Provides-Extra: docs
|
|
69
|
+
Requires-Dist: mkdocs>=1.6; extra == "docs"
|
|
70
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
71
|
+
Requires-Dist: mkdocstrings[python]>=0.25; extra == "docs"
|
|
72
|
+
Dynamic: license-file
|
|
73
|
+
|
|
74
|
+
# PyAccelerate
|
|
75
|
+
|
|
76
|
+
**High-performance Python acceleration engine** — CPU, threads, virtual threads, multi-GPU and virtualization.
|
|
77
|
+
|
|
78
|
+
[](https://github.com/GuilhermeP96/pyaccelerate/actions)
|
|
79
|
+
[](https://www.python.org/)
|
|
80
|
+
[](LICENSE)
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
| Module | Description |
|
|
87
|
+
|---|---|
|
|
88
|
+
| **`cpu`** | CPU detection, topology, NUMA, affinity, ISA flags, dynamic worker recommendations |
|
|
89
|
+
| **`threads`** | Persistent virtual-thread pool, sliding-window executor, async bridge, process pool |
|
|
90
|
+
| **`gpu`** | Multi-vendor GPU detection (NVIDIA/CUDA, AMD/OpenCL, Intel oneAPI), ranking, multi-GPU dispatch |
|
|
91
|
+
| **`virt`** | Virtualization detection (Hyper-V, VT-x/AMD-V, KVM, WSL2, Docker, container detection) |
|
|
92
|
+
| **`memory`** | Memory pressure monitoring, automatic worker clamping, reusable buffer pool |
|
|
93
|
+
| **`profiler`** | `@timed`, `@profile_memory` decorators, `Timer` context manager, `Tracker` statistics |
|
|
94
|
+
| **`benchmark`** | Built-in micro-benchmarks (CPU, threads, memory bandwidth, GPU compute) |
|
|
95
|
+
| **`engine`** | Unified orchestrator — auto-detects everything and provides a single API |
|
|
96
|
+
|
|
97
|
+
## Quick Start
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pip install pyaccelerate
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from pyaccelerate import Engine
|
|
105
|
+
|
|
106
|
+
engine = Engine()
|
|
107
|
+
print(engine.summary())
|
|
108
|
+
|
|
109
|
+
# Submit I/O-bound tasks to the virtual thread pool
|
|
110
|
+
future = engine.submit(my_io_func, arg1, arg2)
|
|
111
|
+
|
|
112
|
+
# Run many tasks with auto-tuned concurrency
|
|
113
|
+
engine.run_parallel(process_file, [(f,) for f in files])
|
|
114
|
+
|
|
115
|
+
# GPU dispatch (auto-fallback to CPU)
|
|
116
|
+
results = engine.gpu_dispatch(my_kernel, data_chunks)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## CLI
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pyaccelerate info # Full hardware report
|
|
123
|
+
pyaccelerate benchmark # Run micro-benchmarks
|
|
124
|
+
pyaccelerate gpu # GPU details
|
|
125
|
+
pyaccelerate cpu # CPU details
|
|
126
|
+
pyaccelerate virt # Virtualization info
|
|
127
|
+
pyaccelerate memory # Memory stats
|
|
128
|
+
pyaccelerate status # One-liner
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Modules in Depth
|
|
132
|
+
|
|
133
|
+
### Virtual Thread Pool
|
|
134
|
+
|
|
135
|
+
Inspired by Java's virtual threads — a persistent `ThreadPoolExecutor` sized for I/O (`cores × 3`, cap 32). All I/O-bound work shares this pool instead of creating/destroying threads per operation.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from pyaccelerate.threads import get_pool, run_parallel, submit
|
|
139
|
+
|
|
140
|
+
# Single task
|
|
141
|
+
fut = submit(download_file, url)
|
|
142
|
+
|
|
143
|
+
# Bounded concurrency (sliding window)
|
|
144
|
+
run_parallel(process, [(item,) for item in items], max_concurrent=8)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Multi-GPU Dispatch
|
|
148
|
+
|
|
149
|
+
Auto-detects GPUs across CUDA, OpenCL and Intel oneAPI. Distributes workloads with configurable strategies.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from pyaccelerate.gpu import detect_all, dispatch
|
|
153
|
+
|
|
154
|
+
gpus = detect_all()
|
|
155
|
+
results = dispatch(my_kernel, data_chunks, strategy="score-weighted")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Profiling
|
|
159
|
+
|
|
160
|
+
Zero-config decorators for timing and memory tracking:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from pyaccelerate.profiler import timed, profile_memory, Tracker
|
|
164
|
+
|
|
165
|
+
@timed(level=logging.INFO)
|
|
166
|
+
def heavy_computation():
|
|
167
|
+
...
|
|
168
|
+
|
|
169
|
+
tracker = Tracker("db_queries")
|
|
170
|
+
for batch in batches:
|
|
171
|
+
with tracker.measure():
|
|
172
|
+
run_query(batch)
|
|
173
|
+
print(tracker.summary())
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Installation Options
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Core (CPU + threads + memory + virt)
|
|
180
|
+
pip install pyaccelerate
|
|
181
|
+
|
|
182
|
+
# With NVIDIA GPU support
|
|
183
|
+
pip install pyaccelerate[cuda]
|
|
184
|
+
|
|
185
|
+
# With OpenCL support (AMD/Intel/NVIDIA)
|
|
186
|
+
pip install pyaccelerate[opencl]
|
|
187
|
+
|
|
188
|
+
# With Intel oneAPI support
|
|
189
|
+
pip install pyaccelerate[intel]
|
|
190
|
+
|
|
191
|
+
# All GPU backends
|
|
192
|
+
pip install pyaccelerate[all-gpu]
|
|
193
|
+
|
|
194
|
+
# Development
|
|
195
|
+
pip install pyaccelerate[dev]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Docker
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# CPU-only
|
|
202
|
+
docker build -t pyaccelerate .
|
|
203
|
+
docker run --rm pyaccelerate info
|
|
204
|
+
|
|
205
|
+
# With NVIDIA GPU
|
|
206
|
+
docker build -f Dockerfile.gpu -t pyaccelerate:gpu .
|
|
207
|
+
docker run --rm --gpus all pyaccelerate:gpu info
|
|
208
|
+
|
|
209
|
+
# Docker Compose
|
|
210
|
+
docker compose up pyaccelerate # CPU
|
|
211
|
+
docker compose up gpu # GPU
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Development
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
git clone https://github.com/GuilhermeP96/pyaccelerate.git
|
|
218
|
+
cd pyaccelerate
|
|
219
|
+
pip install -e ".[dev]"
|
|
220
|
+
|
|
221
|
+
# Run tests
|
|
222
|
+
pytest -v
|
|
223
|
+
|
|
224
|
+
# Lint + format
|
|
225
|
+
ruff check src/ tests/
|
|
226
|
+
ruff format src/ tests/
|
|
227
|
+
|
|
228
|
+
# Type check
|
|
229
|
+
mypy src/
|
|
230
|
+
|
|
231
|
+
# Build wheel
|
|
232
|
+
python -m build
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Architecture
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
pyaccelerate/
|
|
239
|
+
├── cpu.py # CPU detection & topology
|
|
240
|
+
├── threads.py # Virtual thread pool & executors
|
|
241
|
+
├── gpu/
|
|
242
|
+
│ ├── detector.py # Multi-vendor GPU enumeration
|
|
243
|
+
│ ├── cuda.py # CUDA/CuPy helpers
|
|
244
|
+
│ ├── opencl.py # PyOpenCL helpers
|
|
245
|
+
│ ├── intel.py # Intel oneAPI helpers
|
|
246
|
+
│ └── dispatch.py # Multi-GPU load balancer
|
|
247
|
+
├── virt.py # Virtualization detection
|
|
248
|
+
├── memory.py # Memory monitoring & buffer pool
|
|
249
|
+
├── profiler.py # Timing & profiling utilities
|
|
250
|
+
├── benchmark.py # Built-in micro-benchmarks
|
|
251
|
+
├── engine.py # Unified orchestrator
|
|
252
|
+
└── cli.py # Command-line interface
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Roadmap
|
|
256
|
+
|
|
257
|
+
- [ ] npm package (Node.js bindings via pybind11/napi)
|
|
258
|
+
- [ ] gRPC server mode for multi-language integration
|
|
259
|
+
- [ ] Kubernetes operator for auto-scaling GPU workloads
|
|
260
|
+
- [ ] Prometheus metrics exporter
|
|
261
|
+
- [ ] Auto-tuning feedback loop (benchmark → config → re-tune)
|
|
262
|
+
|
|
263
|
+
## Origin
|
|
264
|
+
|
|
265
|
+
Evolved from the acceleration & virtual-thread systems built for:
|
|
266
|
+
- [adb-toolkit](https://github.com/GuilhermeP96/adb-toolkit) — multi-GPU acceleration, virtual thread pool
|
|
267
|
+
- [python-gpu-statistical-analysis](https://github.com/GuilhermeP96/python-gpu-statistical-analysis) — GPU compute foundations
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# PyAccelerate
|
|
2
|
+
|
|
3
|
+
**High-performance Python acceleration engine** — CPU, threads, virtual threads, multi-GPU and virtualization.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/GuilhermeP96/pyaccelerate/actions)
|
|
6
|
+
[](https://www.python.org/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
| Module | Description |
|
|
14
|
+
|---|---|
|
|
15
|
+
| **`cpu`** | CPU detection, topology, NUMA, affinity, ISA flags, dynamic worker recommendations |
|
|
16
|
+
| **`threads`** | Persistent virtual-thread pool, sliding-window executor, async bridge, process pool |
|
|
17
|
+
| **`gpu`** | Multi-vendor GPU detection (NVIDIA/CUDA, AMD/OpenCL, Intel oneAPI), ranking, multi-GPU dispatch |
|
|
18
|
+
| **`virt`** | Virtualization detection (Hyper-V, VT-x/AMD-V, KVM, WSL2, Docker, container detection) |
|
|
19
|
+
| **`memory`** | Memory pressure monitoring, automatic worker clamping, reusable buffer pool |
|
|
20
|
+
| **`profiler`** | `@timed`, `@profile_memory` decorators, `Timer` context manager, `Tracker` statistics |
|
|
21
|
+
| **`benchmark`** | Built-in micro-benchmarks (CPU, threads, memory bandwidth, GPU compute) |
|
|
22
|
+
| **`engine`** | Unified orchestrator — auto-detects everything and provides a single API |
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install pyaccelerate
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from pyaccelerate import Engine
|
|
32
|
+
|
|
33
|
+
engine = Engine()
|
|
34
|
+
print(engine.summary())
|
|
35
|
+
|
|
36
|
+
# Submit I/O-bound tasks to the virtual thread pool
|
|
37
|
+
future = engine.submit(my_io_func, arg1, arg2)
|
|
38
|
+
|
|
39
|
+
# Run many tasks with auto-tuned concurrency
|
|
40
|
+
engine.run_parallel(process_file, [(f,) for f in files])
|
|
41
|
+
|
|
42
|
+
# GPU dispatch (auto-fallback to CPU)
|
|
43
|
+
results = engine.gpu_dispatch(my_kernel, data_chunks)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## CLI
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pyaccelerate info # Full hardware report
|
|
50
|
+
pyaccelerate benchmark # Run micro-benchmarks
|
|
51
|
+
pyaccelerate gpu # GPU details
|
|
52
|
+
pyaccelerate cpu # CPU details
|
|
53
|
+
pyaccelerate virt # Virtualization info
|
|
54
|
+
pyaccelerate memory # Memory stats
|
|
55
|
+
pyaccelerate status # One-liner
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Modules in Depth
|
|
59
|
+
|
|
60
|
+
### Virtual Thread Pool
|
|
61
|
+
|
|
62
|
+
Inspired by Java's virtual threads — a persistent `ThreadPoolExecutor` sized for I/O (`cores × 3`, cap 32). All I/O-bound work shares this pool instead of creating/destroying threads per operation.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from pyaccelerate.threads import get_pool, run_parallel, submit
|
|
66
|
+
|
|
67
|
+
# Single task
|
|
68
|
+
fut = submit(download_file, url)
|
|
69
|
+
|
|
70
|
+
# Bounded concurrency (sliding window)
|
|
71
|
+
run_parallel(process, [(item,) for item in items], max_concurrent=8)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Multi-GPU Dispatch
|
|
75
|
+
|
|
76
|
+
Auto-detects GPUs across CUDA, OpenCL and Intel oneAPI. Distributes workloads with configurable strategies.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from pyaccelerate.gpu import detect_all, dispatch
|
|
80
|
+
|
|
81
|
+
gpus = detect_all()
|
|
82
|
+
results = dispatch(my_kernel, data_chunks, strategy="score-weighted")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Profiling
|
|
86
|
+
|
|
87
|
+
Zero-config decorators for timing and memory tracking:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from pyaccelerate.profiler import timed, profile_memory, Tracker
|
|
91
|
+
|
|
92
|
+
@timed(level=logging.INFO)
|
|
93
|
+
def heavy_computation():
|
|
94
|
+
...
|
|
95
|
+
|
|
96
|
+
tracker = Tracker("db_queries")
|
|
97
|
+
for batch in batches:
|
|
98
|
+
with tracker.measure():
|
|
99
|
+
run_query(batch)
|
|
100
|
+
print(tracker.summary())
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Installation Options
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Core (CPU + threads + memory + virt)
|
|
107
|
+
pip install pyaccelerate
|
|
108
|
+
|
|
109
|
+
# With NVIDIA GPU support
|
|
110
|
+
pip install pyaccelerate[cuda]
|
|
111
|
+
|
|
112
|
+
# With OpenCL support (AMD/Intel/NVIDIA)
|
|
113
|
+
pip install pyaccelerate[opencl]
|
|
114
|
+
|
|
115
|
+
# With Intel oneAPI support
|
|
116
|
+
pip install pyaccelerate[intel]
|
|
117
|
+
|
|
118
|
+
# All GPU backends
|
|
119
|
+
pip install pyaccelerate[all-gpu]
|
|
120
|
+
|
|
121
|
+
# Development
|
|
122
|
+
pip install pyaccelerate[dev]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Docker
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# CPU-only
|
|
129
|
+
docker build -t pyaccelerate .
|
|
130
|
+
docker run --rm pyaccelerate info
|
|
131
|
+
|
|
132
|
+
# With NVIDIA GPU
|
|
133
|
+
docker build -f Dockerfile.gpu -t pyaccelerate:gpu .
|
|
134
|
+
docker run --rm --gpus all pyaccelerate:gpu info
|
|
135
|
+
|
|
136
|
+
# Docker Compose
|
|
137
|
+
docker compose up pyaccelerate # CPU
|
|
138
|
+
docker compose up gpu # GPU
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
git clone https://github.com/GuilhermeP96/pyaccelerate.git
|
|
145
|
+
cd pyaccelerate
|
|
146
|
+
pip install -e ".[dev]"
|
|
147
|
+
|
|
148
|
+
# Run tests
|
|
149
|
+
pytest -v
|
|
150
|
+
|
|
151
|
+
# Lint + format
|
|
152
|
+
ruff check src/ tests/
|
|
153
|
+
ruff format src/ tests/
|
|
154
|
+
|
|
155
|
+
# Type check
|
|
156
|
+
mypy src/
|
|
157
|
+
|
|
158
|
+
# Build wheel
|
|
159
|
+
python -m build
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Architecture
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
pyaccelerate/
|
|
166
|
+
├── cpu.py # CPU detection & topology
|
|
167
|
+
├── threads.py # Virtual thread pool & executors
|
|
168
|
+
├── gpu/
|
|
169
|
+
│ ├── detector.py # Multi-vendor GPU enumeration
|
|
170
|
+
│ ├── cuda.py # CUDA/CuPy helpers
|
|
171
|
+
│ ├── opencl.py # PyOpenCL helpers
|
|
172
|
+
│ ├── intel.py # Intel oneAPI helpers
|
|
173
|
+
│ └── dispatch.py # Multi-GPU load balancer
|
|
174
|
+
├── virt.py # Virtualization detection
|
|
175
|
+
├── memory.py # Memory monitoring & buffer pool
|
|
176
|
+
├── profiler.py # Timing & profiling utilities
|
|
177
|
+
├── benchmark.py # Built-in micro-benchmarks
|
|
178
|
+
├── engine.py # Unified orchestrator
|
|
179
|
+
└── cli.py # Command-line interface
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Roadmap
|
|
183
|
+
|
|
184
|
+
- [ ] npm package (Node.js bindings via pybind11/napi)
|
|
185
|
+
- [ ] gRPC server mode for multi-language integration
|
|
186
|
+
- [ ] Kubernetes operator for auto-scaling GPU workloads
|
|
187
|
+
- [ ] Prometheus metrics exporter
|
|
188
|
+
- [ ] Auto-tuning feedback loop (benchmark → config → re-tune)
|
|
189
|
+
|
|
190
|
+
## Origin
|
|
191
|
+
|
|
192
|
+
Evolved from the acceleration & virtual-thread systems built for:
|
|
193
|
+
- [adb-toolkit](https://github.com/GuilhermeP96/adb-toolkit) — multi-GPU acceleration, virtual thread pool
|
|
194
|
+
- [python-gpu-statistical-analysis](https://github.com/GuilhermeP96/python-gpu-statistical-analysis) — GPU compute foundations
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pyaccelerate"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "High-performance Python acceleration engine — CPU, threads, virtual threads, multi-GPU and virtualization."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {file = "LICENSE"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Guilherme Pinheiro", email = "guilherme@example.com"},
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Topic :: Software Development :: Libraries",
|
|
26
|
+
"Topic :: System :: Hardware",
|
|
27
|
+
"Topic :: Scientific/Engineering",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
keywords = ["acceleration", "gpu", "cuda", "opencl", "threads", "performance", "optimization"]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"psutil>=5.9",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
cuda = ["cupy-cuda12x>=13.0"]
|
|
37
|
+
opencl = ["pyopencl>=2024.1"]
|
|
38
|
+
intel = ["dpctl>=0.16", "dpnp>=0.14"]
|
|
39
|
+
all-gpu = ["cupy-cuda12x>=13.0", "pyopencl>=2024.1"]
|
|
40
|
+
numpy = ["numpy>=1.26"]
|
|
41
|
+
dev = [
|
|
42
|
+
"pytest>=8.0",
|
|
43
|
+
"pytest-cov>=5.0",
|
|
44
|
+
"pytest-asyncio>=0.23",
|
|
45
|
+
"mypy>=1.10",
|
|
46
|
+
"ruff>=0.4",
|
|
47
|
+
"pre-commit>=3.7",
|
|
48
|
+
]
|
|
49
|
+
docs = [
|
|
50
|
+
"mkdocs>=1.6",
|
|
51
|
+
"mkdocs-material>=9.5",
|
|
52
|
+
"mkdocstrings[python]>=0.25",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[project.urls]
|
|
56
|
+
Homepage = "https://github.com/GuilhermeP96/pyaccelerate"
|
|
57
|
+
Repository = "https://github.com/GuilhermeP96/pyaccelerate"
|
|
58
|
+
Issues = "https://github.com/GuilhermeP96/pyaccelerate/issues"
|
|
59
|
+
|
|
60
|
+
[project.scripts]
|
|
61
|
+
pyaccelerate = "pyaccelerate.cli:main"
|
|
62
|
+
|
|
63
|
+
[tool.setuptools.dynamic]
|
|
64
|
+
version = {file = "VERSION"}
|
|
65
|
+
|
|
66
|
+
[tool.setuptools.packages.find]
|
|
67
|
+
where = ["src"]
|
|
68
|
+
|
|
69
|
+
[tool.setuptools.package-data]
|
|
70
|
+
pyaccelerate = ["py.typed"]
|
|
71
|
+
|
|
72
|
+
# ── Ruff ──────────────────────────────────────────────────────────────────
|
|
73
|
+
[tool.ruff]
|
|
74
|
+
target-version = "py310"
|
|
75
|
+
line-length = 99
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint]
|
|
78
|
+
select = ["E", "F", "W", "I", "N", "UP", "B", "SIM", "RUF"]
|
|
79
|
+
ignore = ["E501"]
|
|
80
|
+
|
|
81
|
+
[tool.ruff.lint.isort]
|
|
82
|
+
known-first-party = ["pyaccelerate"]
|
|
83
|
+
|
|
84
|
+
# ── Pytest ────────────────────────────────────────────────────────────────
|
|
85
|
+
[tool.pytest.ini_options]
|
|
86
|
+
testpaths = ["tests"]
|
|
87
|
+
addopts = "-v --tb=short --strict-markers"
|
|
88
|
+
markers = [
|
|
89
|
+
"gpu: requires GPU compute backend",
|
|
90
|
+
"slow: long-running benchmark tests",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
# ── Mypy ──────────────────────────────────────────────────────────────────
|
|
94
|
+
[tool.mypy]
|
|
95
|
+
python_version = "3.10"
|
|
96
|
+
strict = true
|
|
97
|
+
warn_return_any = true
|
|
98
|
+
warn_unused_configs = true
|
|
99
|
+
disallow_untyped_defs = true
|
|
100
|
+
|
|
101
|
+
[[tool.mypy.overrides]]
|
|
102
|
+
module = ["cupy.*", "pyopencl.*", "dpctl.*", "dpnp.*", "psutil.*"]
|
|
103
|
+
ignore_missing_imports = true
|
|
104
|
+
|
|
105
|
+
# ── Coverage ──────────────────────────────────────────────────────────────
|
|
106
|
+
[tool.coverage.run]
|
|
107
|
+
source = ["src/pyaccelerate"]
|
|
108
|
+
omit = ["tests/*"]
|
|
109
|
+
|
|
110
|
+
[tool.coverage.report]
|
|
111
|
+
show_missing = true
|
|
112
|
+
skip_empty = true
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PyAccelerate — High-performance Python acceleration engine.
|
|
3
|
+
|
|
4
|
+
Modules
|
|
5
|
+
-------
|
|
6
|
+
- **cpu** : CPU detection, core count, frequency, affinity, NUMA topology
|
|
7
|
+
- **threads** : Virtual thread pool, sliding-window executor, async bridge
|
|
8
|
+
- **gpu** : Multi-vendor GPU detection, ranking, dispatch (CUDA/OpenCL/Intel)
|
|
9
|
+
- **virt** : Virtualization detection (Hyper-V, VT-x/AMD-V, WSL2, Docker)
|
|
10
|
+
- **memory** : Memory monitoring, pressure detection, pool allocator
|
|
11
|
+
- **profiler** : Decorator-based profiling & timing utilities
|
|
12
|
+
- **benchmark** : Built-in micro-benchmarks for the current host
|
|
13
|
+
- **engine** : Unified orchestrator that auto-tunes all subsystems
|
|
14
|
+
|
|
15
|
+
Quick start::
|
|
16
|
+
|
|
17
|
+
from pyaccelerate import Engine
|
|
18
|
+
|
|
19
|
+
engine = Engine() # auto-detects hardware
|
|
20
|
+
print(engine.summary()) # human-readable report
|
|
21
|
+
|
|
22
|
+
# Use the shared virtual-thread pool
|
|
23
|
+
from pyaccelerate.threads import get_pool, run_parallel
|
|
24
|
+
|
|
25
|
+
pool = get_pool()
|
|
26
|
+
fut = pool.submit(my_io_func, arg1, arg2)
|
|
27
|
+
|
|
28
|
+
# GPU compute
|
|
29
|
+
from pyaccelerate.gpu import detect_all, best_gpu, dispatch
|
|
30
|
+
|
|
31
|
+
gpus = detect_all()
|
|
32
|
+
result = dispatch(my_kernel, data, gpus=gpus)
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from importlib.metadata import PackageNotFoundError, version as _version
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
__version__: str = _version("pyaccelerate")
|
|
39
|
+
except PackageNotFoundError:
|
|
40
|
+
# Running from source / not installed
|
|
41
|
+
from pathlib import Path as _Path
|
|
42
|
+
|
|
43
|
+
_vf = _Path(__file__).resolve().parent.parent.parent / "VERSION"
|
|
44
|
+
__version__ = _vf.read_text().strip() if _vf.exists() else "0.0.0-dev"
|
|
45
|
+
|
|
46
|
+
# Convenience re-exports
|
|
47
|
+
from pyaccelerate.engine import Engine # noqa: E402, F401
|
|
48
|
+
|
|
49
|
+
__all__ = [
|
|
50
|
+
"__version__",
|
|
51
|
+
"Engine",
|
|
52
|
+
]
|