pyrevolve


Namepyrevolve JSON
Version 2.2.3 PyPI version JSON
download
home_pagehttps://github.com/opesci/pyrevolve/
SummaryPython wrapper for Revolve checkpointing
upload_time2023-08-25 16:07:31
maintainer
docs_urlNone
authorImperial College London
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # Checkpointing

The adjoint computation of an unsteady nonlinear primal function requires the
full primal trajectory in reverse temporal order. Storing this can exceed the
available memory. In that case, Checkpointing can be used to store the state
only at carefully selected points in time. From there, the forward computation
can be restarted to recompute lost sections of the trajectory when they are
needed during the adjoint computation. This is always a tradeoff between memory
and runtime. The classic and provably optimal way to do this for a known number
of time steps is [Revolve](https://doi.org/10.1145/347837.347846), and there are other algorithms for optimal online
checkpointing if the number of steps is unknown a priori, or for multistage
checkpointing if there are multiple layers of storage, e.g. memory and hard
drive.
![Visual demo of checkpointing](https://raw.githubusercontent.com/opesci/pyrevolve/master/examples/checkpointing_demo.gif)

# PyRevolve

The pyrevolve library contains two parts: crevolve, which is a thin Python
wrapper around a previously published [C++ implementation](https://www.mathematik.hu-berlin.de/de/forschung/forschungsgebiete/mathematische-optimierung/andrea-walther/walther-software), and pyrevolve
itself, which sits on top of crevolve and manages data and computation
management for the user.

The C++ files in this package are slightly modified to play more nicely with
Python, but the original is available from the link below. In addition, there
is a C wrapper around the C++ library, to simplify the interface with Python.
This C wrapper is taken from [libadjoint](https://bitbucket.org/dolfin-adjoint/libadjoint).



# Installation
Since PyRevolve is distributed as source, you must have a functional C/C++
compiler in your environment before trying to install PyRevolve. The
installation procedure respects the standard environment variables
like CC/CXX.

The simplest installation is through pip by simply doing:

    pip install pyrevolve

If you would like to have a local development copy that you can edit,
clone the repo and call the following command in the home directory:

    pip install -e .

If you face any installation issues, first check that you really do
have a functional C++ compiler, either available as `g++` in the path
or pointed to by the environment variable `CXX`. If this is not the
reason, please raise a issue here or on
[this](https://opesci-slackin.now.sh) Slack channel. 
# Usage

There are two wrappers: a _classic_ wrapper that follows the behaviour of Revolve
as described in the papers, and leaves the data mangement, the actual copying
of data, and the calling of operators to the user. An example of how to use it
can be executed by calling

    python examples/use_classic.py
    
The other, _modernised_ wrapper, takes care of all this. The user creates a
Revolver object, and passes a forward operator, reverse operator, and
checkpoint operator to it. The Revolver provides two important methods:
`apply_forward`, and `apply_reverse`. A call to `apply_forward` executes the
forward computation, while creating the necessary checkpoints for the reverse
computation. After this, a user may also call the `apply_reverse` method to
compute the adjoints.

For this to work, the user is responsible that the operators have an `apply()`
method that takes arguments `t_start` and `t_end`, and that the checkpoint
object has a property `size` to report the size of one checkpoint, and methods
`load(ptr)` and `save(ptr)` that deep-copy all time-dependent live data into
a location given in `ptr`.

An example of this can be found here:

    python examples/use_modernised.py
    

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opesci/pyrevolve/",
    "name": "pyrevolve",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Imperial College London",
    "author_email": "opesci@imperial.ac.uk",
    "download_url": "https://files.pythonhosted.org/packages/42/fb/9a912de9bbd6ea2fe9876fc3dcfe18e70ab6568a69f5a75a216f80fe9760/pyrevolve-2.2.3.tar.gz",
    "platform": null,
    "description": "# Checkpointing\n\nThe adjoint computation of an unsteady nonlinear primal function requires the\nfull primal trajectory in reverse temporal order. Storing this can exceed the\navailable memory. In that case, Checkpointing can be used to store the state\nonly at carefully selected points in time. From there, the forward computation\ncan be restarted to recompute lost sections of the trajectory when they are\nneeded during the adjoint computation. This is always a tradeoff between memory\nand runtime. The classic and provably optimal way to do this for a known number\nof time steps is [Revolve](https://doi.org/10.1145/347837.347846), and there are other algorithms for optimal online\ncheckpointing if the number of steps is unknown a priori, or for multistage\ncheckpointing if there are multiple layers of storage, e.g. memory and hard\ndrive.\n![Visual demo of checkpointing](https://raw.githubusercontent.com/opesci/pyrevolve/master/examples/checkpointing_demo.gif)\n\n# PyRevolve\n\nThe pyrevolve library contains two parts: crevolve, which is a thin Python\nwrapper around a previously published [C++ implementation](https://www.mathematik.hu-berlin.de/de/forschung/forschungsgebiete/mathematische-optimierung/andrea-walther/walther-software), and pyrevolve\nitself, which sits on top of crevolve and manages data and computation\nmanagement for the user.\n\nThe C++ files in this package are slightly modified to play more nicely with\nPython, but the original is available from the link below. In addition, there\nis a C wrapper around the C++ library, to simplify the interface with Python.\nThis C wrapper is taken from [libadjoint](https://bitbucket.org/dolfin-adjoint/libadjoint).\n\n\n\n# Installation\nSince PyRevolve is distributed as source, you must have a functional C/C++\ncompiler in your environment before trying to install PyRevolve. The\ninstallation procedure respects the standard environment variables\nlike CC/CXX.\n\nThe simplest installation is through pip by simply doing:\n\n    pip install pyrevolve\n\nIf you would like to have a local development copy that you can edit,\nclone the repo and call the following command in the home directory:\n\n    pip install -e .\n\nIf you face any installation issues, first check that you really do\nhave a functional C++ compiler, either available as `g++` in the path\nor pointed to by the environment variable `CXX`. If this is not the\nreason, please raise a issue here or on\n[this](https://opesci-slackin.now.sh) Slack channel. \n# Usage\n\nThere are two wrappers: a _classic_ wrapper that follows the behaviour of Revolve\nas described in the papers, and leaves the data mangement, the actual copying\nof data, and the calling of operators to the user. An example of how to use it\ncan be executed by calling\n\n    python examples/use_classic.py\n    \nThe other, _modernised_ wrapper, takes care of all this. The user creates a\nRevolver object, and passes a forward operator, reverse operator, and\ncheckpoint operator to it. The Revolver provides two important methods:\n`apply_forward`, and `apply_reverse`. A call to `apply_forward` executes the\nforward computation, while creating the necessary checkpoints for the reverse\ncomputation. After this, a user may also call the `apply_reverse` method to\ncompute the adjoints.\n\nFor this to work, the user is responsible that the operators have an `apply()`\nmethod that takes arguments `t_start` and `t_end`, and that the checkpoint\nobject has a property `size` to report the size of one checkpoint, and methods\n`load(ptr)` and `save(ptr)` that deep-copy all time-dependent live data into\na location given in `ptr`.\n\nAn example of this can be found here:\n\n    python examples/use_modernised.py\n    \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python wrapper for Revolve checkpointing",
    "version": "2.2.3",
    "project_urls": {
        "Homepage": "https://github.com/opesci/pyrevolve/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "42fb9a912de9bbd6ea2fe9876fc3dcfe18e70ab6568a69f5a75a216f80fe9760",
                "md5": "be974d80fda67a06a336a16dbfad2fbd",
                "sha256": "c019e85280da1038f6d746208faec621a99c72439b8ee9b9db0740bc51b14b87"
            },
            "downloads": -1,
            "filename": "pyrevolve-2.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "be974d80fda67a06a336a16dbfad2fbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 254842,
            "upload_time": "2023-08-25T16:07:31",
            "upload_time_iso_8601": "2023-08-25T16:07:31.777761Z",
            "url": "https://files.pythonhosted.org/packages/42/fb/9a912de9bbd6ea2fe9876fc3dcfe18e70ab6568a69f5a75a216f80fe9760/pyrevolve-2.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-25 16:07:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opesci",
    "github_project": "pyrevolve",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyrevolve"
}
        
Elapsed time: 0.16717s