pixtreme-infer 0.14.4__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.
- pixtreme_infer-0.14.4/.gitignore +167 -0
- pixtreme_infer-0.14.4/LICENSE +21 -0
- pixtreme_infer-0.14.4/PKG-INFO +189 -0
- pixtreme_infer-0.14.4/README.md +163 -0
- pixtreme_infer-0.14.4/pyproject.toml +123 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/__init__.py +90 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/_contracts.py +526 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/_cuda_graph.py +264 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/_dependencies.py +30 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/_errors.py +8 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/_onnx_runtime.py +182 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/_recipe_identity.py +96 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/contracts.py +49 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/cuda_graph.py +5 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/dependencies.py +7 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/errors.py +7 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/py.typed +1 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/recipe_identity.py +21 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/verification/__init__.py +18 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/verification/comparison.py +142 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/verification/contracts.py +883 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/verification/distribution.py +492 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/verification/measurement.py +392 -0
- pixtreme_infer-0.14.4/src/pixtreme/infer/verification/records.py +265 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
.coveragerc
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
#Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# poetry
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
103
|
+
#poetry.lock
|
|
104
|
+
|
|
105
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
106
|
+
__pypackages__/
|
|
107
|
+
|
|
108
|
+
# Celery stuff
|
|
109
|
+
celerybeat-schedule
|
|
110
|
+
celerybeat.pid
|
|
111
|
+
|
|
112
|
+
# SageMath parsed files
|
|
113
|
+
*.sage.py
|
|
114
|
+
|
|
115
|
+
# Environments
|
|
116
|
+
.env
|
|
117
|
+
.venv
|
|
118
|
+
env/
|
|
119
|
+
venv/
|
|
120
|
+
ENV/
|
|
121
|
+
env.bak/
|
|
122
|
+
venv.bak/
|
|
123
|
+
|
|
124
|
+
# Spyder project settings
|
|
125
|
+
.spyderproject
|
|
126
|
+
.spyproject
|
|
127
|
+
|
|
128
|
+
# Rope project settings
|
|
129
|
+
.ropeproject
|
|
130
|
+
|
|
131
|
+
# mkdocs documentation
|
|
132
|
+
/site
|
|
133
|
+
|
|
134
|
+
# mypy
|
|
135
|
+
.mypy_cache/
|
|
136
|
+
.dmypy.json
|
|
137
|
+
dmypy.json
|
|
138
|
+
|
|
139
|
+
# Pyre type checker
|
|
140
|
+
.pyre/
|
|
141
|
+
|
|
142
|
+
# pytype static type analyzer
|
|
143
|
+
.pytype/
|
|
144
|
+
|
|
145
|
+
# Cython debug symbols
|
|
146
|
+
cython_debug/
|
|
147
|
+
|
|
148
|
+
# PyCharm
|
|
149
|
+
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
|
|
150
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
151
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
152
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
153
|
+
#.idea/
|
|
154
|
+
|
|
155
|
+
# Development
|
|
156
|
+
.ruff_cache/
|
|
157
|
+
.serena/
|
|
158
|
+
.claude/
|
|
159
|
+
.kiro/
|
|
160
|
+
cache/
|
|
161
|
+
examples/
|
|
162
|
+
models/
|
|
163
|
+
sandbox/
|
|
164
|
+
.vscode
|
|
165
|
+
.clinerules
|
|
166
|
+
|
|
167
|
+
.python-version
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 minamik
|
|
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,189 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pixtreme-infer
|
|
3
|
+
Version: 0.14.4
|
|
4
|
+
Summary: Inference companion for pixtreme: architecture-independent inference contracts and verification
|
|
5
|
+
Project-URL: repository, https://github.com/sync-dev-org/pixtreme-infer
|
|
6
|
+
Project-URL: issues, https://github.com/sync-dev-org/pixtreme-infer/issues
|
|
7
|
+
Author-email: minamik <mia@sync.dev>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA :: 13
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: pixtreme>=1.3.0
|
|
21
|
+
Provides-Extra: ort
|
|
22
|
+
Requires-Dist: onnxruntime-gpu>=1.20; extra == 'ort'
|
|
23
|
+
Provides-Extra: verify
|
|
24
|
+
Requires-Dist: nvidia-ml-py; extra == 'verify'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# pixtreme.infer
|
|
28
|
+
|
|
29
|
+
This repository owns the pure-Python distribution `pixtreme-infer` and its import package
|
|
30
|
+
`pixtreme.infer`. It provides the architecture-independent Frame boundary, shared inference
|
|
31
|
+
contracts, ONNX verification, recipe identity, and static dispatch used by architecture
|
|
32
|
+
distributions.
|
|
33
|
+
|
|
34
|
+
The wheel owns only the `pixtreme/infer/` subtree. The namespace root
|
|
35
|
+
`pixtreme/__init__.py` remains owned by
|
|
36
|
+
[pixtreme](https://github.com/sync-dev-org/pixtreme). Architecture implementations are
|
|
37
|
+
maintained and distributed separately as architecture distributions.
|
|
38
|
+
|
|
39
|
+
## Capabilities
|
|
40
|
+
|
|
41
|
+
The base dependency is `pixtreme>=1.3.0`. Optional capabilities are separated by extra:
|
|
42
|
+
|
|
43
|
+
- `ort`: ONNX Runtime verification.
|
|
44
|
+
- `verify`: device telemetry for the shared verification tools.
|
|
45
|
+
|
|
46
|
+
The core does not depend on TensorRT or torch. Architecture distributions build and run
|
|
47
|
+
TensorRT engines through tensoracle and declare TensorRT and tensoracle as their own
|
|
48
|
+
dependencies.
|
|
49
|
+
|
|
50
|
+
Core-only installation exposes the shared contracts and gives an actionable error when a
|
|
51
|
+
known architecture distribution is absent. The core does not eagerly import architecture
|
|
52
|
+
implementations.
|
|
53
|
+
|
|
54
|
+
## Development
|
|
55
|
+
|
|
56
|
+
Run development commands from the repository root:
|
|
57
|
+
|
|
58
|
+
```console
|
|
59
|
+
uv sync --all-extras
|
|
60
|
+
uv lock --check
|
|
61
|
+
CUDA_VISIBLE_DEVICES='' uv run --no-sync python -m pytest -q
|
|
62
|
+
uv run --no-sync mypy
|
|
63
|
+
uv run --no-sync ruff check src tests
|
|
64
|
+
uv run --no-sync ruff format --check src tests
|
|
65
|
+
uv build --wheel
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The normal test suite does not require a GPU. Tests that require unavailable optional
|
|
69
|
+
dependencies skip with a reason.
|
|
70
|
+
|
|
71
|
+
## Version and release
|
|
72
|
+
|
|
73
|
+
Versions come from tags named `vX.Y.Z`. Each version is published to PyPI as
|
|
74
|
+
`pixtreme-infer`; there is no corresponding GitHub Release or Release asset.
|
|
75
|
+
|
|
76
|
+
## CUDA Graph components for module authors
|
|
77
|
+
|
|
78
|
+
`pixtreme.infer.cuda_graph` exports `CudaGraphSession` and `CudaGraphBuffers`.
|
|
79
|
+
The core captures backend operations that enqueue work using fixed GPU storage.
|
|
80
|
+
A module still validates every request, selects an operation, handles its temporal
|
|
81
|
+
history and reset, and builds output metadata on every call. The core does not
|
|
82
|
+
capture the module's public Frame call or import an inference backend.
|
|
83
|
+
|
|
84
|
+
A module can implement the optional
|
|
85
|
+
`CudaGraphFactoryProvider[StatelessInferenceFactory[ArtifactIdentity]]` or
|
|
86
|
+
`CudaGraphFactoryProvider[TemporalInferenceFactory[ArtifactIdentity]]` protocol
|
|
87
|
+
from `pixtreme.infer.contracts`. Its `graph_factory()` returns a separate factory
|
|
88
|
+
with the original inference form. Factory selection and `query_contract` allocate
|
|
89
|
+
no GPU memory. `open` repeats configuration validation and prepares all graphs
|
|
90
|
+
before returning an instance whose contract equals the query result. The normal
|
|
91
|
+
factory keeps its existing operations and accepted settings; there is no new
|
|
92
|
+
required setting on existing factories.
|
|
93
|
+
|
|
94
|
+
Open a graph instance inside its device and an explicit non-default CUDA stream.
|
|
95
|
+
One instance handles one fixed input configuration on that device and stream,
|
|
96
|
+
with sequential host calls. Modules can prepare several named operations, with
|
|
97
|
+
shared fixed storage and separate backend execution units where their backend
|
|
98
|
+
requires them. The following fragment shows the integration inside a module;
|
|
99
|
+
the backend callables, fixed Frames, GPU parameters, history, and execution units
|
|
100
|
+
are prepared and owned by that module:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from pixtreme.infer.cuda_graph import CudaGraphBuffers, CudaGraphSession
|
|
104
|
+
|
|
105
|
+
buffers = CudaGraphBuffers(
|
|
106
|
+
fixed_input_frame, fixed_output_frame, params=fixed_gpu_params,
|
|
107
|
+
)
|
|
108
|
+
graphs = CudaGraphSession(
|
|
109
|
+
{"route-a": enqueue_a, "route-b": enqueue_b},
|
|
110
|
+
resources=(buffers, *history, *execution_units),
|
|
111
|
+
after_prepare=restore_initial_history_and_controls,
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Each callable must enqueue on the current stream, use only fixed GPU addresses,
|
|
116
|
+
and be safe for CUDA stream capture. Preparation calls each callable once for
|
|
117
|
+
warm-up, waits for that stream, and captures it once. Keep every buffer and
|
|
118
|
+
backend workspace used inside capture alive for the whole session, using the
|
|
119
|
+
callable's owners or `resources`. Allocating an unretained temporary inside
|
|
120
|
+
capture is invalid. Preparation can write history; `after_prepare` restores both
|
|
121
|
+
GPU history and host controls to their open state without consuming requests.
|
|
122
|
+
If any operation or this callback fails, preparation releases all captured graphs
|
|
123
|
+
and retained references and propagates the error. The module's `open` must also
|
|
124
|
+
release its own partially prepared resources. No partial instance or automatic
|
|
125
|
+
normal-path fallback is returned.
|
|
126
|
+
|
|
127
|
+
For each request, the module first checks its Frame metadata, reset control, and
|
|
128
|
+
parameter contract. It calls `graphs.check_context()` **before** copying inputs
|
|
129
|
+
or resetting history. Then it can perform these steps:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
# Module request validation and graph selection have already completed.
|
|
133
|
+
graphs.check_context()
|
|
134
|
+
buffers.copy_inputs(frame, **gpu_params)
|
|
135
|
+
if reset:
|
|
136
|
+
reset_history_on_current_stream()
|
|
137
|
+
graphs.replay(selected_name)
|
|
138
|
+
result = buffers.copy_output(
|
|
139
|
+
channels=output_channels,
|
|
140
|
+
colorspace=output_colorspace,
|
|
141
|
+
gamma=output_gamma,
|
|
142
|
+
matrix=output_matrix,
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`copy_inputs` validates every source before the first copy and requires exact
|
|
147
|
+
shape, dtype, device, and auxiliary names. It imports Frame storage through
|
|
148
|
+
DLPack and accepts CUDA auxiliary arrays, including CAI v3 and CUDA DLPack
|
|
149
|
+
producers. Sources must already be ready on the current stream and remain alive
|
|
150
|
+
until its copies complete. Copying performs no casting, broadcasting, or host
|
|
151
|
+
transfer, and the graph retains no caller input address. Modules validate reset
|
|
152
|
+
before calling this method, so a structurally rejected request does not clear
|
|
153
|
+
history or modify fixed storage. Auxiliary inputs are distinct from module-owned
|
|
154
|
+
temporal history; reset and graph selection remain module responsibilities.
|
|
155
|
+
|
|
156
|
+
`copy_output` allocates independent GPU storage outside capture and uses the
|
|
157
|
+
metadata supplied for that request. Returned Frames remain unchanged by later
|
|
158
|
+
replays, resets, and close. Requests enqueue without a host wait. Callers use
|
|
159
|
+
CUDA events for another stream to consume results, and finish outstanding work
|
|
160
|
+
before the module closes `graphs`, `buffers`, and its backend resources. Both
|
|
161
|
+
component `close()` methods are idempotent and perform no synchronization; later
|
|
162
|
+
operations on closed components fail before GPU work. Changing settings, device,
|
|
163
|
+
or stream requires opening another instance; there is no automatic recapture or
|
|
164
|
+
graph cache.
|
|
165
|
+
|
|
166
|
+
For common verification, supply `CudaGraphContractSuite(module, replay_equivalence)`
|
|
167
|
+
to `verify_cuda_graph_contract` in `pixtreme.infer.verification`. `module` is the
|
|
168
|
+
existing `StatelessContractSuite` or `TemporalContractSuite`, populated from the
|
|
169
|
+
graph factory and its instances. This runs `FactoryContractCases` unchanged and,
|
|
170
|
+
for temporal modules, the existing reset, startup, instance isolation, and
|
|
171
|
+
persistent state footprint checks. `replay_equivalence` supplies `SequenceFacts`
|
|
172
|
+
from separate normal and graph instances with the same settings, including the
|
|
173
|
+
first call, continuation, changed input values and metadata, and resets. Missing
|
|
174
|
+
evidence stays unverified. Modules retain ownership of their fixtures, correctness
|
|
175
|
+
thresholds, support declarations, and evidence. Performance measurements do not
|
|
176
|
+
determine support status.
|
|
177
|
+
|
|
178
|
+
The opt-in synthetic GPU tests use no TensorRT or tensoracle. Run correctness with
|
|
179
|
+
`uv run --no-sync python -m pytest -m 'gpu and not performance' tests/test_cuda_graph_gpu.py`,
|
|
180
|
+
selecting the GPU with `CUDA_VISIBLE_DEVICES` when the machine has several.
|
|
181
|
+
The `performance` cases record video-sized copy latency with CUDA events and print
|
|
182
|
+
median and p90 values; they apply no speed threshold.
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
The core distribution `pixtreme-infer` is licensed under the MIT License; see
|
|
187
|
+
[LICENSE](LICENSE). Architecture distributions are separate distributions, each with its own
|
|
188
|
+
license. The core license does not apply to them, and installing one does not change the core
|
|
189
|
+
license.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# pixtreme.infer
|
|
2
|
+
|
|
3
|
+
This repository owns the pure-Python distribution `pixtreme-infer` and its import package
|
|
4
|
+
`pixtreme.infer`. It provides the architecture-independent Frame boundary, shared inference
|
|
5
|
+
contracts, ONNX verification, recipe identity, and static dispatch used by architecture
|
|
6
|
+
distributions.
|
|
7
|
+
|
|
8
|
+
The wheel owns only the `pixtreme/infer/` subtree. The namespace root
|
|
9
|
+
`pixtreme/__init__.py` remains owned by
|
|
10
|
+
[pixtreme](https://github.com/sync-dev-org/pixtreme). Architecture implementations are
|
|
11
|
+
maintained and distributed separately as architecture distributions.
|
|
12
|
+
|
|
13
|
+
## Capabilities
|
|
14
|
+
|
|
15
|
+
The base dependency is `pixtreme>=1.3.0`. Optional capabilities are separated by extra:
|
|
16
|
+
|
|
17
|
+
- `ort`: ONNX Runtime verification.
|
|
18
|
+
- `verify`: device telemetry for the shared verification tools.
|
|
19
|
+
|
|
20
|
+
The core does not depend on TensorRT or torch. Architecture distributions build and run
|
|
21
|
+
TensorRT engines through tensoracle and declare TensorRT and tensoracle as their own
|
|
22
|
+
dependencies.
|
|
23
|
+
|
|
24
|
+
Core-only installation exposes the shared contracts and gives an actionable error when a
|
|
25
|
+
known architecture distribution is absent. The core does not eagerly import architecture
|
|
26
|
+
implementations.
|
|
27
|
+
|
|
28
|
+
## Development
|
|
29
|
+
|
|
30
|
+
Run development commands from the repository root:
|
|
31
|
+
|
|
32
|
+
```console
|
|
33
|
+
uv sync --all-extras
|
|
34
|
+
uv lock --check
|
|
35
|
+
CUDA_VISIBLE_DEVICES='' uv run --no-sync python -m pytest -q
|
|
36
|
+
uv run --no-sync mypy
|
|
37
|
+
uv run --no-sync ruff check src tests
|
|
38
|
+
uv run --no-sync ruff format --check src tests
|
|
39
|
+
uv build --wheel
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The normal test suite does not require a GPU. Tests that require unavailable optional
|
|
43
|
+
dependencies skip with a reason.
|
|
44
|
+
|
|
45
|
+
## Version and release
|
|
46
|
+
|
|
47
|
+
Versions come from tags named `vX.Y.Z`. Each version is published to PyPI as
|
|
48
|
+
`pixtreme-infer`; there is no corresponding GitHub Release or Release asset.
|
|
49
|
+
|
|
50
|
+
## CUDA Graph components for module authors
|
|
51
|
+
|
|
52
|
+
`pixtreme.infer.cuda_graph` exports `CudaGraphSession` and `CudaGraphBuffers`.
|
|
53
|
+
The core captures backend operations that enqueue work using fixed GPU storage.
|
|
54
|
+
A module still validates every request, selects an operation, handles its temporal
|
|
55
|
+
history and reset, and builds output metadata on every call. The core does not
|
|
56
|
+
capture the module's public Frame call or import an inference backend.
|
|
57
|
+
|
|
58
|
+
A module can implement the optional
|
|
59
|
+
`CudaGraphFactoryProvider[StatelessInferenceFactory[ArtifactIdentity]]` or
|
|
60
|
+
`CudaGraphFactoryProvider[TemporalInferenceFactory[ArtifactIdentity]]` protocol
|
|
61
|
+
from `pixtreme.infer.contracts`. Its `graph_factory()` returns a separate factory
|
|
62
|
+
with the original inference form. Factory selection and `query_contract` allocate
|
|
63
|
+
no GPU memory. `open` repeats configuration validation and prepares all graphs
|
|
64
|
+
before returning an instance whose contract equals the query result. The normal
|
|
65
|
+
factory keeps its existing operations and accepted settings; there is no new
|
|
66
|
+
required setting on existing factories.
|
|
67
|
+
|
|
68
|
+
Open a graph instance inside its device and an explicit non-default CUDA stream.
|
|
69
|
+
One instance handles one fixed input configuration on that device and stream,
|
|
70
|
+
with sequential host calls. Modules can prepare several named operations, with
|
|
71
|
+
shared fixed storage and separate backend execution units where their backend
|
|
72
|
+
requires them. The following fragment shows the integration inside a module;
|
|
73
|
+
the backend callables, fixed Frames, GPU parameters, history, and execution units
|
|
74
|
+
are prepared and owned by that module:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from pixtreme.infer.cuda_graph import CudaGraphBuffers, CudaGraphSession
|
|
78
|
+
|
|
79
|
+
buffers = CudaGraphBuffers(
|
|
80
|
+
fixed_input_frame, fixed_output_frame, params=fixed_gpu_params,
|
|
81
|
+
)
|
|
82
|
+
graphs = CudaGraphSession(
|
|
83
|
+
{"route-a": enqueue_a, "route-b": enqueue_b},
|
|
84
|
+
resources=(buffers, *history, *execution_units),
|
|
85
|
+
after_prepare=restore_initial_history_and_controls,
|
|
86
|
+
)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Each callable must enqueue on the current stream, use only fixed GPU addresses,
|
|
90
|
+
and be safe for CUDA stream capture. Preparation calls each callable once for
|
|
91
|
+
warm-up, waits for that stream, and captures it once. Keep every buffer and
|
|
92
|
+
backend workspace used inside capture alive for the whole session, using the
|
|
93
|
+
callable's owners or `resources`. Allocating an unretained temporary inside
|
|
94
|
+
capture is invalid. Preparation can write history; `after_prepare` restores both
|
|
95
|
+
GPU history and host controls to their open state without consuming requests.
|
|
96
|
+
If any operation or this callback fails, preparation releases all captured graphs
|
|
97
|
+
and retained references and propagates the error. The module's `open` must also
|
|
98
|
+
release its own partially prepared resources. No partial instance or automatic
|
|
99
|
+
normal-path fallback is returned.
|
|
100
|
+
|
|
101
|
+
For each request, the module first checks its Frame metadata, reset control, and
|
|
102
|
+
parameter contract. It calls `graphs.check_context()` **before** copying inputs
|
|
103
|
+
or resetting history. Then it can perform these steps:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
# Module request validation and graph selection have already completed.
|
|
107
|
+
graphs.check_context()
|
|
108
|
+
buffers.copy_inputs(frame, **gpu_params)
|
|
109
|
+
if reset:
|
|
110
|
+
reset_history_on_current_stream()
|
|
111
|
+
graphs.replay(selected_name)
|
|
112
|
+
result = buffers.copy_output(
|
|
113
|
+
channels=output_channels,
|
|
114
|
+
colorspace=output_colorspace,
|
|
115
|
+
gamma=output_gamma,
|
|
116
|
+
matrix=output_matrix,
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`copy_inputs` validates every source before the first copy and requires exact
|
|
121
|
+
shape, dtype, device, and auxiliary names. It imports Frame storage through
|
|
122
|
+
DLPack and accepts CUDA auxiliary arrays, including CAI v3 and CUDA DLPack
|
|
123
|
+
producers. Sources must already be ready on the current stream and remain alive
|
|
124
|
+
until its copies complete. Copying performs no casting, broadcasting, or host
|
|
125
|
+
transfer, and the graph retains no caller input address. Modules validate reset
|
|
126
|
+
before calling this method, so a structurally rejected request does not clear
|
|
127
|
+
history or modify fixed storage. Auxiliary inputs are distinct from module-owned
|
|
128
|
+
temporal history; reset and graph selection remain module responsibilities.
|
|
129
|
+
|
|
130
|
+
`copy_output` allocates independent GPU storage outside capture and uses the
|
|
131
|
+
metadata supplied for that request. Returned Frames remain unchanged by later
|
|
132
|
+
replays, resets, and close. Requests enqueue without a host wait. Callers use
|
|
133
|
+
CUDA events for another stream to consume results, and finish outstanding work
|
|
134
|
+
before the module closes `graphs`, `buffers`, and its backend resources. Both
|
|
135
|
+
component `close()` methods are idempotent and perform no synchronization; later
|
|
136
|
+
operations on closed components fail before GPU work. Changing settings, device,
|
|
137
|
+
or stream requires opening another instance; there is no automatic recapture or
|
|
138
|
+
graph cache.
|
|
139
|
+
|
|
140
|
+
For common verification, supply `CudaGraphContractSuite(module, replay_equivalence)`
|
|
141
|
+
to `verify_cuda_graph_contract` in `pixtreme.infer.verification`. `module` is the
|
|
142
|
+
existing `StatelessContractSuite` or `TemporalContractSuite`, populated from the
|
|
143
|
+
graph factory and its instances. This runs `FactoryContractCases` unchanged and,
|
|
144
|
+
for temporal modules, the existing reset, startup, instance isolation, and
|
|
145
|
+
persistent state footprint checks. `replay_equivalence` supplies `SequenceFacts`
|
|
146
|
+
from separate normal and graph instances with the same settings, including the
|
|
147
|
+
first call, continuation, changed input values and metadata, and resets. Missing
|
|
148
|
+
evidence stays unverified. Modules retain ownership of their fixtures, correctness
|
|
149
|
+
thresholds, support declarations, and evidence. Performance measurements do not
|
|
150
|
+
determine support status.
|
|
151
|
+
|
|
152
|
+
The opt-in synthetic GPU tests use no TensorRT or tensoracle. Run correctness with
|
|
153
|
+
`uv run --no-sync python -m pytest -m 'gpu and not performance' tests/test_cuda_graph_gpu.py`,
|
|
154
|
+
selecting the GPU with `CUDA_VISIBLE_DEVICES` when the machine has several.
|
|
155
|
+
The `performance` cases record video-sized copy latency with CUDA events and print
|
|
156
|
+
median and p90 values; they apply no speed threshold.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
The core distribution `pixtreme-infer` is licensed under the MIT License; see
|
|
161
|
+
[LICENSE](LICENSE). Architecture distributions are separate distributions, each with its own
|
|
162
|
+
license. The core license does not apply to them, and installing one does not change the core
|
|
163
|
+
license.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pixtreme-infer"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Inference companion for pixtreme: architecture-independent inference contracts and verification"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "minamik", email = "mia@sync.dev" },
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
license-files = ["LICENSE"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
13
|
+
"Environment :: GPU :: NVIDIA CUDA :: 13",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Operating System :: Microsoft :: Windows",
|
|
16
|
+
"Operating System :: POSIX :: Linux",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Multimedia :: Graphics",
|
|
20
|
+
"Topic :: Software Development :: Libraries",
|
|
21
|
+
]
|
|
22
|
+
requires-python = ">=3.12"
|
|
23
|
+
dependencies = [
|
|
24
|
+
"pixtreme>=1.3.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
ort = [
|
|
29
|
+
"onnxruntime-gpu>=1.20",
|
|
30
|
+
]
|
|
31
|
+
verify = [
|
|
32
|
+
"nvidia-ml-py",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
repository = "https://github.com/sync-dev-org/pixtreme-infer"
|
|
37
|
+
issues = "https://github.com/sync-dev-org/pixtreme-infer/issues"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"packaging>=24",
|
|
42
|
+
"pytest>=8.3.5",
|
|
43
|
+
"ruff>=0.15.22",
|
|
44
|
+
"mypy>=1.0.0",
|
|
45
|
+
"pillow>=11",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
testpaths = [
|
|
50
|
+
"tests",
|
|
51
|
+
]
|
|
52
|
+
python_files = ["test_*.py"]
|
|
53
|
+
python_classes = ["Test*"]
|
|
54
|
+
python_functions = ["test_*"]
|
|
55
|
+
addopts = ["--strict-markers", "-m", "not performance and not gpu"]
|
|
56
|
+
markers = [
|
|
57
|
+
"req(id): ID of the spec item the test verifies",
|
|
58
|
+
"performance: opt-in performance/timing tests (excluded by default)",
|
|
59
|
+
"extras: tests that import an optional extra (onnxruntime / nvidia-ml-py) and skip when it is absent",
|
|
60
|
+
"gpu: tests that need a real NVIDIA GPU and the matching extras (skipped when absent)",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
line-length = 120
|
|
65
|
+
target-version = "py312"
|
|
66
|
+
src = ["src"]
|
|
67
|
+
|
|
68
|
+
[tool.ruff.lint]
|
|
69
|
+
select = ["E", "F", "W", "I"]
|
|
70
|
+
ignore = [
|
|
71
|
+
"E501", # Line too long (handled by formatter)
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint.isort]
|
|
75
|
+
# The namespace root is supplied by the external pixtreme distribution even
|
|
76
|
+
# though the companion subtree lives under the configured local source root.
|
|
77
|
+
known-third-party = ["pixtreme"]
|
|
78
|
+
|
|
79
|
+
[tool.mypy]
|
|
80
|
+
python_version = "3.12"
|
|
81
|
+
strict = true
|
|
82
|
+
ignore_missing_imports = true
|
|
83
|
+
warn_unused_configs = true
|
|
84
|
+
files = [
|
|
85
|
+
"src/pixtreme",
|
|
86
|
+
]
|
|
87
|
+
mypy_path = [
|
|
88
|
+
"src",
|
|
89
|
+
]
|
|
90
|
+
explicit_package_bases = true
|
|
91
|
+
namespace_packages = true
|
|
92
|
+
|
|
93
|
+
[tool.hatch.version]
|
|
94
|
+
source = "vcs"
|
|
95
|
+
|
|
96
|
+
[tool.hatch.version.raw-options]
|
|
97
|
+
root = "."
|
|
98
|
+
# Releases are tagged vX.Y.Z; published pixtreme-infer/vX.Y.Z tags remain valid history.
|
|
99
|
+
tag_regex = "^(?:pixtreme-infer/)?v(?P<version>[0-9].*)$"
|
|
100
|
+
git_describe_command = 'git describe --dirty --tags --long --match "v[0-9]*" --match "pixtreme-infer/v[0-9]*"'
|
|
101
|
+
fallback_version = "0.0.0.dev0"
|
|
102
|
+
|
|
103
|
+
[tool.hatch.build.targets.wheel]
|
|
104
|
+
# The companion owns only pixtreme/infer; pixtreme/__init__.py remains owned by pixtreme.
|
|
105
|
+
only-include = [
|
|
106
|
+
"src/pixtreme/infer",
|
|
107
|
+
]
|
|
108
|
+
sources = ["src"]
|
|
109
|
+
|
|
110
|
+
[tool.hatch.build.targets.sdist]
|
|
111
|
+
include = [
|
|
112
|
+
"/src",
|
|
113
|
+
]
|
|
114
|
+
exclude = [
|
|
115
|
+
"/__pycache__",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[build-system]
|
|
119
|
+
requires = [
|
|
120
|
+
"hatchling",
|
|
121
|
+
"hatch-vcs",
|
|
122
|
+
]
|
|
123
|
+
build-backend = "hatchling.build"
|