torchode 0.1.9__tar.gz → 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 (36) hide show
  1. {torchode-0.1.9 → torchode-0.2.0}/CHANGELOG.md +6 -0
  2. {torchode-0.1.9 → torchode-0.2.0}/PKG-INFO +2 -6
  3. {torchode-0.1.9 → torchode-0.2.0}/README.md +0 -3
  4. {torchode-0.1.9 → torchode-0.2.0}/pyproject.toml +1 -4
  5. {torchode-0.1.9 → torchode-0.2.0}/torchode/__init__.py +1 -1
  6. {torchode-0.1.9 → torchode-0.2.0}/torchode/adjoints.py +10 -9
  7. {torchode-0.1.9 → torchode-0.2.0}/.github/workflows/python-package.yml +0 -0
  8. {torchode-0.1.9 → torchode-0.2.0}/.gitignore +0 -0
  9. {torchode-0.1.9 → torchode-0.2.0}/.readthedocs.yaml +0 -0
  10. {torchode-0.1.9 → torchode-0.2.0}/LICENSE +0 -0
  11. {torchode-0.1.9 → torchode-0.2.0}/docs/README.md +0 -0
  12. {torchode-0.1.9 → torchode-0.2.0}/docs/comparison.md +0 -0
  13. {torchode-0.1.9 → torchode-0.2.0}/docs/extra-args.md +0 -0
  14. {torchode-0.1.9 → torchode-0.2.0}/docs/extra-stats.ipynb +0 -0
  15. {torchode-0.1.9 → torchode-0.2.0}/docs/jit.ipynb +0 -0
  16. {torchode-0.1.9 → torchode-0.2.0}/docs/nd-data.md +0 -0
  17. {torchode-0.1.9 → torchode-0.2.0}/docs/requirements.in +0 -0
  18. {torchode-0.1.9 → torchode-0.2.0}/docs/requirements.txt +0 -0
  19. {torchode-0.1.9 → torchode-0.2.0}/docs/step-size-controllers.md +0 -0
  20. {torchode-0.1.9 → torchode-0.2.0}/docs/torchdiffeq.ipynb +0 -0
  21. {torchode-0.1.9 → torchode-0.2.0}/mkdocs.yml +0 -0
  22. {torchode-0.1.9 → torchode-0.2.0}/torchode/interface.py +0 -0
  23. {torchode-0.1.9 → torchode-0.2.0}/torchode/interpolation.py +0 -0
  24. {torchode-0.1.9 → torchode-0.2.0}/torchode/problems.py +0 -0
  25. {torchode-0.1.9 → torchode-0.2.0}/torchode/single_step_methods/__init__.py +0 -0
  26. {torchode-0.1.9 → torchode-0.2.0}/torchode/single_step_methods/base.py +0 -0
  27. {torchode-0.1.9 → torchode-0.2.0}/torchode/single_step_methods/dopri5.py +0 -0
  28. {torchode-0.1.9 → torchode-0.2.0}/torchode/single_step_methods/euler.py +0 -0
  29. {torchode-0.1.9 → torchode-0.2.0}/torchode/single_step_methods/heun.py +0 -0
  30. {torchode-0.1.9 → torchode-0.2.0}/torchode/single_step_methods/runge_kutta.py +0 -0
  31. {torchode-0.1.9 → torchode-0.2.0}/torchode/single_step_methods/tsit5.py +0 -0
  32. {torchode-0.1.9 → torchode-0.2.0}/torchode/solution.py +0 -0
  33. {torchode-0.1.9 → torchode-0.2.0}/torchode/status_codes.py +0 -0
  34. {torchode-0.1.9 → torchode-0.2.0}/torchode/step_size_controllers.py +0 -0
  35. {torchode-0.1.9 → torchode-0.2.0}/torchode/terms.py +0 -0
  36. {torchode-0.1.9 → torchode-0.2.0}/torchode/typing.py +0 -0
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.2.0 - 2023-11-10
9
+
10
+ ### Changed
11
+
12
+ - Removed compatibility with pytorch 1.x
13
+
8
14
  ## 0.1.9 - 2023-08-29
9
15
 
10
16
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: torchode
3
- Version: 0.1.9
3
+ Version: 0.2.0
4
4
  Summary: A parallel ODE solver for PyTorch
5
5
  Author-email: Marten Lienen <m.lienen@tum.de>
6
6
  Requires-Python: >= 3.8
@@ -12,9 +12,8 @@ Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python
14
14
  Requires-Dist: sympy ~= 1.10
15
- Requires-Dist: torch >= 1.11
15
+ Requires-Dist: torch >= 2.0
16
16
  Requires-Dist: torchtyping ~= 0.1.4
17
- Requires-Dist: functorch
18
17
  Requires-Dist: pytest-benchmark ; extra == "benchmark"
19
18
  Requires-Dist: pytest ; extra == "test"
20
19
  Requires-Dist: numpy ~= 1.22 ; extra == "test"
@@ -77,9 +76,6 @@ step_size_controller = to.IntegralController(atol=1e-6, rtol=1e-3, term=term)
77
76
  solver = to.AutoDiffAdjoint(step_method, step_size_controller)
78
77
  jit_solver = torch.compile(solver)
79
78
 
80
- # For pytorch versions < 2.0, use the older TorchScript compiler
81
- #jit_solver = torch.jit.script(solver)
82
-
83
79
  sol = jit_solver.solve(to.InitialValueProblem(y0=y0, t_eval=t_eval))
84
80
  print(sol.stats)
85
81
  # => {'n_f_evals': tensor([26, 26]), 'n_steps': tensor([4, 2]),
@@ -53,9 +53,6 @@ step_size_controller = to.IntegralController(atol=1e-6, rtol=1e-3, term=term)
53
53
  solver = to.AutoDiffAdjoint(step_method, step_size_controller)
54
54
  jit_solver = torch.compile(solver)
55
55
 
56
- # For pytorch versions < 2.0, use the older TorchScript compiler
57
- #jit_solver = torch.jit.script(solver)
58
-
59
56
  sol = jit_solver.solve(to.InitialValueProblem(y0=y0, t_eval=t_eval))
60
57
  print(sol.stats)
61
58
  # => {'n_f_evals': tensor([26, 26]), 'n_steps': tensor([4, 2]),
@@ -19,11 +19,8 @@ classifiers = [
19
19
  ]
20
20
  dependencies = [
21
21
  "sympy ~= 1.10",
22
- "torch >= 1.11",
22
+ "torch >= 2.0",
23
23
  "torchtyping ~= 0.1.4",
24
- # functorch has been integrated into pytorch and this is just a dummy dependency for
25
- # compatibility with pytorch <= 1.13
26
- "functorch",
27
24
  ]
28
25
 
29
26
  [project.optional-dependencies]
@@ -1,6 +1,6 @@
1
1
  """A parallel ODE solver for PyTorch"""
2
2
 
3
- __version__ = "0.1.9"
3
+ __version__ = "0.2.0"
4
4
 
5
5
  from .adjoints import AutoDiffAdjoint, BacksolveAdjoint, JointBacksolveAdjoint
6
6
  from .interface import register_method, solve_ivp
@@ -1,6 +1,5 @@
1
1
  from typing import Any, Dict, Optional
2
2
 
3
- import functorch
4
3
  import torch
5
4
  import torch.nn as nn
6
5
 
@@ -449,22 +448,24 @@ class AugmentedDynamicsTerm(nn.Module):
449
448
  self.vmap_args_dims = vmap_args_dims
450
449
  self.vmap_randomness = vmap_randomness
451
450
 
452
- self.func, self.params, self.buffers = functorch.make_functional_with_buffers(
453
- self.term.f
454
- )
451
+ f = self.term.f
452
+ orig_params = dict(f.named_parameters())
453
+ buffers = dict(f.named_buffers())
454
+ params_names = orig_params.keys()
455
455
 
456
456
  def vjp_single_sample(t_i, y_i, adj_y_i, arg_i):
457
457
  def wrapper(params, t_, y_):
458
+ args = (t_, y_)
458
459
  if self.term.with_args:
459
- return self.func(params, self.buffers, t_, y_, arg_i)
460
- else:
461
- return self.func(params, self.buffers, t_, y_)
460
+ args = args + (arg_i,)
461
+ params_dict = {name: value for name, value in zip(params_names, params)}
462
+ return torch.func.functional_call(f, (params_dict, buffers), args)
462
463
 
463
- dy, vjp = functorch.vjp(wrapper, self.params, t_i, y_i)
464
+ dy, vjp = torch.func.vjp(wrapper, tuple(orig_params.values()), t_i, y_i)
464
465
  vjp_params, vjp_t, vjp_y = vjp(-adj_y_i)
465
466
  return dy, vjp_t, vjp_y, vjp_params
466
467
 
467
- self.vjp_vf = functorch.vmap(
468
+ self.vjp_vf = torch.func.vmap(
468
469
  vjp_single_sample,
469
470
  in_dims=(0, 0, 0, self.vmap_args_dims),
470
471
  randomness=self.vmap_randomness,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes