cquda-continuumq 0.1.0__py3-none-any.whl

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.
cquda/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ import sys
2
+ import tinykern
3
+ sys.modules[__name__] = tinykern
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: cquda-continuumq
3
+ Version: 0.1.0
4
+ Summary: Write CUDA-style kernels in Python: trace to an IR, run on NumPy (CPU SIMT emulation) or NVIDIA GPUs (PTX).
5
+ Author: Aliyev Islom/ContinuumQ
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://continuumq-aether.vercel.app/
8
+ Keywords: gpu,cuda,kernel,simt,ptx,numpy,compiler
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Software Development :: Compilers
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.21
26
+ Provides-Extra: test
27
+ Requires-Dist: pytest; extra == "test"
28
+ Dynamic: license-file
29
+
30
+ # cquda-continuumq (tinykern)
31
+
32
+ Write CUDA-style kernels in Python. A kernel is written once as a Python function, traced into a small
33
+ IR, optimised, and executed by one of two backends:
34
+
35
+ | backend | what it does | needs |
36
+ |---------|-----------------------------------------------------------------------------|----------------------|
37
+ | CPU | the IR is compiled to NumPy source and run as lockstep SIMT on NumPy vectors | nothing but NumPy |
38
+ | GPU | PTX for NVIDIA GPUs through the CUDA driver API (**experimental**) | an NVIDIA driver |
39
+
40
+ The CPU backend is used whenever you pass NumPy arrays; the GPU backend is used when you pass `DeviceArray`s.
41
+
42
+ ```python
43
+ import numpy as np
44
+ from tinykern import kernel, Ptr, F32, I32, let, gid_x, load, store, cdiv
45
+
46
+ @kernel
47
+ def saxpy(x: Ptr, y: Ptr, out: Ptr, a: F32, n: I32):
48
+ i = let(gid_x())
49
+ store(out, i, a * load(x, i) + load(y, i), mask=i < n)
50
+
51
+ x = np.arange(10, dtype=np.float32)
52
+ out = np.zeros(10, np.float32)
53
+ saxpy(cdiv(10, 256), 256, x, x, out, 2.0, 10) # grid, block, then the arguments
54
+ assert np.allclose(out, 3 * x)
55
+ ```
56
+
57
+ ## Install
58
+
59
+ ```
60
+ pip install cquda-continuumq
61
+ ```
62
+
63
+ The distribution name is `cquda-continuumq`; you import it as `tinykern` or, equivalently, `cquda`.
64
+ Python 3.9+ and NumPy are required. No compiler and no GPU are needed.
65
+
66
+ ## The kernel language
67
+
68
+ - Kernel arguments are annotated `Ptr` / `CPtr` (1-D contiguous `float32` array; `CPtr` is read-only),
69
+ `IPtr` / `CIPtr` (`int32` array), `F32` or `I32` (scalars).
70
+ - Thread and block indices: `tid_x/y/z`, `bid_x/y/z`, `bdim_x/y/z`, `gdim_x/y/z`, `gid_x/y/z`,
71
+ `tid_linear`, `lane_id`, `warp_id`. Grids and blocks may be an int or a tuple of up to three ints.
72
+ - Values: `let(expr)` / `var(init)` (mutable, use `v += x` or `v.set(x)`), `shared(n, dtype)` per-block
73
+ scratch memory.
74
+ - Memory: `load(ptr, idx, mask=..., other=...)`, `store(ptr, idx, value, mask=...)`, `load4` / `store4`
75
+ (float4), `atomic_add`, `atomic_max`, `atomic_min` (max/min on `int32`). `ptr[i]` and `ptr[i] = v` also work.
76
+ - Control flow: `with if_(cond):`, `with while_(cond):`, `for i in loop(a, b, step):` (runtime loops).
77
+ Plain Python `for`/`while` loops are unrolled at trace time. `barrier()` is `__syncthreads()`.
78
+ - Math: `+ - * / // % **`, comparisons, `& | ^ << >> ~`, `minimum`, `maximum`, `clamp`, `select`, `sqrt`,
79
+ `rsqrt`, `exp`, `exp2`, `log`, `log2`, `sin`, `cos`, `floor`, `ceil`, `trunc`, `rint`, `rcp`, `fabs`, `fma`,
80
+ `tanh`, `sigmoid`, `relu`, `gelu`, `i2f`, `f2i`.
81
+ - Warps: `shfl_xor/down/up/idx`, `warp_reduce`, `block_reduce`.
82
+
83
+ Python's `if`, `and`, `or` cannot be used on kernel values; use `with if_(...)` and `&` / `|` with
84
+ parenthesised comparisons. Kernel values are lazy expressions: use `let(...)` to snapshot a value that a
85
+ `var` will change later.
86
+
87
+ Inspect what is generated: `saxpy.dump()` (optimised IR), `saxpy.np_source()` (the NumPy code),
88
+ `saxpy.ptx()` (PTX text), `saxpy.stats()`.
89
+
90
+ ## Ready-made kernels
91
+
92
+ ```python
93
+ import tinykern as tk
94
+ tk.gemm(A, B, M, N, K) # row-major matrices, any size
95
+ tk.softmax(x, rows, cols) # row-wise
96
+ tk.layernorm(x, gamma, beta, rows, cols)
97
+ tk.transpose(a, rows, cols)
98
+ tk.reduce_sum(x); tk.reduce_max(x); tk.reduce_min(x)
99
+ tk.inclusive_scan(x); tk.histogram(ints, nbins)
100
+ tk.elementwise(lambda a, b: tk.relu(a * 2.0 - b), nin=2)(a, b) # fuse your own math into one kernel
101
+ ```
102
+
103
+ They are written in the kernel language itself, so they double as examples. Float32 summation order differs
104
+ from NumPy's, so expect agreement to about 1e-4, not bit-for-bit. `tk.autotune(kernel, [(grid, block), ...], *args)`
105
+ times launch configurations and returns the fastest.
106
+
107
+ ## Command line
108
+
109
+ ```
110
+ python -m tinykern info # version and what hardware is available
111
+ python -m tinykern demo # run and verify the library kernels (add --ptx DIR to write PTX files)
112
+ python -m tinykern fuzz -n 25 # random kernels, compared with an independent NumPy evaluation
113
+ ```
114
+
115
+ ## Limitations
116
+
117
+ - The CPU backend emulates GPU threads with NumPy vectors. It is a correctness tool and a way to develop
118
+ kernels without a GPU, not a fast CPU compute engine.
119
+ - The GPU backend is experimental and untested in CI.
120
+ - Defining kernels from several threads at the same time is not supported (tracing uses global state).
121
+ - Arrays must be 1-D, contiguous `float32` (`int32` for `IPtr`). Blocks have at most 1024 threads and static
122
+ shared memory is limited to 48 KB per block. `histogram` supports up to 1024 bins.
123
+
124
+ ## Trademarks and license
125
+
126
+ "CUDA" is a trademark of NVIDIA Corporation. This project is independent and is not affiliated with or
127
+ endorsed by NVIDIA. Released under the MIT License (see `LICENSE`).
@@ -0,0 +1,10 @@
1
+ cquda/__init__.py,sha256=MRkQ5nBmD-oSOu4RfN7-u_QxVM-u_3SOXqf8KSTgKj4,60
2
+ cquda_continuumq-0.1.0.dist-info/licenses/LICENSE,sha256=9wcf-vHuevwAA2sI8AJgp7oCDOYwBYyqjZR6N-dEsp0,1085
3
+ tinykern/__init__.py,sha256=6Te5WdOCvgabRREu8Q92PeC5z5ffBWrG170azU1y7vk,96545
4
+ tinykern/__main__.py,sha256=nAh8pnlVZk8NXZR6abN61xjtsNOndOZqE10cjE4xJ4E,2400
5
+ tinykern/fuzz.py,sha256=pH8qBGf_em7ssyYchyRhlY0s8rsjPyoWnNv3zrqo5yE,9556
6
+ cquda_continuumq-0.1.0.dist-info/METADATA,sha256=J3mfjj39ZYw8kdEfdnaSONGUBxYN8U9nTqKlPeLXJ9s,6091
7
+ cquda_continuumq-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ cquda_continuumq-0.1.0.dist-info/entry_points.txt,sha256=pNl96ET6bx_loReFTz8sr_qky8kpDInlgFu_ZRwPwKE,83
9
+ cquda_continuumq-0.1.0.dist-info/top_level.txt,sha256=-DEggPY899_7cZyWnctI6fFxWNpkfwZSSoi7TSuDBEo,15
10
+ cquda_continuumq-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ cquda = tinykern.__main__:main
3
+ tinykern = tinykern.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CQUDA ContinuumQ contributors
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,2 @@
1
+ cquda
2
+ tinykern