Giter VIP home page Giter VIP logo

bench_hvp's Introduction

Benchmark Hessian-vector product

This Python repo hosts the code of the blogpost about Hessian-vector products.

Installation

Start by cloning the repo:

$ git clone https://github.com/MatDag/bench_hvp.git
$ cd bench_hvp

We advise working in two separate environments: one environment for the experiments in Jax and another for the PyTorch experiments.

Jax environment

To set up the Jax environment, run:

$ conda create -n bench_hvp_jax python=3.11
$ conda activate bench_hvp_jax
$ pip install -e .
$ pip install --upgrade "jax[cuda11_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

In the blogpost, the experiments were done with version 0.4.21 of Jax.

PyTorch environment

To set up the Jax environment, run:

$ conda create -n bench_hvp_torch python=3.11
$ conda activate bench_hvp_torch
$ pip install -e .
$ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

In the blogpost, the experiments were done with version 2.1.1. of PyTorch.

Reproducing the figures

Time complexity

To reproduce the computational time comparison in Jax or in PyTorch, run the following command where XXX has to be replaced by jax or torch accordingly

$ conda activate bench_hvp_XXX
$ cd bench_hvp
$ python bench_hvp_time.py -f XXX -n 100

The raw results are stored in the folder outputs. Then, the figure can be plotted

$ cd ../figures
$ python plot_bench_time.py -f ../outputs/bench_hvp_time_XXX.parquet

The figures are stored in the folder figures. alt text alt text

Memory complexity

To reproduce the memory footprint experiment, you can execute the following bash script

$ cd bench_hvp
$ bash bench_hvp_memory.sh

The raw results are stored in the folder outputs. Then, the figure can be plotted

$ cd ../figures
$ python plot_bench_memory.py -f ../outputs/bench_hvp_memory_XXX.parquet

where XXX can be replaced by jax, jax_without_jit or torch. The figures are stored in the folder figures.

alt text alt text alt text

bench_hvp's People

Contributors

matdag avatar

Stargazers

Naicheng He(Arnie) avatar Anshuman Suri avatar Nhung Bui avatar Alireza Abdollahpourrostam avatar

Watchers

Samuel Vaiter avatar Thomas Moreau avatar Pierre Ablin avatar  avatar

Forkers

arnie-he

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.