Skip to content

Commit

Permalink
Merge pull request #7 from idiap/test-lowest
Browse files Browse the repository at this point in the history
Fix type hint and run CI on highest+lowest dependency versions
  • Loading branch information
eginhard authored Jun 29, 2024
2 parents 6f1f613 + c427198 commit 8025277
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.9, "3.10", "3.11", "3.12"]
uv-resolution: ["lowest-direct", "highest"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -29,16 +30,16 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends git make gcc
- name: Install/upgrade Python setup deps
run: python3 -m pip install --upgrade pip setuptools wheel
run: python3 -m pip install --upgrade pip setuptools uv
- name: Install Trainer
run: |
python3 -m pip install .[dev,test]
python3 -m uv pip install --resolution=${{ matrix.uv-resolution }} --system "coqui-tts-trainer[dev,test] @ ."
- name: Unit tests
run: make test_all
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.python-version }}
name: coverage-data-${{ matrix.python-version }}-${{ matrix.uv-resolution }}
path: .coverage.*
if-no-files-found: ignore
coverage:
Expand Down
27 changes: 14 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include = ["trainer*"]

[project]
name = "coqui-tts-trainer"
version = "0.1.3"
version = "0.1.4"
description = "General purpose model trainer for PyTorch that is more flexible than it should be, by 🐸Coqui."
readme = "README.md"
requires-python = ">=3.9, <3.13"
Expand Down Expand Up @@ -39,28 +39,29 @@ classifiers = [
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
"coqpit",
"fsspec",
"numpy",
"psutil",
"soundfile",
"tensorboard",
"coqpit>=0.0.17",
"fsspec>=2023.6.0",
"numpy>=1.24.3; python_version < '3.12'",
"numpy>=1.26.0; python_version >= '3.12'",
"psutil>=5",
"soundfile>=0.12.0",
"tensorboard>=2.17.0",
"torch>=2.0",
]

[project.optional-dependencies]
# Development dependencies
dev = [
"coverage",
"pre-commit",
"pytest",
"coverage>=7",
"pre-commit>=3",
"pytest>=8",
"ruff==0.4.10",
"tomli; python_version < '3.11'",
"tomli>=2; python_version < '3.11'",
]
# Dependencies for running the tests
test = [
"accelerate",
"torchvision",
"accelerate>=0.20.0",
"torchvision>=0.15.1",
]

[project.urls]
Expand Down
4 changes: 2 additions & 2 deletions trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ def _set_grad_clip_per_optimizer(config: Coqpit, optimizer_idx: int):
def _compute_grad_norm(self, optimizer: torch.optim.Optimizer):
return torch.norm(torch.cat([param.grad.view(-1) for param in self.master_params(optimizer)], dim=0), p=2)

def _grad_clipping(self, grad_clip: float, optimizer: torch.optim.Optimizer, scaler: torch.amp.GradScaler):
def _grad_clipping(self, grad_clip: float, optimizer: torch.optim.Optimizer, scaler: torch.cuda.amp.GradScaler):
"""Perform gradient clipping"""
if grad_clip is not None and grad_clip > 0:
if scaler:
Expand All @@ -960,7 +960,7 @@ def optimize(
batch: dict,
model: nn.Module,
optimizer: torch.optim.Optimizer,
scaler: torch.amp.GradScaler,
scaler: torch.cuda.amp.GradScaler,
criterion: nn.Module,
scheduler: Union[torch.optim.lr_scheduler._LRScheduler, list, dict], # pylint: disable=protected-access
config: Coqpit,
Expand Down

0 comments on commit 8025277

Please sign in to comment.