hybrid-variational-compiler 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ian Mackey
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,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: hybrid-variational-compiler
3
+ Version: 0.1.0
4
+ Summary: Compile differentiable hybrid ODEs into variational kernels (STM, sensitivities, events and jumps) for fast-numerical-integration
5
+ Author: Ian Mackey
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/idm23/hybrid-variational-compiler
8
+ Project-URL: Repository, https://github.com/idm23/hybrid-variational-compiler
9
+ Project-URL: Issues, https://github.com/idm23/hybrid-variational-compiler/issues
10
+ Keywords: code-generation,automatic-differentiation,state-transition-matrix,sensitivity-analysis,hybrid-systems,ode,sympy
11
+ Classifier: Development Status :: 1 - Planning
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
16
+ Classifier: Topic :: Software Development :: Code Generators
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy>=2.0
21
+ Requires-Dist: sympy>=1.12
22
+ Dynamic: license-file
23
+
24
+ # hybrid-variational-compiler
25
+
26
+ Compile differentiable hybrid ODEs into variational kernels. A system is
27
+ time, states and parameters, the rates `f(t, x, p)`, and optionally event
28
+ functions `g(t, x, p)` with jump maps. It is written in SymPy or built
29
+ directly as a graph. The compiler turns it into C kernels that
30
+ [fast-numerical-integration](https://github.com/idm23/fast-numerical-integration)
31
+ (FNI) integrates:
32
+
33
+ - the rates `f`, and their Jacobians `df/dx` and `df/dp`;
34
+ - the right-hand side of the state transition matrix and of the parameter
35
+ sensitivities, for the entries its sparsity allows;
36
+ - event values and gradients, and the jumps of the STM where an event
37
+ changes the mode (saltation matrices);
38
+
39
+ compiled once and cached.
40
+
41
+ > **Status: planning.** The package installs; nothing is implemented yet. The
42
+ > first code comes out of
43
+ > [auto-optimal-control](https://github.com/idm23/auto-optimal-control), whose
44
+ > tape and generic code generation move here.
45
+
46
+ ## Why a graph, not SymPy
47
+
48
+ SymPy is a good language for writing dynamics in and a poor one for computing
49
+ on them at scale. Its `diff`, `simplify`, `subs` and `cse` work on expression
50
+ trees. A six-joint arm's joint torques are about a thousand operations as a
51
+ graph and a hundred thousand written out, and `trigsimp` on a low-thrust
52
+ transfer's rates runs for over ten minutes. So SymPy expressions are recorded
53
+ once into a graph, with equal steps shared, and every derivative and every
54
+ line of C comes from the graph. Recording memoizes on SymPy's nodes, so an
55
+ expression built with shared subexpressions, such as a recursion, records at
56
+ its graph size as long as nothing expands it first.
57
+
58
+ The graph is the interface; SymPy is one way to build it. A step can also be
59
+ an opaque function with a derivative rule (an ephemeris interpolant, a table
60
+ lookup, a user's C function and its Jacobian, a small network), so data and
61
+ learned models sit in the same kernels as the closed-form physics.
62
+
63
+ ## Goals
64
+
65
+ 1. **Variational propagation.** The STM, parameter sensitivities,
66
+ Jacobian-vector products, adjoint (reverse-mode) sensitivities for many
67
+ parameters, and second-order state transition tensors.
68
+ 2. **Vector-Jacobian products as kernels.** The costate equations of an
69
+ indirect method, `lambda' = -(df/dx)^T lambda - L_x`, are a reverse pass
70
+ over the graph, so they never need to be written out, and indirect optimal
71
+ control scales to large force models and robots.
72
+ 3. **Hybrid systems.** Guards, mode switches, jump maps and the STM's jumps
73
+ at them, once and correctly, for bang-bang arcs, eclipses, impulsive
74
+ maneuvers and contacts alike.
75
+ 4. **Opaque steps.** Interpolants, tables, user C functions and networks,
76
+ each with a value and a derivative rule that print as C.
77
+ 5. **Structure.** Sparse Jacobians and STMs, forward or reverse mode chosen
78
+ by cost, parameters fixed at compile time when they are constant, and many
79
+ instances propagated in parallel without the GIL.
80
+ 6. **One semantics, checked.** An interpreter for the graph, and generated C
81
+ checked against it and against finite differences, so that comparisons
82
+ with external references (Orekit, Pinocchio) test the models, not the
83
+ compiler.
84
+ 7. **Shipping kernels.** Prebuilt kernels in wheels, so a user needs no C
85
+ compiler, and standalone C with no Python and no allocation, to run on a
86
+ robot.
87
+
88
+ ## Non-goals
89
+
90
+ - Optimization solvers (auto-optimal-control and white-whale-robotics own
91
+ them).
92
+ - General array programming and GPUs.
93
+ - Domain physics: forces belong to
94
+ [analytical-astro-prop](https://github.com/idm23/analytical-astro-prop),
95
+ rigid-body dynamics to
96
+ [white-whale-robotics](https://github.com/idm23/white-whale-robotics), and
97
+ Pontryagin's principle to auto-optimal-control.
98
+
99
+ ## Where it sits
100
+
101
+ ```
102
+ fast-numerical-integration integrates the kernels
103
+ hybrid-variational-compiler graph -> compiled variational kernels
104
+ analytical-astro-prop orbital force models
105
+ auto-optimal-control Pontryagin's principle, shooting
106
+ white-whale-robotics motion planning
107
+ ```
108
+
109
+ ## Installation
110
+
111
+ ```bash
112
+ git clone https://github.com/idm23/hybrid-variational-compiler
113
+ cd hybrid-variational-compiler
114
+ uv sync
115
+ uv run pytest
116
+ ```
@@ -0,0 +1,93 @@
1
+ # hybrid-variational-compiler
2
+
3
+ Compile differentiable hybrid ODEs into variational kernels. A system is
4
+ time, states and parameters, the rates `f(t, x, p)`, and optionally event
5
+ functions `g(t, x, p)` with jump maps. It is written in SymPy or built
6
+ directly as a graph. The compiler turns it into C kernels that
7
+ [fast-numerical-integration](https://github.com/idm23/fast-numerical-integration)
8
+ (FNI) integrates:
9
+
10
+ - the rates `f`, and their Jacobians `df/dx` and `df/dp`;
11
+ - the right-hand side of the state transition matrix and of the parameter
12
+ sensitivities, for the entries its sparsity allows;
13
+ - event values and gradients, and the jumps of the STM where an event
14
+ changes the mode (saltation matrices);
15
+
16
+ compiled once and cached.
17
+
18
+ > **Status: planning.** The package installs; nothing is implemented yet. The
19
+ > first code comes out of
20
+ > [auto-optimal-control](https://github.com/idm23/auto-optimal-control), whose
21
+ > tape and generic code generation move here.
22
+
23
+ ## Why a graph, not SymPy
24
+
25
+ SymPy is a good language for writing dynamics in and a poor one for computing
26
+ on them at scale. Its `diff`, `simplify`, `subs` and `cse` work on expression
27
+ trees. A six-joint arm's joint torques are about a thousand operations as a
28
+ graph and a hundred thousand written out, and `trigsimp` on a low-thrust
29
+ transfer's rates runs for over ten minutes. So SymPy expressions are recorded
30
+ once into a graph, with equal steps shared, and every derivative and every
31
+ line of C comes from the graph. Recording memoizes on SymPy's nodes, so an
32
+ expression built with shared subexpressions, such as a recursion, records at
33
+ its graph size as long as nothing expands it first.
34
+
35
+ The graph is the interface; SymPy is one way to build it. A step can also be
36
+ an opaque function with a derivative rule (an ephemeris interpolant, a table
37
+ lookup, a user's C function and its Jacobian, a small network), so data and
38
+ learned models sit in the same kernels as the closed-form physics.
39
+
40
+ ## Goals
41
+
42
+ 1. **Variational propagation.** The STM, parameter sensitivities,
43
+ Jacobian-vector products, adjoint (reverse-mode) sensitivities for many
44
+ parameters, and second-order state transition tensors.
45
+ 2. **Vector-Jacobian products as kernels.** The costate equations of an
46
+ indirect method, `lambda' = -(df/dx)^T lambda - L_x`, are a reverse pass
47
+ over the graph, so they never need to be written out, and indirect optimal
48
+ control scales to large force models and robots.
49
+ 3. **Hybrid systems.** Guards, mode switches, jump maps and the STM's jumps
50
+ at them, once and correctly, for bang-bang arcs, eclipses, impulsive
51
+ maneuvers and contacts alike.
52
+ 4. **Opaque steps.** Interpolants, tables, user C functions and networks,
53
+ each with a value and a derivative rule that print as C.
54
+ 5. **Structure.** Sparse Jacobians and STMs, forward or reverse mode chosen
55
+ by cost, parameters fixed at compile time when they are constant, and many
56
+ instances propagated in parallel without the GIL.
57
+ 6. **One semantics, checked.** An interpreter for the graph, and generated C
58
+ checked against it and against finite differences, so that comparisons
59
+ with external references (Orekit, Pinocchio) test the models, not the
60
+ compiler.
61
+ 7. **Shipping kernels.** Prebuilt kernels in wheels, so a user needs no C
62
+ compiler, and standalone C with no Python and no allocation, to run on a
63
+ robot.
64
+
65
+ ## Non-goals
66
+
67
+ - Optimization solvers (auto-optimal-control and white-whale-robotics own
68
+ them).
69
+ - General array programming and GPUs.
70
+ - Domain physics: forces belong to
71
+ [analytical-astro-prop](https://github.com/idm23/analytical-astro-prop),
72
+ rigid-body dynamics to
73
+ [white-whale-robotics](https://github.com/idm23/white-whale-robotics), and
74
+ Pontryagin's principle to auto-optimal-control.
75
+
76
+ ## Where it sits
77
+
78
+ ```
79
+ fast-numerical-integration integrates the kernels
80
+ hybrid-variational-compiler graph -> compiled variational kernels
81
+ analytical-astro-prop orbital force models
82
+ auto-optimal-control Pontryagin's principle, shooting
83
+ white-whale-robotics motion planning
84
+ ```
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ git clone https://github.com/idm23/hybrid-variational-compiler
90
+ cd hybrid-variational-compiler
91
+ uv sync
92
+ uv run pytest
93
+ ```
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "hybrid-variational-compiler"
7
+ version = "0.1.0"
8
+ description = "Compile differentiable hybrid ODEs into variational kernels (STM, sensitivities, events and jumps) for fast-numerical-integration"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Ian Mackey" }]
13
+ requires-python = ">=3.11"
14
+ keywords = ["code-generation", "automatic-differentiation", "state-transition-matrix", "sensitivity-analysis", "hybrid-systems", "ode", "sympy"]
15
+ classifiers = [
16
+ "Development Status :: 1 - Planning",
17
+ "Intended Audience :: Science/Research",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Topic :: Scientific/Engineering :: Mathematics",
21
+ "Topic :: Software Development :: Code Generators",
22
+ ]
23
+ dependencies = [
24
+ "numpy>=2.0",
25
+ "sympy>=1.12",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/idm23/hybrid-variational-compiler"
30
+ Repository = "https://github.com/idm23/hybrid-variational-compiler"
31
+ Issues = "https://github.com/idm23/hybrid-variational-compiler/issues"
32
+
33
+ [dependency-groups]
34
+ dev = ["pytest>=8.0"]
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+ addopts = "--import-mode=importlib"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ """Compile differentiable hybrid ODEs into variational kernels.
2
+
3
+ A system is time, states and parameters, the rates ``f(t, x, p)``, and
4
+ optionally event functions ``g(t, x, p)`` with jump maps. It is written in
5
+ SymPy or built directly as a graph, and is compiled to C kernels for ``f``,
6
+ its Jacobians, the state transition matrix, parameter sensitivities, event
7
+ values and gradients, and the STM's jumps at events, which
8
+ ``fast_numerical_integration`` integrates.
9
+ """
10
+
11
+ from importlib.metadata import version as _version
12
+
13
+ __version__ = _version("hybrid-variational-compiler")
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: hybrid-variational-compiler
3
+ Version: 0.1.0
4
+ Summary: Compile differentiable hybrid ODEs into variational kernels (STM, sensitivities, events and jumps) for fast-numerical-integration
5
+ Author: Ian Mackey
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/idm23/hybrid-variational-compiler
8
+ Project-URL: Repository, https://github.com/idm23/hybrid-variational-compiler
9
+ Project-URL: Issues, https://github.com/idm23/hybrid-variational-compiler/issues
10
+ Keywords: code-generation,automatic-differentiation,state-transition-matrix,sensitivity-analysis,hybrid-systems,ode,sympy
11
+ Classifier: Development Status :: 1 - Planning
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
16
+ Classifier: Topic :: Software Development :: Code Generators
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy>=2.0
21
+ Requires-Dist: sympy>=1.12
22
+ Dynamic: license-file
23
+
24
+ # hybrid-variational-compiler
25
+
26
+ Compile differentiable hybrid ODEs into variational kernels. A system is
27
+ time, states and parameters, the rates `f(t, x, p)`, and optionally event
28
+ functions `g(t, x, p)` with jump maps. It is written in SymPy or built
29
+ directly as a graph. The compiler turns it into C kernels that
30
+ [fast-numerical-integration](https://github.com/idm23/fast-numerical-integration)
31
+ (FNI) integrates:
32
+
33
+ - the rates `f`, and their Jacobians `df/dx` and `df/dp`;
34
+ - the right-hand side of the state transition matrix and of the parameter
35
+ sensitivities, for the entries its sparsity allows;
36
+ - event values and gradients, and the jumps of the STM where an event
37
+ changes the mode (saltation matrices);
38
+
39
+ compiled once and cached.
40
+
41
+ > **Status: planning.** The package installs; nothing is implemented yet. The
42
+ > first code comes out of
43
+ > [auto-optimal-control](https://github.com/idm23/auto-optimal-control), whose
44
+ > tape and generic code generation move here.
45
+
46
+ ## Why a graph, not SymPy
47
+
48
+ SymPy is a good language for writing dynamics in and a poor one for computing
49
+ on them at scale. Its `diff`, `simplify`, `subs` and `cse` work on expression
50
+ trees. A six-joint arm's joint torques are about a thousand operations as a
51
+ graph and a hundred thousand written out, and `trigsimp` on a low-thrust
52
+ transfer's rates runs for over ten minutes. So SymPy expressions are recorded
53
+ once into a graph, with equal steps shared, and every derivative and every
54
+ line of C comes from the graph. Recording memoizes on SymPy's nodes, so an
55
+ expression built with shared subexpressions, such as a recursion, records at
56
+ its graph size as long as nothing expands it first.
57
+
58
+ The graph is the interface; SymPy is one way to build it. A step can also be
59
+ an opaque function with a derivative rule (an ephemeris interpolant, a table
60
+ lookup, a user's C function and its Jacobian, a small network), so data and
61
+ learned models sit in the same kernels as the closed-form physics.
62
+
63
+ ## Goals
64
+
65
+ 1. **Variational propagation.** The STM, parameter sensitivities,
66
+ Jacobian-vector products, adjoint (reverse-mode) sensitivities for many
67
+ parameters, and second-order state transition tensors.
68
+ 2. **Vector-Jacobian products as kernels.** The costate equations of an
69
+ indirect method, `lambda' = -(df/dx)^T lambda - L_x`, are a reverse pass
70
+ over the graph, so they never need to be written out, and indirect optimal
71
+ control scales to large force models and robots.
72
+ 3. **Hybrid systems.** Guards, mode switches, jump maps and the STM's jumps
73
+ at them, once and correctly, for bang-bang arcs, eclipses, impulsive
74
+ maneuvers and contacts alike.
75
+ 4. **Opaque steps.** Interpolants, tables, user C functions and networks,
76
+ each with a value and a derivative rule that print as C.
77
+ 5. **Structure.** Sparse Jacobians and STMs, forward or reverse mode chosen
78
+ by cost, parameters fixed at compile time when they are constant, and many
79
+ instances propagated in parallel without the GIL.
80
+ 6. **One semantics, checked.** An interpreter for the graph, and generated C
81
+ checked against it and against finite differences, so that comparisons
82
+ with external references (Orekit, Pinocchio) test the models, not the
83
+ compiler.
84
+ 7. **Shipping kernels.** Prebuilt kernels in wheels, so a user needs no C
85
+ compiler, and standalone C with no Python and no allocation, to run on a
86
+ robot.
87
+
88
+ ## Non-goals
89
+
90
+ - Optimization solvers (auto-optimal-control and white-whale-robotics own
91
+ them).
92
+ - General array programming and GPUs.
93
+ - Domain physics: forces belong to
94
+ [analytical-astro-prop](https://github.com/idm23/analytical-astro-prop),
95
+ rigid-body dynamics to
96
+ [white-whale-robotics](https://github.com/idm23/white-whale-robotics), and
97
+ Pontryagin's principle to auto-optimal-control.
98
+
99
+ ## Where it sits
100
+
101
+ ```
102
+ fast-numerical-integration integrates the kernels
103
+ hybrid-variational-compiler graph -> compiled variational kernels
104
+ analytical-astro-prop orbital force models
105
+ auto-optimal-control Pontryagin's principle, shooting
106
+ white-whale-robotics motion planning
107
+ ```
108
+
109
+ ## Installation
110
+
111
+ ```bash
112
+ git clone https://github.com/idm23/hybrid-variational-compiler
113
+ cd hybrid-variational-compiler
114
+ uv sync
115
+ uv run pytest
116
+ ```
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/hybrid_variational_compiler/__init__.py
5
+ src/hybrid_variational_compiler.egg-info/PKG-INFO
6
+ src/hybrid_variational_compiler.egg-info/SOURCES.txt
7
+ src/hybrid_variational_compiler.egg-info/dependency_links.txt
8
+ src/hybrid_variational_compiler.egg-info/requires.txt
9
+ src/hybrid_variational_compiler.egg-info/top_level.txt
10
+ tests/test_package.py
@@ -0,0 +1,9 @@
1
+ """The package installs and imports."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ import hybrid_variational_compiler
6
+
7
+
8
+ def test_version_matches_the_installed_distribution():
9
+ assert hybrid_variational_compiler.__version__ == version("hybrid-variational-compiler")