e2am 0.1.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.
- e2am-0.1.0/.gitattributes +7 -0
- e2am-0.1.0/.github/workflows/ci.yml +48 -0
- e2am-0.1.0/.github/workflows/release.yml +63 -0
- e2am-0.1.0/.gitignore +44 -0
- e2am-0.1.0/CHANGELOG.md +57 -0
- e2am-0.1.0/CONTRIBUTING.md +62 -0
- e2am-0.1.0/LICENSE +21 -0
- e2am-0.1.0/PKG-INFO +273 -0
- e2am-0.1.0/README.md +198 -0
- e2am-0.1.0/docs/architecture.md +64 -0
- e2am-0.1.0/examples/cli_model.py +41 -0
- e2am-0.1.0/examples/quickstart_monitor.py +26 -0
- e2am-0.1.0/examples/quickstart_trainer.py +47 -0
- e2am-0.1.0/pyproject.toml +166 -0
- e2am-0.1.0/src/e2am/__init__.py +45 -0
- e2am-0.1.0/src/e2am/cli/__init__.py +7 -0
- e2am-0.1.0/src/e2am/cli/loader.py +60 -0
- e2am-0.1.0/src/e2am/cli/main.py +334 -0
- e2am-0.1.0/src/e2am/config/__init__.py +21 -0
- e2am-0.1.0/src/e2am/config/settings.py +163 -0
- e2am-0.1.0/src/e2am/exceptions.py +45 -0
- e2am-0.1.0/src/e2am/integrations/__init__.py +22 -0
- e2am-0.1.0/src/e2am/integrations/huggingface.py +168 -0
- e2am-0.1.0/src/e2am/metrics/__init__.py +56 -0
- e2am-0.1.0/src/e2am/metrics/classification.py +124 -0
- e2am-0.1.0/src/e2am/metrics/green.py +153 -0
- e2am-0.1.0/src/e2am/metrics/tracker.py +99 -0
- e2am-0.1.0/src/e2am/monitoring/__init__.py +42 -0
- e2am-0.1.0/src/e2am/monitoring/api.py +167 -0
- e2am-0.1.0/src/e2am/monitoring/carbon.py +108 -0
- e2am-0.1.0/src/e2am/monitoring/energy.py +79 -0
- e2am-0.1.0/src/e2am/monitoring/result.py +137 -0
- e2am-0.1.0/src/e2am/monitoring/samplers.py +228 -0
- e2am-0.1.0/src/e2am/monitoring/session.py +263 -0
- e2am-0.1.0/src/e2am/optimize/__init__.py +8 -0
- e2am-0.1.0/src/e2am/optimize/analyzer.py +225 -0
- e2am-0.1.0/src/e2am/optimize/suggestions.py +35 -0
- e2am-0.1.0/src/e2am/plugins/__init__.py +23 -0
- e2am-0.1.0/src/e2am/plugins/base.py +48 -0
- e2am-0.1.0/src/e2am/plugins/mlflow.py +84 -0
- e2am-0.1.0/src/e2am/plugins/tensorboard.py +59 -0
- e2am-0.1.0/src/e2am/plugins/wandb.py +72 -0
- e2am-0.1.0/src/e2am/plugins/webhooks.py +98 -0
- e2am-0.1.0/src/e2am/profiler/__init__.py +21 -0
- e2am-0.1.0/src/e2am/profiler/flops.py +238 -0
- e2am-0.1.0/src/e2am/profiler/latency.py +138 -0
- e2am-0.1.0/src/e2am/profiler/memory.py +63 -0
- e2am-0.1.0/src/e2am/py.typed +0 -0
- e2am-0.1.0/src/e2am/reports/__init__.py +17 -0
- e2am-0.1.0/src/e2am/reports/common.py +158 -0
- e2am-0.1.0/src/e2am/reports/dashboard.py +121 -0
- e2am-0.1.0/src/e2am/reports/generate.py +82 -0
- e2am-0.1.0/src/e2am/reports/html.py +108 -0
- e2am-0.1.0/src/e2am/reports/leaderboard.py +65 -0
- e2am-0.1.0/src/e2am/reports/markdown.py +49 -0
- e2am-0.1.0/src/e2am/reports/pdf.py +112 -0
- e2am-0.1.0/src/e2am/trainer/__init__.py +33 -0
- e2am-0.1.0/src/e2am/trainer/callbacks.py +135 -0
- e2am-0.1.0/src/e2am/trainer/result.py +115 -0
- e2am-0.1.0/src/e2am/trainer/trainer.py +440 -0
- e2am-0.1.0/src/e2am/utils/__init__.py +22 -0
- e2am-0.1.0/src/e2am/utils/hardware.py +221 -0
- e2am-0.1.0/src/e2am/utils/logging.py +65 -0
- e2am-0.1.0/src/e2am/utils/nvml.py +178 -0
- e2am-0.1.0/src/e2am/visualization/__init__.py +15 -0
- e2am-0.1.0/src/e2am/visualization/plots.py +272 -0
- e2am-0.1.0/src/e2am/visualization/style.py +44 -0
- e2am-0.1.0/tests/conftest.py +72 -0
- e2am-0.1.0/tests/test_carbon.py +45 -0
- e2am-0.1.0/tests/test_classification.py +80 -0
- e2am-0.1.0/tests/test_cli.py +194 -0
- e2am-0.1.0/tests/test_config.py +66 -0
- e2am-0.1.0/tests/test_energy.py +57 -0
- e2am-0.1.0/tests/test_flops.py +107 -0
- e2am-0.1.0/tests/test_green.py +77 -0
- e2am-0.1.0/tests/test_hardware.py +49 -0
- e2am-0.1.0/tests/test_huggingface.py +114 -0
- e2am-0.1.0/tests/test_import.py +21 -0
- e2am-0.1.0/tests/test_latency.py +48 -0
- e2am-0.1.0/tests/test_memory.py +29 -0
- e2am-0.1.0/tests/test_monitor_api.py +89 -0
- e2am-0.1.0/tests/test_nvml.py +41 -0
- e2am-0.1.0/tests/test_optimize.py +163 -0
- e2am-0.1.0/tests/test_plots.py +93 -0
- e2am-0.1.0/tests/test_plugins.py +264 -0
- e2am-0.1.0/tests/test_reports.py +130 -0
- e2am-0.1.0/tests/test_samplers.py +57 -0
- e2am-0.1.0/tests/test_session.py +134 -0
- e2am-0.1.0/tests/test_tracker.py +83 -0
- e2am-0.1.0/tests/test_trainer.py +273 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.11"
|
|
17
|
+
- name: Install
|
|
18
|
+
run: pip install -e ".[dev]"
|
|
19
|
+
- name: Ruff
|
|
20
|
+
run: ruff check src tests
|
|
21
|
+
- name: Black
|
|
22
|
+
run: black --check src tests
|
|
23
|
+
- name: isort
|
|
24
|
+
run: isort --check-only src tests
|
|
25
|
+
- name: Mypy
|
|
26
|
+
run: mypy src/e2am
|
|
27
|
+
|
|
28
|
+
test:
|
|
29
|
+
runs-on: ${{ matrix.os }}
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
os: [ubuntu-latest, windows-latest]
|
|
34
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
35
|
+
exclude:
|
|
36
|
+
- os: windows-latest
|
|
37
|
+
python-version: "3.10"
|
|
38
|
+
- os: windows-latest
|
|
39
|
+
python-version: "3.12"
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
- uses: actions/setup-python@v5
|
|
43
|
+
with:
|
|
44
|
+
python-version: ${{ matrix.python-version }}
|
|
45
|
+
- name: Install
|
|
46
|
+
run: pip install -e ".[dev]"
|
|
47
|
+
- name: Run tests (no GPU on CI runners)
|
|
48
|
+
run: pytest -m "not gpu" --cov=e2am --cov-report=term-missing
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI via trusted publishing (OIDC) when a version tag is pushed.
|
|
4
|
+
# One-time setup on pypi.org: project "e2am" -> Publishing -> add GitHub
|
|
5
|
+
# publisher (owner: Shanmuk4622, repo: e2am, workflow: release.yml,
|
|
6
|
+
# environment: pypi).
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
tags: ["v*"]
|
|
11
|
+
workflow_dispatch: {}
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.11"
|
|
21
|
+
- name: Build sdist and wheel
|
|
22
|
+
run: |
|
|
23
|
+
pip install build twine
|
|
24
|
+
python -m build
|
|
25
|
+
twine check dist/*
|
|
26
|
+
- uses: actions/upload-artifact@v4
|
|
27
|
+
with:
|
|
28
|
+
name: dist
|
|
29
|
+
path: dist/
|
|
30
|
+
|
|
31
|
+
test:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
needs: build
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: actions/setup-python@v5
|
|
37
|
+
with:
|
|
38
|
+
python-version: "3.11"
|
|
39
|
+
- uses: actions/download-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: dist
|
|
42
|
+
path: dist/
|
|
43
|
+
- name: Install the built wheel and smoke-test it
|
|
44
|
+
run: |
|
|
45
|
+
pip install dist/*.whl
|
|
46
|
+
python -c "import e2am; print(e2am.__version__)"
|
|
47
|
+
e2am version
|
|
48
|
+
e2am hardware --json > /dev/null
|
|
49
|
+
|
|
50
|
+
publish:
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
needs: [build, test]
|
|
53
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
54
|
+
environment: pypi
|
|
55
|
+
permissions:
|
|
56
|
+
id-token: write
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/download-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
name: dist
|
|
61
|
+
path: dist/
|
|
62
|
+
- name: Publish to PyPI (trusted publishing)
|
|
63
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
e2am-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Byte-compiled / caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.mypy_cache/
|
|
10
|
+
.ruff_cache/
|
|
11
|
+
.coverage
|
|
12
|
+
htmlcov/
|
|
13
|
+
|
|
14
|
+
# Environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
.conda/
|
|
19
|
+
|
|
20
|
+
# Editors / OS
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
.DS_Store
|
|
24
|
+
Thumbs.db
|
|
25
|
+
|
|
26
|
+
# Experiment outputs
|
|
27
|
+
results/
|
|
28
|
+
runs/
|
|
29
|
+
emissions.csv
|
|
30
|
+
*.ckpt
|
|
31
|
+
*.pth
|
|
32
|
+
*.pt
|
|
33
|
+
|
|
34
|
+
# Data
|
|
35
|
+
data/
|
|
36
|
+
datasets/
|
|
37
|
+
|
|
38
|
+
# Docs build
|
|
39
|
+
docs/_build/
|
|
40
|
+
site/
|
|
41
|
+
|
|
42
|
+
# Local claude settings
|
|
43
|
+
.claude/settings.local.json
|
|
44
|
+
.claude/launch.json
|
e2am-0.1.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to E2AM are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/) and the project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] — 2026-07-11
|
|
8
|
+
|
|
9
|
+
First public release. 🌱
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
**Monitoring**
|
|
14
|
+
- `with monitor(project=...)` context manager / decorator — zero-code-change
|
|
15
|
+
energy, carbon, and utilization tracking for any code block.
|
|
16
|
+
- Background `MonitorSession` with per-device samplers: GPU (NVML live power
|
|
17
|
+
sensor, TDP × utilization fallback for cards without one), CPU
|
|
18
|
+
(TDP × utilization), RAM (~3 W per 8 GB used); live `snapshot()` totals.
|
|
19
|
+
- Trapezoidal power→energy integration robust to irregular intervals and
|
|
20
|
+
missing readings; measured-vs-estimated flags on every device.
|
|
21
|
+
- Region-aware carbon estimation (27-country intensity table, user override,
|
|
22
|
+
world-average fallback).
|
|
23
|
+
|
|
24
|
+
**Profiling & metrics**
|
|
25
|
+
- `profile_model`: hook-based MACs/FLOPs/params with an extensible counter
|
|
26
|
+
registry and honest parameter-coverage reporting.
|
|
27
|
+
- `benchmark_latency`: warmed-up, CUDA-synchronized latency (mean/p50/p95)
|
|
28
|
+
and throughput. `MemoryTracker`: exact CUDA peak + host RSS delta.
|
|
29
|
+
- Torch-native classification metrics (accuracy, macro/weighted P/R/F1).
|
|
30
|
+
- Green AI metrics: energy/carbon per sample, accuracy-per-joule,
|
|
31
|
+
Green Score (`100·acc·E_ref/(E_ref+E)`), EAG (energy-accuracy gradient).
|
|
32
|
+
|
|
33
|
+
**Training**
|
|
34
|
+
- Drop-in `Trainer` with AMP, gradient accumulation, clipping, LR scheduler
|
|
35
|
+
support, callback lifecycle, `EarlyStopping`, and automatic integration of
|
|
36
|
+
monitoring + profiling + green metrics.
|
|
37
|
+
|
|
38
|
+
**Outputs**
|
|
39
|
+
- Automatic artifacts per run: 10 plots, self-contained `report.html`,
|
|
40
|
+
`README.md`, optional `report.pdf`, `metrics.json`, `summary.yaml`,
|
|
41
|
+
`config.yaml`, cross-run `leaderboard.csv`, local `dashboard.html`.
|
|
42
|
+
|
|
43
|
+
**CLI**
|
|
44
|
+
- `e2am hardware | train | benchmark | report | compare | optimize | dashboard`.
|
|
45
|
+
- `benchmark` reports energy per inference (joules) via live monitoring.
|
|
46
|
+
- `optimize`: rule-based efficiency suggestions with quantified Wh savings
|
|
47
|
+
(wasted-epoch detection, AMP, batch size, torch.compile, checkpointing,
|
|
48
|
+
quantization).
|
|
49
|
+
|
|
50
|
+
**Integrations**
|
|
51
|
+
- Plugins (all Trainer callbacks): Weights & Biases, MLflow, TensorBoard,
|
|
52
|
+
Slack, Discord (webhooks are stdlib-only).
|
|
53
|
+
- Hugging Face: `E2AMCallback` for `transformers.Trainer`.
|
|
54
|
+
|
|
55
|
+
### Notes
|
|
56
|
+
- Python ≥ 3.10. PyTorch is a peer dependency (install the build matching
|
|
57
|
+
your hardware); monitoring works without it.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Contributing to E2AM
|
|
2
|
+
|
|
3
|
+
Thanks for helping make AI training measurably greener! 🌱
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/Shanmuk4622/e2am.git
|
|
9
|
+
cd e2am
|
|
10
|
+
python -m venv .venv && source .venv/bin/activate # or your conda env
|
|
11
|
+
pip install -e ".[dev,pdf]"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
PyTorch is a peer dependency — install the build matching your hardware from
|
|
15
|
+
[pytorch.org](https://pytorch.org/get-started/locally/).
|
|
16
|
+
|
|
17
|
+
## Quality gate
|
|
18
|
+
|
|
19
|
+
Every PR must pass the same gate CI runs:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
ruff check src tests
|
|
23
|
+
black --check src tests
|
|
24
|
+
isort --check-only src tests
|
|
25
|
+
mypy src/e2am
|
|
26
|
+
pytest -m "not gpu" # GPU tests run only on machines with an NVIDIA GPU
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
On a GPU machine, also run the full suite: `pytest`.
|
|
30
|
+
|
|
31
|
+
## Design rules of the codebase
|
|
32
|
+
|
|
33
|
+
- **Graceful degradation** — no GPU, no power sensor, no torch: E2AM must
|
|
34
|
+
still work, estimating (and *labeling* the estimate) where it cannot measure.
|
|
35
|
+
- **Never crash user training** — samplers, callbacks, and report generation
|
|
36
|
+
are failure-isolated; a monitoring bug must not kill an 8-hour run.
|
|
37
|
+
- **Honesty over false precision** — anything estimated is flagged as
|
|
38
|
+
estimated in results, reports, and plots.
|
|
39
|
+
- **One implementation** — the CLI orchestrates the Python API; it never
|
|
40
|
+
reimplements it.
|
|
41
|
+
- **Torch stays optional at import time** — `import e2am` and monitoring work
|
|
42
|
+
without PyTorch; torch-backed modules are imported lazily.
|
|
43
|
+
|
|
44
|
+
## Style
|
|
45
|
+
|
|
46
|
+
Python ≥ 3.10, full type hints, Google-style docstrings, `ruff`/`black`/`isort`
|
|
47
|
+
formatting (line length 100). Tests use plain `pytest` with markers `gpu`,
|
|
48
|
+
`torch`, `slow`. New metrics or samplers need hand-computed expected values in
|
|
49
|
+
their tests, not just "doesn't crash".
|
|
50
|
+
|
|
51
|
+
## Adding a sampler / metric / report
|
|
52
|
+
|
|
53
|
+
- New device sampler: subclass `e2am.monitoring.samplers.Sampler`, register in
|
|
54
|
+
`create_samplers`, never raise from `sample()`.
|
|
55
|
+
- New MAC counter: `e2am.profiler.register_mac_counter(YourModule, fn)`.
|
|
56
|
+
- New report format: consume `e2am.reports.common.build_sections` so every
|
|
57
|
+
format stays in sync.
|
|
58
|
+
|
|
59
|
+
## Reporting issues
|
|
60
|
+
|
|
61
|
+
Include your OS, Python, torch version, GPU/driver, and the output of
|
|
62
|
+
`e2am hardware --json`.
|
e2am-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Satyanarayana (Shanmuk4622) and E2AM contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
e2am-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: e2am
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: E2AM — Energy Efficient AI Models: automatic energy, carbon, and performance profiling for AI training.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Shanmuk4622/e2am
|
|
6
|
+
Project-URL: Repository, https://github.com/Shanmuk4622/e2am
|
|
7
|
+
Project-URL: Issues, https://github.com/Shanmuk4622/e2am/issues
|
|
8
|
+
Author-email: Satyanarayana <shanmukesh.bonala@gmail.com>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Satyanarayana (Shanmuk4622) and E2AM contributors
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Keywords: benchmarking,carbon-emissions,energy-efficiency,green-ai,mlops,profiling,pytorch,sustainability
|
|
32
|
+
Classifier: Development Status :: 3 - Alpha
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: Intended Audience :: Science/Research
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
42
|
+
Classifier: Topic :: System :: Monitoring
|
|
43
|
+
Classifier: Typing :: Typed
|
|
44
|
+
Requires-Python: >=3.10
|
|
45
|
+
Requires-Dist: matplotlib>=3.6
|
|
46
|
+
Requires-Dist: numpy>=1.23
|
|
47
|
+
Requires-Dist: nvidia-ml-py>=11.495.46
|
|
48
|
+
Requires-Dist: psutil>=5.9
|
|
49
|
+
Requires-Dist: pydantic>=2.0
|
|
50
|
+
Requires-Dist: pyyaml>=6.0
|
|
51
|
+
Requires-Dist: rich>=13.0
|
|
52
|
+
Requires-Dist: typer>=0.9
|
|
53
|
+
Provides-Extra: all
|
|
54
|
+
Requires-Dist: codecarbon>=2.3; extra == 'all'
|
|
55
|
+
Requires-Dist: plotly>=5.18; extra == 'all'
|
|
56
|
+
Requires-Dist: reportlab>=4.0; extra == 'all'
|
|
57
|
+
Provides-Extra: carbon
|
|
58
|
+
Requires-Dist: codecarbon>=2.3; extra == 'carbon'
|
|
59
|
+
Provides-Extra: dashboard
|
|
60
|
+
Requires-Dist: plotly>=5.18; extra == 'dashboard'
|
|
61
|
+
Provides-Extra: dev
|
|
62
|
+
Requires-Dist: black>=24.0; extra == 'dev'
|
|
63
|
+
Requires-Dist: isort>=5.13; extra == 'dev'
|
|
64
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
65
|
+
Requires-Dist: pandas>=1.5; extra == 'dev'
|
|
66
|
+
Requires-Dist: pre-commit>=3.5; extra == 'dev'
|
|
67
|
+
Requires-Dist: pytest-cov>=4.1; extra == 'dev'
|
|
68
|
+
Requires-Dist: pytest>=7.4; extra == 'dev'
|
|
69
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
70
|
+
Requires-Dist: types-psutil; extra == 'dev'
|
|
71
|
+
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
72
|
+
Provides-Extra: pdf
|
|
73
|
+
Requires-Dist: reportlab>=4.0; extra == 'pdf'
|
|
74
|
+
Description-Content-Type: text/markdown
|
|
75
|
+
|
|
76
|
+
<div align="center">
|
|
77
|
+
|
|
78
|
+
# ⚡ E2AM — Energy Efficient AI Models
|
|
79
|
+
|
|
80
|
+
**Automatic energy, carbon, and performance profiling for AI training — with almost zero code changes.**
|
|
81
|
+
|
|
82
|
+
[](https://github.com/Shanmuk4622/e2am/actions/workflows/ci.yml)
|
|
83
|
+
[](https://www.python.org/)
|
|
84
|
+
[](LICENSE)
|
|
85
|
+
[](https://github.com/psf/black)
|
|
86
|
+
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
E2AM makes AI model training automatically measurable in terms of **energy efficiency**,
|
|
92
|
+
**carbon emissions**, **computational cost**, and **model performance**. Think of it as
|
|
93
|
+
*Weights & Biases + CodeCarbon + PyTorch Profiler* for **Green AI** — in one lightweight toolkit
|
|
94
|
+
for researchers, ML engineers, universities, and companies.
|
|
95
|
+
|
|
96
|
+
## Quickstart
|
|
97
|
+
|
|
98
|
+
Wrap any training code:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from e2am import monitor
|
|
102
|
+
|
|
103
|
+
with monitor(project="ResNet50"):
|
|
104
|
+
train()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or use the drop-in trainer:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from e2am import Trainer
|
|
111
|
+
|
|
112
|
+
trainer = Trainer(
|
|
113
|
+
model=model,
|
|
114
|
+
optimizer=optimizer,
|
|
115
|
+
train_loader=train_loader,
|
|
116
|
+
val_loader=val_loader,
|
|
117
|
+
)
|
|
118
|
+
trainer.fit()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Everything else happens automatically: energy, carbon, utilization, FLOPs, timing,
|
|
122
|
+
accuracy metrics, plots, and reports land in `results/`.
|
|
123
|
+
|
|
124
|
+
## Installation
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install e2am # once published; until then:
|
|
128
|
+
pip install git+https://github.com/Shanmuk4622/e2am.git
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> **Note:** PyTorch is not installed automatically — install the build matching your
|
|
132
|
+
> hardware from [pytorch.org](https://pytorch.org/get-started/locally/). Monitoring
|
|
133
|
+
> works even without PyTorch.
|
|
134
|
+
|
|
135
|
+
Optional extras:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pip install "e2am[carbon]" # CodeCarbon-backed carbon tracking
|
|
139
|
+
pip install "e2am[pdf]" # PDF reports (reportlab)
|
|
140
|
+
pip install "e2am[dashboard]" # interactive dashboards (plotly)
|
|
141
|
+
pip install "e2am[all]" # everything
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## What E2AM measures
|
|
145
|
+
|
|
146
|
+
| Category | Metrics |
|
|
147
|
+
| ----------- | ----------------------------------------------------------------------- |
|
|
148
|
+
| Energy | GPU / CPU / RAM energy (Wh), power draw over time, energy per sample |
|
|
149
|
+
| Carbon | CO₂eq emissions, carbon per sample, region-aware carbon intensity |
|
|
150
|
+
| Compute | FLOPs, MACs, parameters, GPU/CPU utilization, peak memory |
|
|
151
|
+
| Time | Training / epoch / batch time, latency, throughput |
|
|
152
|
+
| Quality | Accuracy, precision, recall, F1 |
|
|
153
|
+
| Green AI | Accuracy per joule, **Green Score**, **EAG** (Energy-Accuracy Gradient) |
|
|
154
|
+
|
|
155
|
+
## Automatic outputs
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
results/<run_name>/
|
|
159
|
+
accuracy.png loss.png energy.png power.png
|
|
160
|
+
gpu_usage.png cpu_usage.png memory.png carbon.png
|
|
161
|
+
latency.png throughput.png
|
|
162
|
+
report.html report.pdf
|
|
163
|
+
metrics.json leaderboard.csv
|
|
164
|
+
config.yaml README.md
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Architecture
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
e2am/
|
|
171
|
+
trainer/ # drop-in Trainer with callback lifecycle
|
|
172
|
+
monitor/ # background samplers: GPU (NVML), CPU, RAM, carbon
|
|
173
|
+
profiler/ # FLOPs / MACs / params, latency, memory
|
|
174
|
+
metrics/ # classification + Green AI metrics
|
|
175
|
+
benchmark/ # model/hardware benchmarking
|
|
176
|
+
reports/ # HTML / PDF / JSON / Markdown report generation
|
|
177
|
+
visualization/ # publication-quality plots
|
|
178
|
+
dashboard/ # interactive dashboard
|
|
179
|
+
plugins/ # W&B, MLflow, TensorBoard, Slack, Discord, HF
|
|
180
|
+
cli/ # `e2am` command line
|
|
181
|
+
config/ # typed, YAML-loadable configuration
|
|
182
|
+
utils/ # hardware detection, logging, timing
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Design principles: SOLID, clean architecture, graceful degradation (no GPU? no NVML power
|
|
186
|
+
sensor? no problem — E2AM falls back to utilization-based estimation), and zero required
|
|
187
|
+
code changes to your training loop.
|
|
188
|
+
|
|
189
|
+
## CLI
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
e2am hardware # detected hardware & energy capabilities
|
|
193
|
+
e2am train model.py --config config.yaml # train with full telemetry
|
|
194
|
+
e2am benchmark model.py --input-size 8,3,224,224 # FLOPs, latency, J/inference
|
|
195
|
+
e2am report results/run1 # regenerate reports for a run
|
|
196
|
+
e2am compare results/run1 results/run2 # side-by-side comparison
|
|
197
|
+
e2am optimize results/run1 # efficiency suggestions + Wh savings
|
|
198
|
+
e2am dashboard # local HTML dashboard of all runs
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
`model.py` follows a tiny convention (see [examples/cli_model.py](examples/cli_model.py)):
|
|
202
|
+
define `get_model()` and, for training, `get_loaders()`; optionally
|
|
203
|
+
`get_optimizer(model)` and `get_loss()`.
|
|
204
|
+
|
|
205
|
+
## Plugins
|
|
206
|
+
|
|
207
|
+
Every plugin is a Trainer callback — pass any combination:
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
from e2am import Trainer
|
|
211
|
+
from e2am.plugins import WandbPlugin, MLflowPlugin, TensorBoardPlugin, SlackPlugin
|
|
212
|
+
|
|
213
|
+
trainer = Trainer(
|
|
214
|
+
model=model, optimizer=optimizer, train_loader=train_loader,
|
|
215
|
+
callbacks=[
|
|
216
|
+
WandbPlugin(entity="my-team"), # pip install wandb
|
|
217
|
+
MLflowPlugin(experiment_name="green"), # pip install mlflow
|
|
218
|
+
TensorBoardPlugin(), # pip install tensorboard
|
|
219
|
+
SlackPlugin("https://hooks.slack.com/services/..."), # no extra deps
|
|
220
|
+
],
|
|
221
|
+
)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Slack/Discord notify on completion **and on failure** — including the final
|
|
225
|
+
energy, carbon, and Green Score. Missing packages fail fast at construction
|
|
226
|
+
with the pip command; network errors during training are logged, never raised.
|
|
227
|
+
Write your own by subclassing `e2am.trainer.Callback`.
|
|
228
|
+
|
|
229
|
+
## Hugging Face
|
|
230
|
+
|
|
231
|
+
Already using `transformers.Trainer`? One callback adds full E2AM telemetry:
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
from transformers import Trainer
|
|
235
|
+
from e2am.integrations import E2AMCallback
|
|
236
|
+
|
|
237
|
+
trainer = Trainer(
|
|
238
|
+
model=model, args=training_args, train_dataset=train_ds, eval_dataset=eval_ds,
|
|
239
|
+
callbacks=[E2AMCallback(project="bert-finetune")],
|
|
240
|
+
)
|
|
241
|
+
trainer.train() # energy, carbon, green metrics + full E2AM reports in results/
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Roadmap
|
|
245
|
+
|
|
246
|
+
- [x] Hardware detection with energy-capability probing
|
|
247
|
+
- [x] Background energy/carbon/utilization monitoring (`monitor()`)
|
|
248
|
+
- [x] FLOPs/MACs/latency/peak-memory profiler
|
|
249
|
+
- [x] Drop-in `Trainer` with callback lifecycle (AMP, grad accumulation, early stopping)
|
|
250
|
+
- [x] Green AI metrics: energy/carbon per sample, accuracy/joule, Green Score, EAG
|
|
251
|
+
- [x] Automatic plots + HTML/Markdown/PDF reports + leaderboard
|
|
252
|
+
- [x] CLI (`hardware`, `train`, `benchmark`, `report`, `compare`, `dashboard`)
|
|
253
|
+
- [x] Local HTML dashboard across runs
|
|
254
|
+
- [x] Plugin integrations (W&B, MLflow, TensorBoard, Slack/Discord)
|
|
255
|
+
- [x] Optimization engine (`e2am optimize`: AMP, batch size, torch.compile, checkpointing, quantization, wasted-epoch detection with measured Wh savings)
|
|
256
|
+
- [x] Hugging Face `transformers` integration (`E2AMCallback`)
|
|
257
|
+
- [ ] Distributed training support
|
|
258
|
+
- [ ] Cloud dashboard
|
|
259
|
+
|
|
260
|
+
## Contributing
|
|
261
|
+
|
|
262
|
+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md). Development setup:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
git clone https://github.com/Shanmuk4622/e2am.git
|
|
266
|
+
cd e2am
|
|
267
|
+
pip install -e ".[dev]"
|
|
268
|
+
pytest
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT — see [LICENSE](LICENSE).
|