pyzag 0.9.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.
pyzag-0.9.0/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright 2024, UChicago Argonne, LLC
2
+ All Rights Reserved
3
+ Software Name: pyzag
4
+ By: Argonne National Laboratory
5
+ OPEN SOURCE LICENSE (MIT)
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
pyzag-0.9.0/PKG-INFO ADDED
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyzag
3
+ Version: 0.9.0
4
+ Summary: A Python package for efficiently solving and taking derivatives of systems of recursive nonlinear equations
5
+ Author-email: Mark Messner <messner@anl.gov>
6
+ Project-URL: Homepage, https://github.com/applied-material-modeling/pyzag
7
+ Project-URL: Issues, https://github.com/applied-material-modeling/pyzag/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+
15
+ # pyzag
16
+
17
+
18
+ [![Documentation](https://github.com/applied-material-modeling/pyzag/actions/workflows/build_docs.yml/badge.svg?branch=main)](https://applied-material-modeling.github.io/pyzag/) [![Testing](https://github.com/applied-material-modeling/pyzag/actions/workflows/run_tests.yml/badge.svg?branch=main)](https://github.com/applied-material-modeling/pyzag/actions/workflows/run_tests.yml) [![Code formatting](https://github.com/applied-material-modeling/pyzag/actions/workflows/formatting_check.yml/badge.svg?branch=main)](https://github.com/applied-material-modeling/pyzag/actions/workflows/formatting_check.yml)
19
+
20
+ pyzag is a library for efficiently training generic models defined with a recursive nonlinear function. Full documentation is available [here](https://applied-material-modeling.github.io/pyzag/).
21
+
22
+ The library is available as open source code with an [MIT license](https://raw.githubusercontent.com/applied-material-modeling/pyzag/main/LICENSE).
23
+
24
+ ## Nonlinear recursive functions
25
+
26
+ A nonlinear recursive function has the form
27
+
28
+ $$f\left(x_{i-1}, x_i; p\right) =0 \, \forall i \in \left(1,2,\ldots,n \right)$$
29
+
30
+ with $x$ the model *state* (the unknowns to solve for) and $p$ the model *parameters*. Given the model and an *initial condition* $x_0$ we can define a sequence $\mathcal{X} = \left(x_0, x_1, \ldots, x_n \right)$ by recursively solving the nonlinear equation for $x_n$.
31
+
32
+ While this form seems abstract, it actually describes a large number of interesting and useful models. For example, consider the ordinary differential equation defined by
33
+
34
+ $$\dot{x} = g\left(x; p \right)$$
35
+
36
+ $$x(0) = x_0$$
37
+
38
+ We can convert this into a nonlinear recursive equation by applying a numerical time integration scheme, for example the [backward Euler method](https://en.wikipedia.org/wiki/Backward_Euler_method):
39
+
40
+ $$x_{i} = x_{i-1} + g(x_i; p) \Delta t_i $$
41
+
42
+ This algebraic equation has our standard form for a nonlinear recursive model:
43
+
44
+ $$f\left(x_{i-1}, x_i; p \right) = x_i - x_{i-1} - g(x_i; p) \Delta t_i $$
45
+
46
+ However, defining our time series with an algebraic equation, rather than a differential equation, provides access to a range of models that cannot be expressed as ODEs, for example difference equations.
47
+
48
+ ## Training building blocks
49
+
50
+ The goal of training is basically to find the parameters $p$ for a nonlinear recursive function $f$ and initial condition $x_0$ such that the resulting sequence $\mathcal{X}$ best matches a target series $\hat{\mathcal{X}}$. At a minimum to train a model we need to efficiently generate the time series $\mathcal{X}$ for different parameter values and, often, for multiple targets. Additionally, we often need the derivative of the sequence $\mathcal{X}$ with respect to the model parameters $p$.
51
+
52
+ pyzag provides a few building block methods for efficiently generating sequences and their derivatives:
53
+
54
+ 1. pyzag can vectorize simulating the sequences both for independent instantiations of the same model (i.e. batch vectorization) but also by vectorizing over some number of steps $i$. [This paper](https://arxiv.org/abs/2310.08649) describes the basic idea, but pyzag extends the concept to general nonlinear recursive models. The advantage of the approach is that it can increase the calculation bandwith if batch parallelism alone is not enough to fully utilize the compute device.
55
+ 2. pyzag implements the parameter gradient calculation with the adjoint method. For long sequences this approach is much more memory efficient compared to automatic differentiation and is also generally more computationally efficient.
56
+ 3. pyzag also provides several methods for solving the resulting batched, time-chunked nonlinear and linear equations and predictors for starting the nonlinear solves based on previously simulated pieces of the sequence.
57
+
58
+ ## Deterministic and stochastic models
59
+
60
+ pyzag is built on top of [PyTorch](https://pytorch.org/), integrating the adjoint calculation into PyTorch AD. Users can seemlessly define and train deterministic models using PyTorch primitives.
61
+
62
+ The library also provides helper classes to convert a deterministic model, defined as a nonlinear recursive relation implemented with a PyTorch model, into a statistical model using the [pyro](https://pyro.ai/) library. Specifically, pyzag provides methods for automatically converting the deterministic model to a stochastic model by replacing determinsitc parameters with prior distributions as well as methods for converting models into a hierarchical statistical format to provide dependence across multiple sequences.
pyzag-0.9.0/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # pyzag
2
+
3
+
4
+ [![Documentation](https://github.com/applied-material-modeling/pyzag/actions/workflows/build_docs.yml/badge.svg?branch=main)](https://applied-material-modeling.github.io/pyzag/) [![Testing](https://github.com/applied-material-modeling/pyzag/actions/workflows/run_tests.yml/badge.svg?branch=main)](https://github.com/applied-material-modeling/pyzag/actions/workflows/run_tests.yml) [![Code formatting](https://github.com/applied-material-modeling/pyzag/actions/workflows/formatting_check.yml/badge.svg?branch=main)](https://github.com/applied-material-modeling/pyzag/actions/workflows/formatting_check.yml)
5
+
6
+ pyzag is a library for efficiently training generic models defined with a recursive nonlinear function. Full documentation is available [here](https://applied-material-modeling.github.io/pyzag/).
7
+
8
+ The library is available as open source code with an [MIT license](https://raw.githubusercontent.com/applied-material-modeling/pyzag/main/LICENSE).
9
+
10
+ ## Nonlinear recursive functions
11
+
12
+ A nonlinear recursive function has the form
13
+
14
+ $$f\left(x_{i-1}, x_i; p\right) =0 \, \forall i \in \left(1,2,\ldots,n \right)$$
15
+
16
+ with $x$ the model *state* (the unknowns to solve for) and $p$ the model *parameters*. Given the model and an *initial condition* $x_0$ we can define a sequence $\mathcal{X} = \left(x_0, x_1, \ldots, x_n \right)$ by recursively solving the nonlinear equation for $x_n$.
17
+
18
+ While this form seems abstract, it actually describes a large number of interesting and useful models. For example, consider the ordinary differential equation defined by
19
+
20
+ $$\dot{x} = g\left(x; p \right)$$
21
+
22
+ $$x(0) = x_0$$
23
+
24
+ We can convert this into a nonlinear recursive equation by applying a numerical time integration scheme, for example the [backward Euler method](https://en.wikipedia.org/wiki/Backward_Euler_method):
25
+
26
+ $$x_{i} = x_{i-1} + g(x_i; p) \Delta t_i $$
27
+
28
+ This algebraic equation has our standard form for a nonlinear recursive model:
29
+
30
+ $$f\left(x_{i-1}, x_i; p \right) = x_i - x_{i-1} - g(x_i; p) \Delta t_i $$
31
+
32
+ However, defining our time series with an algebraic equation, rather than a differential equation, provides access to a range of models that cannot be expressed as ODEs, for example difference equations.
33
+
34
+ ## Training building blocks
35
+
36
+ The goal of training is basically to find the parameters $p$ for a nonlinear recursive function $f$ and initial condition $x_0$ such that the resulting sequence $\mathcal{X}$ best matches a target series $\hat{\mathcal{X}}$. At a minimum to train a model we need to efficiently generate the time series $\mathcal{X}$ for different parameter values and, often, for multiple targets. Additionally, we often need the derivative of the sequence $\mathcal{X}$ with respect to the model parameters $p$.
37
+
38
+ pyzag provides a few building block methods for efficiently generating sequences and their derivatives:
39
+
40
+ 1. pyzag can vectorize simulating the sequences both for independent instantiations of the same model (i.e. batch vectorization) but also by vectorizing over some number of steps $i$. [This paper](https://arxiv.org/abs/2310.08649) describes the basic idea, but pyzag extends the concept to general nonlinear recursive models. The advantage of the approach is that it can increase the calculation bandwith if batch parallelism alone is not enough to fully utilize the compute device.
41
+ 2. pyzag implements the parameter gradient calculation with the adjoint method. For long sequences this approach is much more memory efficient compared to automatic differentiation and is also generally more computationally efficient.
42
+ 3. pyzag also provides several methods for solving the resulting batched, time-chunked nonlinear and linear equations and predictors for starting the nonlinear solves based on previously simulated pieces of the sequence.
43
+
44
+ ## Deterministic and stochastic models
45
+
46
+ pyzag is built on top of [PyTorch](https://pytorch.org/), integrating the adjoint calculation into PyTorch AD. Users can seemlessly define and train deterministic models using PyTorch primitives.
47
+
48
+ The library also provides helper classes to convert a deterministic model, defined as a nonlinear recursive relation implemented with a PyTorch model, into a statistical model using the [pyro](https://pyro.ai/) library. Specifically, pyzag provides methods for automatically converting the deterministic model to a stochastic model by replacing determinsitc parameters with prior distributions as well as methods for converting models into a hierarchical statistical format to provide dependence across multiple sequences.
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pyzag"
7
+ version = "0.9.0"
8
+ authors = [
9
+ { name="Mark Messner", email="messner@anl.gov" },
10
+ ]
11
+ description = "A Python package for efficiently solving and taking derivatives of systems of recursive nonlinear equations"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/applied-material-modeling/pyzag"
22
+ Issues = "https://github.com/applied-material-modeling/pyzag/issues"
@@ -0,0 +1,23 @@
1
+ # Copyright 2024, UChicago Argonne, LLC
2
+ # All Rights Reserved
3
+ # Software Name: pyzag
4
+ # By: Argonne National Laboratory
5
+ # OPEN SOURCE LICENSE (MIT)
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ # THE SOFTWARE.