raptor-core 0.2.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.
Files changed (40) hide show
  1. raptor_core-0.2.0/LICENSE +202 -0
  2. raptor_core-0.2.0/NOTICE +2 -0
  3. raptor_core-0.2.0/PKG-INFO +328 -0
  4. raptor_core-0.2.0/README.md +308 -0
  5. raptor_core-0.2.0/pyproject.toml +93 -0
  6. raptor_core-0.2.0/raptor/__init__.py +14 -0
  7. raptor_core-0.2.0/raptor/conformance/__init__.py +38 -0
  8. raptor_core-0.2.0/raptor/conformance/doc_includes.py +178 -0
  9. raptor_core-0.2.0/raptor/conformance/interop.py +393 -0
  10. raptor_core-0.2.0/raptor/protocols/__init__.py +24 -0
  11. raptor_core-0.2.0/raptor/protocols/backend.py +102 -0
  12. raptor_core-0.2.0/raptor/protocols/launcher.py +129 -0
  13. raptor_core-0.2.0/raptor/protocols/provider.py +38 -0
  14. raptor_core-0.2.0/raptor/py.typed +0 -0
  15. raptor_core-0.2.0/raptor/schema/__init__.py +88 -0
  16. raptor_core-0.2.0/raptor/schema/blocks.py +283 -0
  17. raptor_core-0.2.0/raptor/schema/dtypes.py +31 -0
  18. raptor_core-0.2.0/raptor/schema/manifest.py +270 -0
  19. raptor_core-0.2.0/raptor/version.py +13 -0
  20. raptor_core-0.2.0/raptor_core.egg-info/PKG-INFO +328 -0
  21. raptor_core-0.2.0/raptor_core.egg-info/SOURCES.txt +38 -0
  22. raptor_core-0.2.0/raptor_core.egg-info/dependency_links.txt +1 -0
  23. raptor_core-0.2.0/raptor_core.egg-info/requires.txt +4 -0
  24. raptor_core-0.2.0/raptor_core.egg-info/top_level.txt +1 -0
  25. raptor_core-0.2.0/setup.cfg +4 -0
  26. raptor_core-0.2.0/tests/test_blocks_zero_dep_floor.py +102 -0
  27. raptor_core-0.2.0/tests/test_conformance_interop.py +117 -0
  28. raptor_core-0.2.0/tests/test_docs_interop_protocols_sync.py +80 -0
  29. raptor_core-0.2.0/tests/test_example_autodiff_vs_torch.py +200 -0
  30. raptor_core-0.2.0/tests/test_example_early_termination.py +183 -0
  31. raptor_core-0.2.0/tests/test_example_two_body_hybrid.py +77 -0
  32. raptor_core-0.2.0/tests/test_example_zero_copy_interop.py +198 -0
  33. raptor_core-0.2.0/tests/test_goldens.py +85 -0
  34. raptor_core-0.2.0/tests/test_hawk_contracts_conformance.py +225 -0
  35. raptor_core-0.2.0/tests/test_import.py +24 -0
  36. raptor_core-0.2.0/tests/test_packaging.py +63 -0
  37. raptor_core-0.2.0/tests/test_protocols.py +112 -0
  38. raptor_core-0.2.0/tests/test_purity.py +56 -0
  39. raptor_core-0.2.0/tests/test_schema_v2_execution.py +190 -0
  40. raptor_core-0.2.0/tests/test_verbatim_against_eagle.py +49 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ raptor
2
+ Copyright 2026 Alessandro Masat
@@ -0,0 +1,328 @@
1
+ Metadata-Version: 2.4
2
+ Name: raptor-core
3
+ Version: 0.2.0
4
+ Summary: raptor — the protocol spine of the family: schema, typing.Protocols, golden conformance suite
5
+ Author: Alessandro Masat
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/amasat01/raptor
8
+ Project-URL: Documentation, https://amasat01.github.io/raptor/
9
+ Project-URL: Repository, https://github.com/amasat01/raptor
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ License-File: NOTICE
16
+ Provides-Extra: demo
17
+ Requires-Dist: numpy; extra == "demo"
18
+ Requires-Dist: torch; extra == "demo"
19
+ Dynamic: license-file
20
+
21
+ <p align="center">
22
+ <img src="https://raw.githubusercontent.com/amasat01/raptor/main/docs/_static/brand/family_raptor.svg" alt="" height="56">
23
+ </p>
24
+ <h1 align="center">raptor</h1>
25
+ <h3 align="center">raptor: one manifest, any engine</h3>
26
+ <p align="center">A compiled GPU kernel ships with a small JSON file that says what it takes, what it returns and
27
+ where it can run. raptor defines that file, so one package can build a kernel and another can run it.</p>
28
+ <p align="center"><b>Runs on:</b> CPU, no GPU needed · <b>You need:</b> Python 3.9+, nothing else to install raptor itself</p>
29
+
30
+ <p align="center">
31
+ <a href="https://github.com/amasat01/raptor/actions/workflows/ci.yml"><img src="https://github.com/amasat01/raptor/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
32
+ <a href="https://amasat01.github.io/raptor/"><img src="https://github.com/amasat01/raptor/actions/workflows/docs.yml/badge.svg" alt="Docs"></a>
33
+ <a href="https://github.com/amasat01/raptor/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License"></a>
34
+ </p>
35
+
36
+ <p align="center">
37
+ <picture>
38
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/amasat01/raptor/main/docs/_static/ecosystem/ecosystem_raptor_dark.svg">
39
+ <img src="https://raw.githubusercontent.com/amasat01/raptor/main/docs/_static/ecosystem/ecosystem_raptor_light.svg" alt="The RAPTOR family: hawk (write it), eagle (run it), aether (the C++/CUDA numerics underneath) and raptor (the shared contract); you are looking at raptor." width="760">
40
+ </picture>
41
+ </p>
42
+
43
+ <p align="center">
44
+
45
+ [aether](https://amasat01.github.io/aether/) · [hawk](https://amasat01.github.io/hawk/) · [eagle](https://amasat01.github.io/eagle/) · [raptor](https://amasat01.github.io/raptor/) · [the family](https://amasat01.github.io/)
46
+
47
+ </p>
48
+
49
+ raptor holds the shared contracts of the [RAPTOR family](https://amasat01.github.io/): the manifest format and certification
50
+ contracts that let a kernel built once work with the code you already have. See
51
+ [where RAPTOR fits](https://amasat01.github.io/where_raptor_fits.html) for how the four pieces combine.
52
+
53
+ | **0** | **4** | **1** |
54
+ |:---:|:---:|:---:|
55
+ | hard dependencies (pure Python) | array libraries certified: NumPy, CuPy, PyTorch, Warp | JSON manifest per kernel bundle (a kernel's compiled artifact(s) plus its manifest) |
56
+
57
+ **See it working**: a batch of orbits, one kernel, run on CPU threads — [Demo](#demo) below has the commands
58
+ and what each printed line means.
59
+
60
+ [Docs](https://amasat01.github.io/raptor/) · [the family site](https://amasat01.github.io/)
61
+
62
+ ## For package authors
63
+
64
+ ```python
65
+ from raptor.schema import validate_manifest
66
+
67
+ manifest = {
68
+ "schema_version": 2,
69
+ "pattern": "pure",
70
+ "aether_abi": "aether-abi/2",
71
+ "exec_targets": ["host", "device"],
72
+ "exec_access": "sample_local",
73
+ "plugins": [{"id": "two_body_step", "order": 0, "enabled": True, "artifact": "two_body_step.ptx",
74
+ "sidecar": "two_body_step.json", "format": "ptx"}],
75
+ }
76
+ validate_manifest(manifest) # raises on a malformed or out-of-order document
77
+ ```
78
+
79
+ | key | meaning |
80
+ |---|---|
81
+ | `schema_version` | which rules this document follows |
82
+ | `pattern` | which kind of kernel this is; `pure` = no side effects |
83
+ | `aether_abi` | the binary-format tag paired with `schema_version` (e.g. `"aether-abi/2"` for v2) |
84
+ | `exec_targets` | host / device: where this kernel may run |
85
+ | `exec_access` | how it touches per-sample vs. cross-sample data |
86
+ | `plugins` | the compiled artifact(s) this manifest describes (`ptx` = NVIDIA's GPU assembly format) |
87
+
88
+ Any class with a matching `build(directory)` method satisfies
89
+ `ManifestProvider` — "duck typing": judged by which methods exist, checked
90
+ with `isinstance`, never by which class it inherits from:
91
+
92
+ ```python
93
+ from raptor.protocols import ManifestProvider
94
+
95
+ class Bundle:
96
+ def build(self, directory):
97
+ return f"{directory}/manifest.json"
98
+
99
+ isinstance(Bundle(), ManifestProvider) # True — duck-typed, no inheritance needed
100
+ ```
101
+
102
+ ## Install
103
+
104
+ ```bash
105
+ pip install raptor-core # Python 3.9+, no dependencies
106
+ ```
107
+
108
+ The import name is `raptor`. The rest of the family installs the same way: `pip install raptor-hawk` for the CPU
109
+ route (Linux x86_64, CPython 3.10-3.13, a host `g++` 11 or newer; it brings `aether-dsc`, the sealed C++ headers it
110
+ compiles against, automatically), and for the GPU route
111
+ `pip install "raptor-hawk[cuda12]" "raptor-eagle[cuda12]"` (use `[cuda13]` on both for CUDA 13; no `nvcc` needed).
112
+
113
+ > **NVIDIA packages come only through the extras.** `raptor-hawk[cuda12]` pulls `cuda-bindings` 12,
114
+ > `nvidia-cuda-nvrtc-cu12` and `nvidia-cuda-cccl-cu12`; `raptor-hawk[cuda13]` pulls `cuda-bindings` 13,
115
+ > `nvidia-cuda-nvrtc` 13 and `nvidia-cuda-cccl` 13; `raptor-eagle[cuda12]` / `[cuda13]` pull CuPy
116
+ > (`cupy-cuda12x` / `cupy-cuda13x`, with the CUDA headers CuPy compiles against). Without an extra pip installs no NVIDIA package: you get the CPU route, or the GPU route through a CUDA setup you already have. Pick the extra matching the CUDA
117
+ > version your driver reports (`nvidia-smi`, top right).
118
+
119
+ **Platforms:** built and tested on Linux x86_64 only so far (CPython 3.10–3.13), on NVIDIA GPUs from Pascal (Quadro P2000) and Turing (Tesla T4). There are no wheels for macOS, Windows or ARM yet, and WSL2 is untested. `raptor-core` and `aether-dsc` are pure Python and install anywhere.
120
+
121
+ To work on the code, from a clone: `git clone https://github.com/amasat01/raptor.git`, then `pip install -e .`. Test with `pip install pytest && pytest tests -m "not
122
+ cross_repo"` (`-m "not cross_repo"` leaves out the tests that check eagle against raptor's contracts — they need
123
+ an `eagle` checkout next to this one, and fail rather than skip without it). To set up a development machine for
124
+ the whole family, see [`tools/devbox/`](https://github.com/amasat01/raptor/tree/main/tools/devbox).
125
+
126
+ ## Demo
127
+
128
+ `examples/two_body_hybrid.py` is a small end-to-end example: a batch of
129
+ orbits propagated by a hand-written physics formula plus a small learned
130
+ correction, traced into one compiled kernel that this package's manifest
131
+ describes. See [Going deeper](#going-deeper-optional) below for exactly
132
+ what it computes and prints.
133
+
134
+ ```bash
135
+ # hawk and eagle come from PyPI (no nvcc needed); [demo] adds numpy and torch
136
+ pip install "raptor-hawk[cuda12]" "raptor-eagle[cuda12]" # or [cuda13] on both
137
+ pip install -e .[demo] # from a clone of this repository
138
+ python examples/two_body_hybrid.py --host
139
+ python examples/two_body_hybrid.py --device --steps 400 --batch 65536
140
+ ```
141
+
142
+ `--host` prints the following (output of `python examples/two_body_hybrid.py --host`; the wall-per-step line varies by
143
+ machine, everything above it is exact, the same seed every run):
144
+
145
+ ```
146
+ target : host (manifest exec_targets ['host'])
147
+ batch x steps : 1024 x 200 at dt = 0.01
148
+ training loss : 1.230e-06
149
+ (a) max |compiled - torch eager| : 1.788e-06 (tolerance 1e-04)
150
+ (b) final-state error vs truth : corrected 6.491e-03 vs two-body only 1.930e-01
151
+ (c) wall per step (demo measurement, not a benchmark): compiled 1.306 ms, torch eager 0.612 ms
152
+ ```
153
+
154
+ ## Going deeper (optional)
155
+
156
+ What the demo computes, package internals, and three scripts' own
157
+ machine-local measurements — none of it needed to install or use raptor.
158
+
159
+ <details>
160
+ <summary>What's inside</summary>
161
+
162
+ - `raptor.schema` — the kernel-manifest schema, two layers:
163
+ `schema.manifest` (the core layer every producer writes against) and
164
+ `schema.blocks` (the `neural_block` extension; hawk never imports it).
165
+ `schema.dtypes` carries the scalar-type tag vocabulary.
166
+ `raptor.schema.validate_manifest(doc)` is a minimal shape validator (key
167
+ order, top keys, schema_version, pattern vocabulary) — not a port of
168
+ eagle's deep `validate_sidecar`. Schema versions 1 and 2 both load
169
+ (`manifest.MAX_SCHEMA_VERSION`): v2 adds three
170
+ flat, versioned top-level keys — `exec_targets` (`device`/`host` list),
171
+ `exec_access` (`sample_local` / `cross_sample_read` / `cross_sample_write`
172
+ / `mapreduce`), `exec_op` (required iff `exec_access="mapreduce"`) — and
173
+ requires `aether_abi: "aether-abi/2"`; v1 rejects any `exec_*` key
174
+ outright (`manifest.check_execution_axis`).
175
+ - `raptor.protocols` — the `typing.Protocol` definitions:
176
+ `Backend` / `Executable` (program-level execution),
177
+ `KernelLauncher` / `Marshal` (kernel-level launch/marshal, mirroring
178
+ eagle's public surface 1:1), `ManifestProvider` (the kernel-provider
179
+ protocol's one facet).
180
+ - `raptor.conformance` — the interop certification declaration (`UNIVERSE` /
181
+ `CERTIFIED` / `ROADMAP` / `ROWS`) and its reusable matrix-hygiene scanners;
182
+ the full row-by-row certification matrix is on the
183
+ [interop protocols page](https://amasat01.github.io/raptor/content/interop_protocols.html).
184
+ - `goldens/` — the golden conformance corpus (harvested from eagle's test
185
+ fixtures) that `raptor.schema.validate_manifest` is exercised against.
186
+ - `tests/*cross_repo*`: the eagle conformance battery
187
+ (`test_verbatim_against_eagle.py`, `test_goldens.py`), marked `cross_repo`
188
+ and failing rather than skipping when a sibling checkout is absent —
189
+ deselected here only via `-m "not cross_repo"`, run for real by the local
190
+ gate and a downstream package's own CI. `raptor.schema.manifest.SCHEMA_VERSION`
191
+ is the version of record; `eagle.roles.SCHEMA_VERSION` derives from it
192
+ directly, so no standalone text-scan cross-check is kept as a redundant leg.
193
+ </details>
194
+
195
+ <details>
196
+ <summary>What the demo computes</summary>
197
+
198
+ A batch of planar orbits is propagated with **RK4** (a standard 4th-order
199
+ numerical-integration formula). The textbook two-body formula is written by
200
+ hand; the piece it misses — drag — is learned by a small (4 → 32 → 2) neural
201
+ network trained in torch on CPU. hawk traces ONE kernel that performs a
202
+ whole RK4 step with the network evaluated inline, compiles it, and publishes
203
+ it with a manifest this package's schema validates; eagle loads that
204
+ manifest and runs the kernel, either on CPU threads or as a replayed
205
+ **CUDA graph** (a GPU's sequence of launches recorded once and replayed
206
+ without re-issuing each one). The script prints how closely the compiled
207
+ rollout tracks a plain torch rollout of the same arithmetic, how much closer
208
+ to the truth the corrected orbits land than uncorrected ones, and a
209
+ wall-per-step line.
210
+ </details>
211
+
212
+ <details>
213
+ <summary>early termination: samples that finish at different times (measured when the script runs — numbers vary by machine)</summary>
214
+
215
+ `examples/early_termination.py` shows the other half of this one-kernel
216
+ idea: irregular work whose samples finish at different times, with the host
217
+ out of the loop. A batch of planar orbits ends when it crosses a collision
218
+ or an escape radius, and a device-side live count guards each step with a
219
+ conditional graph node (a graph step that can skip itself at replay time),
220
+ so the whole horizon is queued as graph replays with zero host round-trips
221
+ until every sample is done — later replays then do no work at all. Measured
222
+ against the identical captured graph with the guard removed (so the guard
223
+ is the only difference), the skip is a real wall-clock saving that scales
224
+ with how much of the horizon runs past the last termination — **this
225
+ script's own measurement, on the machine that built this page: over 13x at
226
+ a million samples over 4000 steps (13.8x in the committed card).** The script also runs
227
+ the same kernel eagerly, host-side guard check and all: at a million samples the
228
+ guarded graph and this host-guarded eager loop tie (1.01x in the card; the kernel itself
229
+ dominates there); at the smallest batches (1, 32 samples) the skip does not
230
+ pay for itself — the conditional node's own fixed cost exceeds a tiny
231
+ kernel's, so the unguarded graph is the fastest arm. The eager loop also
232
+ carries one host round-trip per two-step replay against the graph's one for
233
+ the whole captured horizon, a gap the numbers above already price in. CPU
234
+ mode (`--host`) runs the same kernel with the guard evaluated eagerly, so it
235
+ needs no GPU. `--torch` (device only) times the same RK4 two-body physics
236
+ written in idiomatic torch — eager, eager with a host check, and both as a
237
+ replayed CUDA graph — against the guarded graph and prints each arm's ratio.
238
+ Run it yourself for your own machine's numbers.
239
+
240
+ ```bash
241
+ python examples/early_termination.py --host
242
+ python examples/early_termination.py --device
243
+ python examples/early_termination.py --device --torch
244
+ ```
245
+ </details>
246
+
247
+ <details>
248
+ <summary>zero-copy interop (measured when the script runs — numbers vary by machine)</summary>
249
+
250
+ `examples/zero_copy_interop.py` backs the third leg of the same idea:
251
+ exchanging GPU arrays with NumPy, CuPy and PyTorch without copies, and only
252
+ where the family's own certification matrix says there is none. A
253
+ CUDA-resident torch tensor is handed straight into one hawk kernel through
254
+ eagle's zero-copy `to_cupy` view, and the kernel writes its result into a
255
+ second torch CUDA buffer through the same view — no allocation, no copy,
256
+ matching the aliasing rows of [raptor's interop matrix](https://amasat01.github.io/raptor/content/interop_protocols.html)
257
+ exactly. The same tensor read from
258
+ CPU memory instead takes the honest upload the matrix declares as a copy.
259
+ The script prints each crossing's measured pointer
260
+ identity next to the row that covers it, and a behavioural proof for the
261
+ input alias: mutating the torch tensor in place and replaying the same
262
+ kernel with no rebind shows the output tracking the change. `--device` also
263
+ times that alias path against the copying round-trip a caller without this
264
+ protocol would naturally write — **this script's own measurement, on the
265
+ machine that built this page: at 256 MB, the copies cost over 100x the alias
266
+ path (113.6x in the committed card).** CPU mode (`--host`) needs neither a GPU nor torch: it runs the same
267
+ kernel on CPU threads with plain numpy in and out.
268
+
269
+ ```bash
270
+ python examples/zero_copy_interop.py --host
271
+ python examples/zero_copy_interop.py --device
272
+ ```
273
+ </details>
274
+
275
+ <details>
276
+ <summary>autodiff vs. torch (measured when the script runs — numbers vary by machine)</summary>
277
+
278
+ `examples/autodiff_vs_torch.py` closes the loop on the same one-kernel
279
+ idea: hawk differentiates the traced kernel itself rather than executing a
280
+ separate tape. One RK4 two-body step is traced once, and `hawk.diff.vjp`/
281
+ `jvp` derive a reverse-mode gradient kernel (`vjp`: given a cotangent — a
282
+ weighting of the output — produce the matching weighting of the input) and
283
+ a forward-mode directional-derivative kernel (`jvp`: given a tangent — a
284
+ direction in the input — produce the matching direction in the output) from
285
+ it, published in the same manifest as the primal (the original, undifferentiated
286
+ kernel). `--device` checks both against `torch.autograd.grad` and
287
+ `torch.func.jvp` on the identical physics written in torch, and against a
288
+ float64 finite-difference Jacobian (the matrix of every output's derivative
289
+ with respect to every input, approximated numerically) so the check does
290
+ not rest on torch alone; every plane (one array per sample) in and out — the
291
+ state, the cotangent, the tangent, both derivative outputs — is a torch CUDA
292
+ tensor crossing through eagle's zero-copy `to_cupy` view, read back from
293
+ torch's own storage. It also times hawk's vjp/jvp kernels against torch's,
294
+ and each side's primal alone so the derivative's own overhead is visible —
295
+ **this script's own sweep, on the machine that built this page
296
+ (`benchmarks/autodiff_vs_torch_card.md`): across a batch sweep from 1 to a
297
+ million samples, hawk's vjp measured roughly 90-550x faster per call than
298
+ `torch.autograd.grad`, and hawk's jvp roughly 60-780x faster than
299
+ `torch.func.jvp`.** At small batch those ratios are
300
+ mostly torch's own per-call overhead; at a million samples (about 90x and
301
+ 60x) they are memory traffic — one fused kernel against every intermediate
302
+ written out. hawk's derivatives cost about 1.0-1.5x their own primal, where
303
+ torch's forward-plus-backward pass costs several times its primal alone.
304
+ CPU mode (`--host`) needs no GPU or cupy; its reference is the float64
305
+ finite difference alone, with torch (if installed) added as an optional CPU
306
+ cross-check.
307
+
308
+ ```bash
309
+ python examples/autodiff_vs_torch.py --host
310
+ python examples/autodiff_vs_torch.py --device
311
+ python examples/autodiff_vs_torch.py --sweep
312
+ ```
313
+ </details>
314
+
315
+ ---
316
+ <p align="center">
317
+ <b>hawk</b> write it ·
318
+ <b>eagle</b> run it ·
319
+ <b>aether</b> the numerics core ·
320
+ <b>raptor</b> the shared contracts (this repo) —
321
+ <a href="https://amasat01.github.io/">the RAPTOR family</a>
322
+ </p>
323
+
324
+ Apache-2.0 (see [`LICENSE`](https://github.com/amasat01/raptor/blob/main/LICENSE) and
325
+ [`NOTICE`](https://github.com/amasat01/raptor/blob/main/NOTICE)) · cite via "Cite this repository"
326
+ (`CITATION.cff`; each tagged release is archived on Zenodo with its own DOI once the first one exists) · built to
327
+ make GPU computing accessible on modest hardware, for research and education. Collaboration is the point, and a
328
+ citation is the currency — get in touch.