triton-cache-loader 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.
- triton_cache_loader-0.1.0/.gitignore +36 -0
- triton_cache_loader-0.1.0/CHANGELOG.md +21 -0
- triton_cache_loader-0.1.0/LICENSE +159 -0
- triton_cache_loader-0.1.0/PKG-INFO +195 -0
- triton_cache_loader-0.1.0/README.md +167 -0
- triton_cache_loader-0.1.0/deploy/Dockerfile +78 -0
- triton_cache_loader-0.1.0/deploy/k8s-daemonset-prewarm.yaml +221 -0
- triton_cache_loader-0.1.0/docs/ADR-001-arch-sync-protocol.md +106 -0
- triton_cache_loader-0.1.0/docs/VERIFICATION-REPORT.md +72 -0
- triton_cache_loader-0.1.0/pyproject.toml +68 -0
- triton_cache_loader-0.1.0/src/_triton_cache_loader_hook.pth +1 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/__init__.py +252 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/cli.py +378 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/config.py +108 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/engine/__init__.py +33 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/engine/exceptions.py +27 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/engine/healthcheck.py +276 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/engine/metrics.py +101 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/engine/preloader.py +461 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/hooks/__init__.py +48 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/hooks/autotuner_guard.py +615 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/hooks/import_hook.py +160 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/hooks/triton_manager.py +297 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/probe/__init__.py +33 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/probe/cpu.py +146 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/probe/fingerprint.py +433 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/probe/gpu.py +977 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/store/__init__.py +29 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/store/local_store.py +304 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/store/manifest.py +358 -0
- triton_cache_loader-0.1.0/src/triton_cache_loader/store/remote_store.py +397 -0
- triton_cache_loader-0.1.0/tests/test_fingerprint_sync.py +196 -0
- triton_cache_loader-0.1.0/tests/test_healthcheck_once.py +191 -0
- triton_cache_loader-0.1.0/tests/test_perf_and_cross_arch.py +701 -0
- triton_cache_loader-0.1.0/tests/test_probe_hardware.py +139 -0
- triton_cache_loader-0.1.0/tests/test_security_vulns.py +935 -0
- triton_cache_loader-0.1.0/tests/test_store_and_preloader.py +270 -0
- triton_cache_loader-0.1.0/tests/test_triton_integration.py +311 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Python / packaging
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg-info/
|
|
7
|
+
.eggs/
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
sdist/
|
|
11
|
+
wheels/
|
|
12
|
+
*.whl
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
ENV/
|
|
18
|
+
.tmp_*
|
|
19
|
+
|
|
20
|
+
# Test & tool caches
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.mypy_cache/
|
|
23
|
+
.ruff_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
htmlcov/
|
|
26
|
+
|
|
27
|
+
# Triton runtime artifacts
|
|
28
|
+
.triton/
|
|
29
|
+
.triton_cache_store/
|
|
30
|
+
.loader_manifest.json
|
|
31
|
+
|
|
32
|
+
# OS / IDE
|
|
33
|
+
.DS_Store
|
|
34
|
+
Thumbs.db
|
|
35
|
+
.vscode/
|
|
36
|
+
.idea/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `triton-cache-loader` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-11-30
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Zero-overhead `.pth` lazy `sys.meta_path` hook (`_triton_cache_loader_hook.pth` + `TritonImportFinder`) with PEP 562 lazy package initialization.
|
|
12
|
+
- Zero-dependency hardware topology probing:
|
|
13
|
+
- NVIDIA CUDA/NVML via `ctypes` (`nvml.dll`/`libnvidia-ml.so.1`, `nvcuda.dll`/`libcuda.so.1`), `nvidia-smi`, and `torch.cuda`, supporting `CUDA_VISIBLE_DEVICES` indices, `GPU-...` UUIDs, `MIG-...` IDs, and logical ordinal mapping.
|
|
14
|
+
- AMD ROCm (`amd-smi`, `rocm-smi`, Linux KFD sysfs, `torch.version.hip` `gcnArchName`, `ROCR_VISIBLE_DEVICES`, `HIP_VISIBLE_DEVICES`, `HSA_OVERRIDE_GFX_VERSION`).
|
|
15
|
+
- Huawei Ascend NPU (`npu-smi`, `ASCEND_RT_VISIBLE_DEVICES`, `torch_npu`).
|
|
16
|
+
- Intel XPU (`xpu-smi`, `ZE_AFFINITY_MASK`, `torch.xpu`).
|
|
17
|
+
- Cross-platform CPU ISA probing (`avx512f`/`avx512bw`/`avx512vnni`/`amx_tile`/`avx2`/`fma`/`neon`/`sve`).
|
|
18
|
+
- SHA-256 verified, architecture-indexed bundle storage (`LocalBundleStore`, `RemoteBundleStore` with `file://` and HTTP(S) circuit breaker + anti-SSRF redirect blocking + size caps).
|
|
19
|
+
- Parallel atomic hydration (`PreloadEngine`) and single-shot O(1) execution sync verification (`ExecutionSyncHealthCheck`).
|
|
20
|
+
- Triton runtime integration (`ArchSyncedCacheManager`, `ArchArtifactRemoteBackend`, and O(1)-indexed `Autotuner` guard) + `triton-cache-loader` CLI (`probe`, `pack`, `preload`, `health`, `status`, `doctor`, `metrics`).
|
|
21
|
+
- Production `deploy/Dockerfile`, `deploy/k8s-daemonset-prewarm.yaml`, `docs/ADR-001-arch-sync-protocol.md`, and `docs/VERIFICATION-REPORT.md`.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the Licensor that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, whether in
|
|
49
|
+
Source or Object form, that is intentionally submitted to Licensor for
|
|
50
|
+
inclusion in the Work by the copyright owner or by an individual or
|
|
51
|
+
Legal Entity authorized to submit on behalf of the Contribution. For
|
|
52
|
+
the purposes of this License, "Contribution" includes any work
|
|
53
|
+
submitted to the Licensor for inclusion in the Work.
|
|
54
|
+
|
|
55
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
56
|
+
whom a Contribution has been received by Licensor and subsequently
|
|
57
|
+
incorporated into the Work.
|
|
58
|
+
|
|
59
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
60
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
61
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
62
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
63
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
64
|
+
Work and such Derivative Works in Source or Object form.
|
|
65
|
+
|
|
66
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
(except as stated in this section) patent license to make, have made,
|
|
70
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
71
|
+
where such license applies only to those patent claims licensable
|
|
72
|
+
by such Contributor that are necessarily infringed by their
|
|
73
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
74
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
75
|
+
institute patent litigation against any entity (including a
|
|
76
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
77
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
78
|
+
or contributory patent infringement, then any patent licenses
|
|
79
|
+
granted to You under this License for that Work shall terminate
|
|
80
|
+
as of the date such litigation is filed.
|
|
81
|
+
|
|
82
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
83
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
84
|
+
modifications, and in Source or Object form, provided that You
|
|
85
|
+
meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or
|
|
88
|
+
Derivative Works a copy of this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices
|
|
91
|
+
stating that You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
94
|
+
that You distribute, all copyright, patent, and trademark
|
|
95
|
+
notices from the Source form of the Work, excluding those
|
|
96
|
+
notices that do not pertain to any part of the Derivative
|
|
97
|
+
Works; and
|
|
98
|
+
|
|
99
|
+
(d) If the Work includes a "NOTICE" file as part of its
|
|
100
|
+
distribution, then any Derivative Works that You include a
|
|
101
|
+
copy of this License must include a copy of that NOTICE
|
|
102
|
+
file, in at least one of the following places: within a
|
|
103
|
+
NOTICE file distributed as part of the Work; within the
|
|
104
|
+
Source form or documentation, if provided along with the
|
|
105
|
+
Work; or, within a display generated by the Derivative
|
|
106
|
+
Works, if and wherever such third-party notices normally
|
|
107
|
+
appear. The contents of the NOTICE file are for informational
|
|
108
|
+
purposes only and do not modify the License. You may add
|
|
109
|
+
Your own NOTICE file within Derivative Works that You
|
|
110
|
+
distribute, alongside or as an addendum to the NOTICE
|
|
111
|
+
file from the Work, provided that such additional NOTICE
|
|
112
|
+
notices cannot be construed as modifying the License.
|
|
113
|
+
|
|
114
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
115
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
116
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
117
|
+
this License, without any additional terms or conditions.
|
|
118
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
119
|
+
the terms of any separate license agreement you may have executed
|
|
120
|
+
with Licensor regarding such Contributions.
|
|
121
|
+
|
|
122
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
123
|
+
names, trademarks, logos, or service marks of the Licensor, except as
|
|
124
|
+
required for reasonable and customary display of the descriptions of
|
|
125
|
+
the Work and origin of the Source.
|
|
126
|
+
|
|
127
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to,
|
|
128
|
+
in writing, software distributed under the License is distributed on an
|
|
129
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
130
|
+
express or implied. See the License for the specific language governing
|
|
131
|
+
permissions and limitations under the License.
|
|
132
|
+
|
|
133
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
134
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
135
|
+
unless required by applicable law (such as deliberate misconduct) or
|
|
136
|
+
agreed to in writing, shall any Contributor be liable to You for
|
|
137
|
+
damages, including any direct, indirect, special, incidental, or
|
|
138
|
+
consequential damages of any character arising as a result of this
|
|
139
|
+
License or out of the use or inability to use the Work (including but
|
|
140
|
+
not limited to damages for loss of goodwill, work stoppage, computer
|
|
141
|
+
failure or malfunction, or any and all other commercial damages or
|
|
142
|
+
losses), even if such Contributor has been advised of the possibility
|
|
143
|
+
of such damages.
|
|
144
|
+
|
|
145
|
+
END OF TERMS AND CONDITIONS
|
|
146
|
+
|
|
147
|
+
Copyright 2026 Abhishek Ghosh
|
|
148
|
+
|
|
149
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
150
|
+
you may not use this file except in compliance with the License.
|
|
151
|
+
You may obtain a copy of the License at
|
|
152
|
+
|
|
153
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
154
|
+
|
|
155
|
+
Unless required by applicable law or agreed to in writing, software
|
|
156
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
157
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
158
|
+
See the License for the specific language governing permissions and
|
|
159
|
+
limitations under the License.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: triton-cache-loader
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Architecture-synchronized Triton autotuning & kernel cache preloader with single-shot execution health checks for GPU and CPU systems.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Codenuclei/triton-cache-loader
|
|
6
|
+
Project-URL: Repository, https://github.com/Codenuclei/triton-cache-loader
|
|
7
|
+
Project-URL: Issues, https://github.com/Codenuclei/triton-cache-loader/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/Codenuclei/triton-cache-loader/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Abhishek Ghosh <160272247+Codenuclei@users.noreply.github.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ascend,autotune,cache,cuda,gpu,inference,mlops,rocm,triton
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: System Administrators
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# triton-cache-loader
|
|
30
|
+
|
|
31
|
+
[](https://github.com/Codenuclei/triton-cache-loader/actions/workflows/ci-publish.yml)
|
|
32
|
+
[](https://www.python.org/downloads/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
[](pyproject.toml)
|
|
35
|
+
|
|
36
|
+
**Zero-dependency, architecture-synchronized Triton autotuning & kernel cache loader with automatic import-time hydration, autotune-sweep prevention, and a single-shot execution sync health check for GPU and CPU systems.**
|
|
37
|
+
|
|
38
|
+
Install the package once (`pip install triton-cache-loader`). On the first `import triton`, it automatically probes the live GPU/CPU architecture, preloads SHA-256 verified cache bundles matching that exact hardware topology into `TRITON_CACHE_DIR`, blocks redundant `@triton.autotune` sweeps, and runs a **single-shot O(1) synchronization health check** before kernel execution.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Why `triton-cache-loader`?
|
|
43
|
+
|
|
44
|
+
Production [OpenAI Triton](https://github.com/triton-lang/triton) deployments fail in three predictable ways:
|
|
45
|
+
|
|
46
|
+
1. **Cold-start autotuning stalls:** Fresh pods trigger `@triton.autotune` sweeps (`bench_fn()`) across dozens of tile/warp/stage configs under live traffic, causing multi-second P99 latency spikes.
|
|
47
|
+
2. **Cross-architecture cubin & occupancy poisoning:** Sharing one `TRITON_CACHE_DIR` across heterogeneous nodes (e.g., `sm_80` A100 vs. `sm_90` H100, `sm_100` B200 vs. `sm_120` RTX 5090, or identical Compute Capability SKUs with different SM counts) silently breaks binary compatibility or loads suboptimal tile configurations.
|
|
48
|
+
3. **Silent driver, compiler & visibility drift:** Host driver downgrades, Triton upgrades, or per-process `CUDA_VISIBLE_DEVICES` / `ROCR_VISIBLE_DEVICES` masking invalidate cached binaries unless checked against live hardware.
|
|
49
|
+
|
|
50
|
+
`triton-cache-loader` eliminates runtime cache generation while guaranteeing hardware synchronization at execution time.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Architecture
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
Python startup (.pth)
|
|
58
|
+
│
|
|
59
|
+
▼ O(1) stdlib-only MetaPathFinder (+23–34 ms; no GPU probe until `import triton`)
|
|
60
|
+
import triton intercepted
|
|
61
|
+
│
|
|
62
|
+
▼ Zero-dep Hardware Probe (NVML / CUDA Driver ctypes, ROCm, Ascend, XPU, CPU ISA)
|
|
63
|
+
Canonical ArchFingerprint (arch_id + arch_tag)
|
|
64
|
+
│
|
|
65
|
+
▼ SHA-256 Verified Bundle Store (LocalBundleStore / RemoteBundleStore + Circuit Breaker)
|
|
66
|
+
Atomic Parallel Preloader ──► TRITON_CACHE_DIR + .loader_manifest.json
|
|
67
|
+
│
|
|
68
|
+
▼ 1st kernel / Autotuner / CacheManager lookup
|
|
69
|
+
Single-Shot ExecutionSyncHealthCheck (O(1) 4.10 us fast path on calls 2..N)
|
|
70
|
+
│
|
|
71
|
+
├── SYNCED / MINOR_DRIFT ──► Autotuner Guard loads winner in 30.6 us (bench_fn = 0 calls)
|
|
72
|
+
└── ARCH_MISMATCH / STALE_DRIVER / HETEROGENEOUS ──► strict (abort) | rehydrate | warn
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Core Guarantees
|
|
76
|
+
|
|
77
|
+
- **Zero-touch activation:** Ships `_triton_cache_loader_hook.pth` directly into `site-packages` and uses PEP 562 lazy imports so non-Triton scripts never pay GPU probe or `importlib` startup costs (`TRITON_CACHE_LOADER_DISABLE=1` disables it completely).
|
|
78
|
+
- **Single-shot execution health check:** Verifies live GPU/CPU topology (`arch`, `sm_count`, `warp_size`, `shared_mem_per_sm_bytes`, `driver_version`, `cuda_driver_version`, `triton_version`, heterogeneous multi-GPU skew) **once** per `(pid, visibility_env, policy, cache_dir)` context, then serves an `O(1)` cached check (`4.10 us` median).
|
|
79
|
+
- **Zero autotune regeneration:** Patches `triton.runtime.autotuner.Autotuner` with an `O(1)` in-memory `.autotune.json` index and implements `TRITON_CACHE_MANAGER` (`ArchSyncedCacheManager`) + `RemoteCacheBackend` (`ArchArtifactRemoteBackend`) to short-circuit `bench_fn()` on hits and block misses in `fail_on_miss` mode.
|
|
80
|
+
- **Hardened security:** Blocks path/NTFS-junction traversal, Windows drive/case-insensitive `.autotune.json` bypasses, HTTP SSRF redirects, oversized/truncated downloads, `NaN`/`Infinity`/malformed config injection, and 16/32-thread concurrent write races.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Installation
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Install from PyPI (once v0.1.0 is published)
|
|
88
|
+
pip install triton-cache-loader
|
|
89
|
+
|
|
90
|
+
# Or install directly from GitHub
|
|
91
|
+
pip install "git+https://github.com/Codenuclei/triton-cache-loader.git"
|
|
92
|
+
|
|
93
|
+
# Development / test suite
|
|
94
|
+
uv pip install -e ".[dev]"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Requires **Python >= 3.10**. Zero third-party runtime dependencies.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Quickstart
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# 1. Inspect live GPU/CPU topology and canonical arch_id
|
|
105
|
+
triton-cache-loader probe
|
|
106
|
+
|
|
107
|
+
# 2. Pack an existing warmed Triton cache into the arch-indexed store
|
|
108
|
+
triton-cache-loader pack ~/.triton/cache --store /opt/triton-cache-store
|
|
109
|
+
|
|
110
|
+
# 3. Hydrate TRITON_CACHE_DIR on a target node (local store or HTTP/file:// mirror)
|
|
111
|
+
triton-cache-loader preload \
|
|
112
|
+
--store /opt/triton-cache-store \
|
|
113
|
+
--cache-dir /mnt/nvme/triton-cache \
|
|
114
|
+
--remote https://artifacts.internal/triton-bundles
|
|
115
|
+
|
|
116
|
+
# 4. Run a strict pre-flight health check before serving traffic
|
|
117
|
+
TRITON_CACHE_DIR=/mnt/nvme/triton-cache triton-cache-loader health --policy strict
|
|
118
|
+
|
|
119
|
+
# 5. Inspect diagnostics and Prometheus metrics
|
|
120
|
+
triton-cache-loader doctor
|
|
121
|
+
triton-cache-loader metrics
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Programmatic API
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
import triton_cache_loader
|
|
128
|
+
|
|
129
|
+
triton_cache_loader.activate(preload_now=True)
|
|
130
|
+
report = triton_cache_loader.health_check()
|
|
131
|
+
assert report.sync_result.synchronized
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Multi-Architecture Hardware Support
|
|
137
|
+
|
|
138
|
+
| Vendor / Stack | Supported Targets | Native Zero-Dep Probe | Notes |
|
|
139
|
+
| :--- | :--- | :--- | :--- |
|
|
140
|
+
| **NVIDIA CUDA** | Ampere (`sm_80`/`sm_86`), Ada (`sm_89`), Hopper (`sm_90`/`sm_90a`), Blackwell (`sm_100`/`sm_120`); legacy `sm_70`/`sm_75` | `nvml.dll`/`libnvidia-ml.so.1` + `nvcuda.dll`/`libcuda.so.1` + `nvidia-smi` | Supports `CUDA_VISIBLE_DEVICES` indices, `GPU-...` UUIDs, `MIG-...`, logical ordinal mapping, and SM/shmem differentiation (`sm_100` vs `sm_120`). Pascal (`sm_60`) is flagged unsupported in modern Triton. |
|
|
141
|
+
| **AMD ROCm** | CDNA2/3 (`gfx90a`, `gfx942`), RDNA3 (`gfx1100`), RDNA2 (`gfx1030` community/override) | `amd-smi`, `rocm-smi`, Linux KFD sysfs, `torch.version.hip` | Honors `ROCR_VISIBLE_DEVICES`, `HIP_VISIBLE_DEVICES`, and `HSA_OVERRIDE_GFX_VERSION`; separates wave32 (RDNA) vs. wave64 (CDNA). |
|
|
142
|
+
| **Huawei Ascend** | `Ascend910B`, Atlas A2/A3 (`triton-ascend`) | `npu-smi`, `ASCEND_RT_VISIBLE_DEVICES`, `torch_npu` | Classified under `backend="ascend"`. |
|
|
143
|
+
| **Intel XPU** | Intel Arc / Data Center GPU Max (`triton-xpu`) | `xpu-smi`, `ZE_AFFINITY_MASK`, `torch.xpu` | Classified under `backend="xpu"`. |
|
|
144
|
+
| **CPU** | `x86_64` (`avx512`, `avx2`, `avx`, `sse2`), `aarch64` (`sve`, `neon`) | Windows `kernel32`, Linux `/proc/cpuinfo`, macOS `sysctl` | Automatic fallback when no GPU is visible (`CUDA_VISIBLE_DEVICES=-1`) or `TRITON_CACHE_LOADER_TARGET_ARCH=cpu`. |
|
|
145
|
+
|
|
146
|
+
> **SK hynix note:** SK hynix manufactures HBM (HBM3/3E/4), GDDR6-AiM PIM/AiMX cards, and CXL memory expanders rather than standalone GPUs; no Triton compiler backend exists for SK hynix.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Verified Benchmarks (`v0.1.0`)
|
|
151
|
+
|
|
152
|
+
Measured on `NVIDIA GeForce RTX 2050` (`sm_86`, 16 SMs, Driver `596.21`, CUDA `13.2`) + `12-core x86_64 AVX2` (**88/88 `pytest` passing in 31.82s** — full details in [docs/VERIFICATION-REPORT.md](docs/VERIFICATION-REPORT.md)):
|
|
153
|
+
|
|
154
|
+
| Operation | Measured Latency / Throughput |
|
|
155
|
+
| :--- | :--- |
|
|
156
|
+
| `Autotuner.check_disk_cache()` (1,000 dispatches, 25 files) | **`30.64 ms`** (`30.64 us/call` O(1) index) |
|
|
157
|
+
| `ExecutionSyncHealthCheck.check_once()` warm fast-path (10,000 calls) | **`4.10 us` median** (`p95=8.00 us`, `p99=13.20 us`) |
|
|
158
|
+
| `Autotuner.run()` dispatch overhead (1,000 calls) | **`4.81 us/call`** |
|
|
159
|
+
| Non-Triton Python `.pth` startup overhead | **`+23.30 ms` – `+34.15 ms`** |
|
|
160
|
+
| Bundle hydration (100 artifacts / 20.31 MB) | **`170.41 ms`** cold (`verify=False`), **`316.41 ms`** cold (`verify=True`), **`216.00 ms`** warm parallel SHA-256 |
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Configuration & Policies
|
|
165
|
+
|
|
166
|
+
### Environment Variables
|
|
167
|
+
|
|
168
|
+
| Variable | Default | Description |
|
|
169
|
+
| :--- | :--- | :--- |
|
|
170
|
+
| `TRITON_CACHE_LOADER_STORE` | `~/.triton_cache_store` | Path to local arch-indexed `LocalBundleStore`. |
|
|
171
|
+
| `TRITON_CACHE_LOADER_REMOTE` | Unset (`None`) | Remote bundle mirror (`file://...`, `http://...`, or `https://...`). |
|
|
172
|
+
| `TRITON_CACHE_LOADER_MODE` | `strict_preload` | Cache enforcement: `strict_preload`, `hybrid`, or `fail_on_miss`. |
|
|
173
|
+
| `TRITON_CACHE_LOADER_SYNC_POLICY` | `strict` | Action on arch drift: `strict` (raise `ArchSyncError`), `rehydrate`, or `warn`. |
|
|
174
|
+
| `TRITON_CACHE_LOADER_TARGET_ARCH` | Unset (`None`) | Set to `cpu` to force CPU ISA fingerprinting. |
|
|
175
|
+
| `TRITON_CACHE_LOADER_EXACT_DRIVER` | `0` | Set `1` to require exact `driver_version` string match instead of driver floor. |
|
|
176
|
+
| `TRITON_CACHE_LOADER_EXACT_TRITON` | `1` | Set `1` to require exact `triton_version` match between runtime and bundle. |
|
|
177
|
+
| `TRITON_CACHE_LOADER_VERIFY_SHA256` | `1` | Set `1` to enforce `size_bytes` and SHA-256 checksums on bundles and hydrated files. |
|
|
178
|
+
| `TRITON_CACHE_LOADER_AUTO_PRELOAD` | `1` | Set `1` to auto-run `PreloadEngine.preload()` on first `import triton`. |
|
|
179
|
+
| `TRITON_CACHE_LOADER_TIMEOUT_S` | `10.0` | HTTP request timeout (seconds) for `RemoteBundleStore`. |
|
|
180
|
+
| `TRITON_CACHE_LOADER_DISABLE` | `0` | Set `1` to disable `.pth` lazy hook registration at Python startup. |
|
|
181
|
+
|
|
182
|
+
### Sync States (`SyncState`) & Modes (`CacheMode`)
|
|
183
|
+
|
|
184
|
+
- **`CacheMode`:** `strict_preload` (serve preloaded cache, block `.autotune.json` overwrites), `hybrid` (serve preloaded cache, allow unseen kernels to compile/tune), `fail_on_miss` (latency-critical serving: raise `BundleNotFoundError`/`CacheMissError`, never compile or autotune).
|
|
185
|
+
- **`SyncState`:** `SYNCED`, `MINOR_DRIFT` (compatible newer CUDA driver), `ARCH_MISMATCH`, `STALE_DRIVER`, `TRITON_VERSION_MISMATCH`, `HETEROGENEOUS_NODE` (raises `HeterogeneousDeviceError`), `CORRUPT_BUNDLE`, `UNINITIALIZED`.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Docs & Deployment
|
|
190
|
+
|
|
191
|
+
- **Verification & Benchmark Report:** [docs/VERIFICATION-REPORT.md](docs/VERIFICATION-REPORT.md)
|
|
192
|
+
- **Architecture Decision Record:** [docs/ADR-001-arch-sync-protocol.md](docs/ADR-001-arch-sync-protocol.md)
|
|
193
|
+
- **Container Image:** [deploy/Dockerfile](deploy/Dockerfile)
|
|
194
|
+
- **Kubernetes Pre-warm DaemonSet:** [deploy/k8s-daemonset-prewarm.yaml](deploy/k8s-daemonset-prewarm.yaml)
|
|
195
|
+
- **CI & PyPI Trusted Publishing:** [.github/workflows/ci-publish.yml](.github/workflows/ci-publish.yml)
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# triton-cache-loader
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Codenuclei/triton-cache-loader/actions/workflows/ci-publish.yml)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](pyproject.toml)
|
|
7
|
+
|
|
8
|
+
**Zero-dependency, architecture-synchronized Triton autotuning & kernel cache loader with automatic import-time hydration, autotune-sweep prevention, and a single-shot execution sync health check for GPU and CPU systems.**
|
|
9
|
+
|
|
10
|
+
Install the package once (`pip install triton-cache-loader`). On the first `import triton`, it automatically probes the live GPU/CPU architecture, preloads SHA-256 verified cache bundles matching that exact hardware topology into `TRITON_CACHE_DIR`, blocks redundant `@triton.autotune` sweeps, and runs a **single-shot O(1) synchronization health check** before kernel execution.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Why `triton-cache-loader`?
|
|
15
|
+
|
|
16
|
+
Production [OpenAI Triton](https://github.com/triton-lang/triton) deployments fail in three predictable ways:
|
|
17
|
+
|
|
18
|
+
1. **Cold-start autotuning stalls:** Fresh pods trigger `@triton.autotune` sweeps (`bench_fn()`) across dozens of tile/warp/stage configs under live traffic, causing multi-second P99 latency spikes.
|
|
19
|
+
2. **Cross-architecture cubin & occupancy poisoning:** Sharing one `TRITON_CACHE_DIR` across heterogeneous nodes (e.g., `sm_80` A100 vs. `sm_90` H100, `sm_100` B200 vs. `sm_120` RTX 5090, or identical Compute Capability SKUs with different SM counts) silently breaks binary compatibility or loads suboptimal tile configurations.
|
|
20
|
+
3. **Silent driver, compiler & visibility drift:** Host driver downgrades, Triton upgrades, or per-process `CUDA_VISIBLE_DEVICES` / `ROCR_VISIBLE_DEVICES` masking invalidate cached binaries unless checked against live hardware.
|
|
21
|
+
|
|
22
|
+
`triton-cache-loader` eliminates runtime cache generation while guaranteeing hardware synchronization at execution time.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
Python startup (.pth)
|
|
30
|
+
│
|
|
31
|
+
▼ O(1) stdlib-only MetaPathFinder (+23–34 ms; no GPU probe until `import triton`)
|
|
32
|
+
import triton intercepted
|
|
33
|
+
│
|
|
34
|
+
▼ Zero-dep Hardware Probe (NVML / CUDA Driver ctypes, ROCm, Ascend, XPU, CPU ISA)
|
|
35
|
+
Canonical ArchFingerprint (arch_id + arch_tag)
|
|
36
|
+
│
|
|
37
|
+
▼ SHA-256 Verified Bundle Store (LocalBundleStore / RemoteBundleStore + Circuit Breaker)
|
|
38
|
+
Atomic Parallel Preloader ──► TRITON_CACHE_DIR + .loader_manifest.json
|
|
39
|
+
│
|
|
40
|
+
▼ 1st kernel / Autotuner / CacheManager lookup
|
|
41
|
+
Single-Shot ExecutionSyncHealthCheck (O(1) 4.10 us fast path on calls 2..N)
|
|
42
|
+
│
|
|
43
|
+
├── SYNCED / MINOR_DRIFT ──► Autotuner Guard loads winner in 30.6 us (bench_fn = 0 calls)
|
|
44
|
+
└── ARCH_MISMATCH / STALE_DRIVER / HETEROGENEOUS ──► strict (abort) | rehydrate | warn
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Core Guarantees
|
|
48
|
+
|
|
49
|
+
- **Zero-touch activation:** Ships `_triton_cache_loader_hook.pth` directly into `site-packages` and uses PEP 562 lazy imports so non-Triton scripts never pay GPU probe or `importlib` startup costs (`TRITON_CACHE_LOADER_DISABLE=1` disables it completely).
|
|
50
|
+
- **Single-shot execution health check:** Verifies live GPU/CPU topology (`arch`, `sm_count`, `warp_size`, `shared_mem_per_sm_bytes`, `driver_version`, `cuda_driver_version`, `triton_version`, heterogeneous multi-GPU skew) **once** per `(pid, visibility_env, policy, cache_dir)` context, then serves an `O(1)` cached check (`4.10 us` median).
|
|
51
|
+
- **Zero autotune regeneration:** Patches `triton.runtime.autotuner.Autotuner` with an `O(1)` in-memory `.autotune.json` index and implements `TRITON_CACHE_MANAGER` (`ArchSyncedCacheManager`) + `RemoteCacheBackend` (`ArchArtifactRemoteBackend`) to short-circuit `bench_fn()` on hits and block misses in `fail_on_miss` mode.
|
|
52
|
+
- **Hardened security:** Blocks path/NTFS-junction traversal, Windows drive/case-insensitive `.autotune.json` bypasses, HTTP SSRF redirects, oversized/truncated downloads, `NaN`/`Infinity`/malformed config injection, and 16/32-thread concurrent write races.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Install from PyPI (once v0.1.0 is published)
|
|
60
|
+
pip install triton-cache-loader
|
|
61
|
+
|
|
62
|
+
# Or install directly from GitHub
|
|
63
|
+
pip install "git+https://github.com/Codenuclei/triton-cache-loader.git"
|
|
64
|
+
|
|
65
|
+
# Development / test suite
|
|
66
|
+
uv pip install -e ".[dev]"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Requires **Python >= 3.10**. Zero third-party runtime dependencies.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Quickstart
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 1. Inspect live GPU/CPU topology and canonical arch_id
|
|
77
|
+
triton-cache-loader probe
|
|
78
|
+
|
|
79
|
+
# 2. Pack an existing warmed Triton cache into the arch-indexed store
|
|
80
|
+
triton-cache-loader pack ~/.triton/cache --store /opt/triton-cache-store
|
|
81
|
+
|
|
82
|
+
# 3. Hydrate TRITON_CACHE_DIR on a target node (local store or HTTP/file:// mirror)
|
|
83
|
+
triton-cache-loader preload \
|
|
84
|
+
--store /opt/triton-cache-store \
|
|
85
|
+
--cache-dir /mnt/nvme/triton-cache \
|
|
86
|
+
--remote https://artifacts.internal/triton-bundles
|
|
87
|
+
|
|
88
|
+
# 4. Run a strict pre-flight health check before serving traffic
|
|
89
|
+
TRITON_CACHE_DIR=/mnt/nvme/triton-cache triton-cache-loader health --policy strict
|
|
90
|
+
|
|
91
|
+
# 5. Inspect diagnostics and Prometheus metrics
|
|
92
|
+
triton-cache-loader doctor
|
|
93
|
+
triton-cache-loader metrics
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Programmatic API
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import triton_cache_loader
|
|
100
|
+
|
|
101
|
+
triton_cache_loader.activate(preload_now=True)
|
|
102
|
+
report = triton_cache_loader.health_check()
|
|
103
|
+
assert report.sync_result.synchronized
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Multi-Architecture Hardware Support
|
|
109
|
+
|
|
110
|
+
| Vendor / Stack | Supported Targets | Native Zero-Dep Probe | Notes |
|
|
111
|
+
| :--- | :--- | :--- | :--- |
|
|
112
|
+
| **NVIDIA CUDA** | Ampere (`sm_80`/`sm_86`), Ada (`sm_89`), Hopper (`sm_90`/`sm_90a`), Blackwell (`sm_100`/`sm_120`); legacy `sm_70`/`sm_75` | `nvml.dll`/`libnvidia-ml.so.1` + `nvcuda.dll`/`libcuda.so.1` + `nvidia-smi` | Supports `CUDA_VISIBLE_DEVICES` indices, `GPU-...` UUIDs, `MIG-...`, logical ordinal mapping, and SM/shmem differentiation (`sm_100` vs `sm_120`). Pascal (`sm_60`) is flagged unsupported in modern Triton. |
|
|
113
|
+
| **AMD ROCm** | CDNA2/3 (`gfx90a`, `gfx942`), RDNA3 (`gfx1100`), RDNA2 (`gfx1030` community/override) | `amd-smi`, `rocm-smi`, Linux KFD sysfs, `torch.version.hip` | Honors `ROCR_VISIBLE_DEVICES`, `HIP_VISIBLE_DEVICES`, and `HSA_OVERRIDE_GFX_VERSION`; separates wave32 (RDNA) vs. wave64 (CDNA). |
|
|
114
|
+
| **Huawei Ascend** | `Ascend910B`, Atlas A2/A3 (`triton-ascend`) | `npu-smi`, `ASCEND_RT_VISIBLE_DEVICES`, `torch_npu` | Classified under `backend="ascend"`. |
|
|
115
|
+
| **Intel XPU** | Intel Arc / Data Center GPU Max (`triton-xpu`) | `xpu-smi`, `ZE_AFFINITY_MASK`, `torch.xpu` | Classified under `backend="xpu"`. |
|
|
116
|
+
| **CPU** | `x86_64` (`avx512`, `avx2`, `avx`, `sse2`), `aarch64` (`sve`, `neon`) | Windows `kernel32`, Linux `/proc/cpuinfo`, macOS `sysctl` | Automatic fallback when no GPU is visible (`CUDA_VISIBLE_DEVICES=-1`) or `TRITON_CACHE_LOADER_TARGET_ARCH=cpu`. |
|
|
117
|
+
|
|
118
|
+
> **SK hynix note:** SK hynix manufactures HBM (HBM3/3E/4), GDDR6-AiM PIM/AiMX cards, and CXL memory expanders rather than standalone GPUs; no Triton compiler backend exists for SK hynix.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Verified Benchmarks (`v0.1.0`)
|
|
123
|
+
|
|
124
|
+
Measured on `NVIDIA GeForce RTX 2050` (`sm_86`, 16 SMs, Driver `596.21`, CUDA `13.2`) + `12-core x86_64 AVX2` (**88/88 `pytest` passing in 31.82s** — full details in [docs/VERIFICATION-REPORT.md](docs/VERIFICATION-REPORT.md)):
|
|
125
|
+
|
|
126
|
+
| Operation | Measured Latency / Throughput |
|
|
127
|
+
| :--- | :--- |
|
|
128
|
+
| `Autotuner.check_disk_cache()` (1,000 dispatches, 25 files) | **`30.64 ms`** (`30.64 us/call` O(1) index) |
|
|
129
|
+
| `ExecutionSyncHealthCheck.check_once()` warm fast-path (10,000 calls) | **`4.10 us` median** (`p95=8.00 us`, `p99=13.20 us`) |
|
|
130
|
+
| `Autotuner.run()` dispatch overhead (1,000 calls) | **`4.81 us/call`** |
|
|
131
|
+
| Non-Triton Python `.pth` startup overhead | **`+23.30 ms` – `+34.15 ms`** |
|
|
132
|
+
| Bundle hydration (100 artifacts / 20.31 MB) | **`170.41 ms`** cold (`verify=False`), **`316.41 ms`** cold (`verify=True`), **`216.00 ms`** warm parallel SHA-256 |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Configuration & Policies
|
|
137
|
+
|
|
138
|
+
### Environment Variables
|
|
139
|
+
|
|
140
|
+
| Variable | Default | Description |
|
|
141
|
+
| :--- | :--- | :--- |
|
|
142
|
+
| `TRITON_CACHE_LOADER_STORE` | `~/.triton_cache_store` | Path to local arch-indexed `LocalBundleStore`. |
|
|
143
|
+
| `TRITON_CACHE_LOADER_REMOTE` | Unset (`None`) | Remote bundle mirror (`file://...`, `http://...`, or `https://...`). |
|
|
144
|
+
| `TRITON_CACHE_LOADER_MODE` | `strict_preload` | Cache enforcement: `strict_preload`, `hybrid`, or `fail_on_miss`. |
|
|
145
|
+
| `TRITON_CACHE_LOADER_SYNC_POLICY` | `strict` | Action on arch drift: `strict` (raise `ArchSyncError`), `rehydrate`, or `warn`. |
|
|
146
|
+
| `TRITON_CACHE_LOADER_TARGET_ARCH` | Unset (`None`) | Set to `cpu` to force CPU ISA fingerprinting. |
|
|
147
|
+
| `TRITON_CACHE_LOADER_EXACT_DRIVER` | `0` | Set `1` to require exact `driver_version` string match instead of driver floor. |
|
|
148
|
+
| `TRITON_CACHE_LOADER_EXACT_TRITON` | `1` | Set `1` to require exact `triton_version` match between runtime and bundle. |
|
|
149
|
+
| `TRITON_CACHE_LOADER_VERIFY_SHA256` | `1` | Set `1` to enforce `size_bytes` and SHA-256 checksums on bundles and hydrated files. |
|
|
150
|
+
| `TRITON_CACHE_LOADER_AUTO_PRELOAD` | `1` | Set `1` to auto-run `PreloadEngine.preload()` on first `import triton`. |
|
|
151
|
+
| `TRITON_CACHE_LOADER_TIMEOUT_S` | `10.0` | HTTP request timeout (seconds) for `RemoteBundleStore`. |
|
|
152
|
+
| `TRITON_CACHE_LOADER_DISABLE` | `0` | Set `1` to disable `.pth` lazy hook registration at Python startup. |
|
|
153
|
+
|
|
154
|
+
### Sync States (`SyncState`) & Modes (`CacheMode`)
|
|
155
|
+
|
|
156
|
+
- **`CacheMode`:** `strict_preload` (serve preloaded cache, block `.autotune.json` overwrites), `hybrid` (serve preloaded cache, allow unseen kernels to compile/tune), `fail_on_miss` (latency-critical serving: raise `BundleNotFoundError`/`CacheMissError`, never compile or autotune).
|
|
157
|
+
- **`SyncState`:** `SYNCED`, `MINOR_DRIFT` (compatible newer CUDA driver), `ARCH_MISMATCH`, `STALE_DRIVER`, `TRITON_VERSION_MISMATCH`, `HETEROGENEOUS_NODE` (raises `HeterogeneousDeviceError`), `CORRUPT_BUNDLE`, `UNINITIALIZED`.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Docs & Deployment
|
|
162
|
+
|
|
163
|
+
- **Verification & Benchmark Report:** [docs/VERIFICATION-REPORT.md](docs/VERIFICATION-REPORT.md)
|
|
164
|
+
- **Architecture Decision Record:** [docs/ADR-001-arch-sync-protocol.md](docs/ADR-001-arch-sync-protocol.md)
|
|
165
|
+
- **Container Image:** [deploy/Dockerfile](deploy/Dockerfile)
|
|
166
|
+
- **Kubernetes Pre-warm DaemonSet:** [deploy/k8s-daemonset-prewarm.yaml](deploy/k8s-daemonset-prewarm.yaml)
|
|
167
|
+
- **CI & PyPI Trusted Publishing:** [.github/workflows/ci-publish.yml](.github/workflows/ci-publish.yml)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Production container image for serving Triton-backed workloads with
|
|
2
|
+
# architecture-synchronized preloaded caches and strict pre-flight verification.
|
|
3
|
+
#
|
|
4
|
+
# Build (with optional pre-baked arch-indexed bundles under ./bundles):
|
|
5
|
+
# docker build -f deploy/Dockerfile -t triton-serving:latest .
|
|
6
|
+
#
|
|
7
|
+
# Run (mounting host/node-local NVMe cache or pointing to remote bundle store):
|
|
8
|
+
# docker run --gpus all \
|
|
9
|
+
# -v /mnt/nvme/triton-cache:/var/cache/triton \
|
|
10
|
+
# -e TRITON_CACHE_LOADER_REMOTE=https://artifacts.internal/triton-bundles \
|
|
11
|
+
# triton-serving:latest python -m your_serving_app
|
|
12
|
+
|
|
13
|
+
ARG BASE_IMAGE=nvidia/cuda:12.4.1-runtime-ubuntu22.04
|
|
14
|
+
FROM ${BASE_IMAGE} AS runtime
|
|
15
|
+
|
|
16
|
+
ENV DEBIAN_FRONTEND=noninteractive \
|
|
17
|
+
PYTHONUNBUFFERED=1 \
|
|
18
|
+
PIP_NO_CACHE_DIR=1
|
|
19
|
+
|
|
20
|
+
# Ensure Python >= 3.10 is present (no-op on images that already bundle it)
|
|
21
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
22
|
+
python3 \
|
|
23
|
+
python3-pip \
|
|
24
|
+
ca-certificates \
|
|
25
|
+
&& rm -rf /var/lib/apt/lists/* \
|
|
26
|
+
&& ln -sf /usr/bin/python3 /usr/local/bin/python
|
|
27
|
+
|
|
28
|
+
WORKDIR /opt/triton-cache-loader
|
|
29
|
+
|
|
30
|
+
# Install triton-cache-loader (registers _triton_cache_loader_hook.pth in site-packages)
|
|
31
|
+
COPY pyproject.toml README.md ./
|
|
32
|
+
COPY src ./src
|
|
33
|
+
RUN python3 -m pip install --no-cache-dir .
|
|
34
|
+
|
|
35
|
+
# Optional: bake pre-warmed arch-indexed bundles (<store_dir>/<arch_id>/manifest.json)
|
|
36
|
+
# into the image. If omitted or overridden at runtime, mount /opt/triton-cache-store
|
|
37
|
+
# or set TRITON_CACHE_LOADER_REMOTE.
|
|
38
|
+
RUN mkdir -p /opt/triton-cache-store /var/cache/triton
|
|
39
|
+
# COPY bundles/ /opt/triton-cache-store/
|
|
40
|
+
|
|
41
|
+
# Strict production defaults:
|
|
42
|
+
# - Hydrate to /var/cache/triton (override with node-local NVMe mount in K8s)
|
|
43
|
+
# - fail_on_miss guarantees zero runtime autotuning stalls in production
|
|
44
|
+
# - strict sync policy aborts startup on arch/SM/driver/Triton drift
|
|
45
|
+
ENV TRITON_CACHE_LOADER_STORE=/opt/triton-cache-store \
|
|
46
|
+
TRITON_CACHE_DIR=/var/cache/triton \
|
|
47
|
+
TRITON_CACHE_MANAGER=triton_cache_loader.hooks.triton_manager:ArchSyncedCacheManager \
|
|
48
|
+
TRITON_CACHE_LOADER_MODE=fail_on_miss \
|
|
49
|
+
TRITON_CACHE_LOADER_SYNC_POLICY=strict \
|
|
50
|
+
TRITON_CACHE_LOADER_VERIFY_SHA256=1 \
|
|
51
|
+
TRITON_CACHE_LOADER_EXACT_TRITON=1 \
|
|
52
|
+
TRITON_CACHE_LOADER_AUTO_PRELOAD=1
|
|
53
|
+
|
|
54
|
+
# Pre-flight entrypoint:
|
|
55
|
+
# 1. Hydrates matching arch bundle into TRITON_CACHE_DIR (from local or remote store).
|
|
56
|
+
# 2. Enforces `triton-cache-loader health --policy strict` before exec'ing the server.
|
|
57
|
+
RUN cat <<'EOF' > /usr/local/bin/triton-cache-entrypoint.sh
|
|
58
|
+
#!/usr/bin/env bash
|
|
59
|
+
set -euo pipefail
|
|
60
|
+
|
|
61
|
+
echo "[triton-cache-loader] Probing node topology..."
|
|
62
|
+
triton-cache-loader probe --json
|
|
63
|
+
|
|
64
|
+
echo "[triton-cache-loader] Hydrating TRITON_CACHE_DIR=${TRITON_CACHE_DIR}..."
|
|
65
|
+
triton-cache-loader preload \
|
|
66
|
+
--store "${TRITON_CACHE_LOADER_STORE}" \
|
|
67
|
+
--cache-dir "${TRITON_CACHE_DIR}" \
|
|
68
|
+
${TRITON_CACHE_LOADER_REMOTE:+--remote "${TRITON_CACHE_LOADER_REMOTE}"}
|
|
69
|
+
|
|
70
|
+
echo "[triton-cache-loader] Running strict execution sync health gate..."
|
|
71
|
+
triton-cache-loader health --policy strict
|
|
72
|
+
|
|
73
|
+
exec "$@"
|
|
74
|
+
EOF
|
|
75
|
+
RUN chmod +x /usr/local/bin/triton-cache-entrypoint.sh
|
|
76
|
+
|
|
77
|
+
ENTRYPOINT ["/usr/local/bin/triton-cache-entrypoint.sh"]
|
|
78
|
+
CMD ["triton-cache-loader", "doctor"]
|