Skip to main content

AccelHydra

python pytorch accelerate hydra docs license

It is still developing, with potential errors. Welcome bug report and PR!

:sparkles: Introduction

:thinking: What is AccelHydra?

A lightweight, configurable and modular training framework based on Accelerate and Hydra.

It IS:

  • a trainer wrapping PyTorch, providing some basic utility functions to improve the reusability of PyTorch training code.
  • built on accelerate to support various distributed training / inference environments.
  • built on hydra to support modular training configurations and command line overrides, with potential extended features like parameter sweeping.

It IS NOT:

  • a training framework designed for specific tasks (e.g., LLMs, image/audio-related tasks...).
  • a package including various state-of-the-art model implementations.
  • an inference-time accelerating or memory-reducing toolkit.

:bulb: Why you might want to use AccelHydra?

  • Avoid writing boilerplates every time. The training loop and some utility functions remain almost the same across different projects, so we take them out as a basic library.
  • The functionality of config loading is managed by Hydra, while distributed training is managed by Accelerate, so you don't need to worry about these details.
  • Maintain a moderate level of abstraction. Great libraries like PyTorch Lightning and Transformers are powerful, but their codebases are too deep for newcomers to understand, or lack convenient interface to modify. We don't want a Trainer with dozens of inheritence layers, nor a single train.py with all logics in thousands of lines.
  • Similar codebases can be found: lightning-hydra-template, lightning-accelerate. However, task-specific codes and base codes (base classes and utility functions) should be separated to continuously fix bugs in base codes. Therefore the principle here is to only integrate generic codes into the library, instead of codes designed for specific tasks (CV, NLP, RL, ...)

:warning: Why you might not want to use AccelHydra?

  • Overriding may sometimes become complicated for Hydra. Breaking training configs into different components make things clear, but it may also fail from time to time.
  • Efficiency consideration. This library is suitable for acamedic research to implement an idea and test its applicability, but the efficiency for data loading, training, and inference are not involved in this library.

:package: Installation

This repositiry is tested on Python 3.10+. We recommend creating a new virtual envrionment before installing AccelHydra to avoid breaking existing environments:

pip install accel_hydra
# or
pip install git+https://github.com/wsntxxn/AccelHydra

:computer: Usage

Check out the documentation or have a look at examples.

Basically, to use AccelHydra for training, you need to implement your own datasets, models, loss functions, and trainer:

  • For basic functions and classes provided by AccelHydra, you don't need to implement again.
  • The trainer should inherit accel_hydra.Trainer and implements necessary function training_step (and validation_step if validation is used).
  • Write Hydra-style YAML configs with the top-level train.yaml.
  • (Optional) Write a custom TrainLauncher if you need to customize the training setup.
  • (Optional) Write a custom training entry script train.py.
  • Launch training using the built-in entry point (for example, 8 GPUs on 2 nodes, fp16):
accelerate launch \
  --num_processes 8 \
  --num_machines 2 \
  --mixed_precision fp16 \
  -m accel_hydra.train_entry \
  -c configs/train.yaml

:memo: Note

Currently AccelHydra is only tested on GPU nodes. Welcome to test this library on more machines and create corresponding PRs.

:book: Citation

If you found this repository useful, please consider citing

@misc{
  title={AccelHydra: A Lightweight, Configurable and Modular Training Framework based on Accelerate and Hydra.},
  author={Xuenan Xu and Yixuan Li and Jiahao Mei},
  howpublished={\url{https://github.com/wsntxxn/AccelHydra}},
  year={2025}
}

Release files for accel-hydra 0.0.6.post1

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

Source distribution (sdist)

Source distribution for accel-hydra 0.0.6.post1
File Size Uploaded
accel_hydra-0.0.6.post1.tar.gz 170.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for accel-hydra 0.0.6.post1
File Interpreter ABI Platform
accel_hydra-0.0.6.post1-py3-none-any.whl Python 3 none any Details

Total release size: 199.2 kB

Release files / accel_hydra-0.0.6.post1.tar.gz

Download URL accel_hydra-0.0.6.post1.tar.gz
Size 170.8 kB
Tags Source
SHA-256 checksum
How to use checksums
39adb8fd4763c7d56c5871a41f1956b5f17d2dbd96696a145e9b4def5fff4d8e
BLAKE2b-256 checksum
How to use checksums
2448bebca2e48baa27b04adab8a3161dd2ed1ca19629781794d1cdd6aa7eacc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Release files / accel_hydra-0.0.6.post1-py3-none-any.whl

Download URL accel_hydra-0.0.6.post1-py3-none-any.whl
Size 28.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5db4485c44b0ad67b273d2e1097b2f184ab6afd32c6b85f405976b957bb8f501
BLAKE2b-256 checksum
How to use checksums
16cec04ad9e62abd10321d9cccb5cffb59b2b65633f7e1a7ae9f3e0985985c22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Release history Release notifications | RSS feed

This release

0.0.6.post1 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

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