Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ASDL: Automatic Second-order Differentiation Library

ASDL is an extension library of PyTorch to easily perform gradient preconditioning using second-order information (e.g., Hessian, Fisher information) for deep neural networks.

ASDL provides various implementations and a unified interface (GradientMaker) for gradient preconditioning for deep neural networks. For example, to train your model with gradient preconditioning by K-FAC algorithm, you can replace a <Standard> gradient calculation procedure (i.e., a forward pass followed by a backward pass) with one by <ASDL> with KfacGradientMaker like the following:

from asdl.precondition import PreconditioningConfig, KfacGradientMaker

# Initialize model
model = Net()

# Initialize optimizer (SGD is recommended)
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)

# Initialize KfacGradientMaker
config = PreconditioningConfig(data_size=batch_size, damping=0.01)
gm = KfacGradientMaker(model, config)

# Training loop
for x, t in data_loader:
  optimizer.zero_grad()
  
  # <Standard> (gradient calculation)
  # y = model(x)
  # loss = loss_fn(y, t)
  # loss.backward()

  # <ASDL> ('preconditioned' gradient calculation)
  dummy_y = gm.setup_model_call(model, x)
  gm.setup_loss_call(loss_fn, dummy_y, t)
  y, loss = gm.forward_and_backward()

  optimizer.step()

You can apply a different gradient preconditioning algorithm by replacing gm with another XXXGradientMaker(model, config) (XXX: algorithm name, e.g., ShampooGradientMaker for Shampoo algorithm) with the same interface. This enables a flexible switching/comparison of a range of gradient preconditioning algorithms.

Installation

You can install the latest version of ASDL by running:

$ pip install asdfghjkl

ASDL is tested with Python 3.7 and is compatible with PyTorch 1.13.

Example

The training script for training MLPs, CNNs, or ResNets using varous types of gradient preconditionig methods (which reproduces the results in the ASDL paper).

Resource

Metadata

Release files for asdfghjkl 0.1a5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asdfghjkl 0.1a5
File Size Uploaded Provenance Actions
asdfghjkl-0.1a5.tar.gz 75.7 kB Without provenance Details for asdfghjkl-0.1a5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for asdfghjkl 0.1a5
File Interpreter ABI Platform Actions
asdfghjkl-0.1a5-py3-none-any.whl Python 3 none any Details for asdfghjkl-0.1a5-py3-none-any.whl

Total release size: 165.3 kB

Release files / asdfghjkl-0.1a5.tar.gz

Download URL asdfghjkl-0.1a5.tar.gz
Size 75.7 kB
Tags Source
SHA-256 checksum
How to use checksums
02d268093bfa804132b9405266f2c3b27ffda27000b47251b31de299b13d0da8
BLAKE2b-256 checksum
How to use checksums
460097a16b4a9c0ec0f971e7033187043cff4d854bd8e84dc6b03e3b74d8931a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.4

Release files / asdfghjkl-0.1a5-py3-none-any.whl

Download URL asdfghjkl-0.1a5-py3-none-any.whl
Size 89.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b84d6755f0e7a47ef71a6ba88c81e8fe123b8cbd234eb20cde5790eebb4d5198
BLAKE2b-256 checksum
How to use checksums
1f9c0d320fa42c3a965e1f2ba20ada993737da049ab2545cf55199deb5e50d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.4

Security for asdfghjkl 0.1a5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page