Skip to content

Commit 86deebc

Browse files
committed
Draft
1 parent fdf794e commit 86deebc

File tree

214 files changed

+6684
-11608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+6684
-11608
lines changed

.github/build_windows_packages.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,17 @@ Remove-Item $ffDir.FullName -Recurse -Force
115115
Write-Host "[INFO] Installing PyTorch..."
116116
& ".\runtime\python.exe" -m ensurepip
117117
& ".\runtime\python.exe" -m pip install --upgrade pip --no-warn-script-location
118+
118119
switch ($cuda) {
119120
"cu124" {
120-
& ".\runtime\python.exe" -m pip install torch==2.6 torchaudio --index-url https://download.pytorch.org/whl/cu124 --no-warn-script-location
121+
& ".\runtime\python.exe" -m pip install psutil ninja packaging wheel "setuptools>=42" --no-warn-script-location
122+
& ".\runtime\python.exe" -m pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu124 --no-warn-script-location
123+
& ".\runtime\python.exe" -m pip install flash-attn -i https://xxxxrt666.github.io/PIP-Index/ --no-build-isolation
121124
}
122125
"cu128" {
126+
& ".\runtime\python.exe" -m pip install psutil ninja packaging wheel "setuptools>=42" --no-warn-script-location
123127
& ".\runtime\python.exe" -m pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location
128+
& ".\runtime\python.exe" -m pip install flash-attn -i https://xxxxrt666.github.io/PIP-Index/ --no-build-isolation
124129
}
125130
default {
126131
Write-Error "Unsupported CUDA version: $cuda"

.github/workflows/build_windows_packages.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ jobs:
3131
- name: Checkout
3232
uses: actions/checkout@v4
3333

34+
- name: Install Windows CUDA 12.9
35+
if: ${{ runner.os == 'Windows' && matrix.torch_cuda == '12.8' }}
36+
uses: Jimver/cuda-toolkit
37+
id: cuda-toolkit-win-129
38+
with:
39+
cuda: 12.9.1
40+
method: "network"
41+
sub-packages: '["nvcc", "cudart", "visual_studio_integration"]'
42+
3443
- name: Run Build and Upload Script
3544
shell: pwsh
3645
run: |

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ ffprobe*
1616
cfg.json
1717
speakers.json
1818
ref_audios
19-
tools/AP_BWE_main/24kto48k/*
20-
!tools/AP_BWE_main/24kto48k/readme.txt
19+
tools/AP_BWE/24kto48k/*
20+
!tools/AP_BWE/24kto48k/readme.txt
21+
onnx
2122

2223
# Byte-compiled / optimized / DLL files
2324
__pycache__/

Docker/miniconda_install.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ fi
2323

2424
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
2525
"${WGET_CMD[@]}" -O miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py311_25.3.1-1-Linux-x86_64.sh
26+
SYSROOT_PKG="sysroot_linux-64>=2.28"
2627
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
2728
"${WGET_CMD[@]}" -O miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py311_25.3.1-1-Linux-aarch64.sh
29+
SYSROOT_PKG="sysroot_linux-aarch64>=2.28"
2830
else
2931
exit 1
3032
fi
@@ -45,20 +47,36 @@ rm miniconda.sh
4547

4648
source "$HOME/miniconda3/etc/profile.d/conda.sh"
4749

50+
"$HOME/miniconda3/bin/conda" init bash
51+
52+
source "$HOME/.bashrc"
53+
4854
"$HOME/miniconda3/bin/conda" config --add channels conda-forge
4955

5056
"$HOME/miniconda3/bin/conda" update -q --all -y 1>/dev/null
5157

5258
"$HOME/miniconda3/bin/conda" install python=3.11 -q -y
5359

54-
"$HOME/miniconda3/bin/conda" install gcc=14 gxx ffmpeg cmake make unzip -q -y
60+
"$HOME/miniconda3/bin/conda" install gcc=11 gxx ffmpeg cmake make unzip $SYSROOT_PKG "libstdcxx-ng>=11" -q -y
5561

5662
if [ "$CUDA_VERSION" = "12.8" ]; then
5763
"$HOME/miniconda3/bin/pip" install torch torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/cu128
64+
"$HOME/miniconda3/bin/conda" install cuda-nvcc=12.8 -c nvidia
5865
elif [ "$CUDA_VERSION" = "12.6" ]; then
59-
"$HOME/miniconda3/bin/pip" install torch==2.6 torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/cu126
66+
"$HOME/miniconda3/bin/pip" install torch torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/cu126
67+
"$HOME/miniconda3/bin/conda" install cuda-nvcc=12.6 -c nvidia
6068
fi
6169

70+
CUDA_PATH=$(echo "$HOME/miniconda3/targets/"*-linux | awk '{print $1}')
71+
72+
export CUDA_HOME=$CUDA_PATH
73+
export PATH="$HOME/miniconda3/bin:$PATH"
74+
export PATH="$CUDA_HOME/bin:$PATH"
75+
export PATH="$CUDA_HOME/nvvm/bin:$PATH"
76+
77+
"$HOME/miniconda3/bin/pip" install psutil ninja packaging wheel "setuptools>=42"
78+
"$HOME/miniconda3/bin/pip" install flash-attn -i https://xxxxrt666.github.io/PIP-Index/ --no-build-isolation
79+
6280
"$HOME/miniconda3/bin/pip" cache purge
6381

6482
rm $LOG_PATH

GPT_SoVITS/AR/__init__.py

Whitespace-only changes.

GPT_SoVITS/AR/data/data_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from pytorch_lightning import LightningDataModule
44
from torch.utils.data import DataLoader
55

6-
from AR.data.bucket_sampler import DistributedBucketSampler
7-
from AR.data.dataset import Text2SemanticDataset
6+
from GPT_SoVITS.AR.data.bucket_sampler import DistributedBucketSampler
7+
from GPT_SoVITS.AR.data.dataset import Text2SemanticDataset
88

99

1010
class Text2SemanticDataModule(LightningDataModule):

GPT_SoVITS/AR/data/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
version = os.environ.get("version", None)
1515

16-
from text import cleaned_text_to_sequence
16+
from GPT_SoVITS.text import cleaned_text_to_sequence
1717

1818
# from config import exp_dir
1919

@@ -220,7 +220,7 @@ def __getitem__(self, idx: int) -> Dict:
220220

221221
flag = 0
222222
path_bert = "%s/%s.pt" % (self.path3, item_name)
223-
if os.path.exists(path_bert) == True:
223+
if os.path.exists(path_bert) is True:
224224
bert_feature = torch.load(path_bert, map_location="cpu")
225225
else:
226226
flag = 1

GPT_SoVITS/AR/models/__init__.py

Whitespace-only changes.

GPT_SoVITS/AR/models/t2s_lightning_module.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# modified from https://github.com/yangdongchao/SoundStorm/blob/master/soundstorm/s1/AR/models/t2s_lightning_module.py
22
# reference: https://github.com/lifeiteng/vall-e
3-
import os
4-
import sys
53

6-
now_dir = os.getcwd()
7-
sys.path.append(now_dir)
84
from typing import Dict
95

106
import torch
117
from pytorch_lightning import LightningModule
128

13-
from AR.models.t2s_model import Text2SemanticDecoder
14-
from AR.modules.lr_schedulers import WarmupCosineLRSchedule
15-
from AR.modules.optim import ScaledAdam
9+
from ..modules.lr_schedulers import WarmupCosineLRSchedule
10+
from ..modules.optim import ScaledAdam
11+
from .t2s_model import Text2SemanticDecoder
1612

1713

1814
class Text2SemanticLightningModule(LightningModule):
@@ -42,7 +38,7 @@ def __init__(self, config, output_dir, is_train=True):
4238
def training_step(self, batch: Dict, batch_idx: int):
4339
opt = self.optimizers()
4440
scheduler = self.lr_schedulers()
45-
forward = self.model.forward if self.config["train"].get("if_dpo", False) == True else self.model.forward_old
41+
forward = self.model.forward if self.config["train"].get("if_dpo", False) is True else self.model.forward_old
4642
loss, acc = forward(
4743
batch["phoneme_ids"],
4844
batch["phoneme_ids_len"],
Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
# modified from https://github.com/yangdongchao/SoundStorm/blob/master/soundstorm/s1/AR/models/t2s_lightning_module.py
22
# reference: https://github.com/lifeiteng/vall-e
3-
import os
4-
import sys
53

6-
now_dir = os.getcwd()
7-
sys.path.append(now_dir)
8-
from typing import Dict
94

105
import torch
116
from pytorch_lightning import LightningModule
127

13-
from AR.models.t2s_model_onnx import Text2SemanticDecoder
14-
from AR.modules.lr_schedulers import WarmupCosineLRSchedule
15-
from AR.modules.optim import ScaledAdam
8+
from .t2s_model_onnx import Text2SemanticDecoder
169

1710

1811
class Text2SemanticLightningModule(LightningModule):
@@ -21,90 +14,3 @@ def __init__(self, config, output_dir, is_train=True):
2114
self.config = config
2215
self.top_k = 3
2316
self.model = Text2SemanticDecoder(config=config, top_k=self.top_k)
24-
pretrained_s1 = config.get("pretrained_s1")
25-
if pretrained_s1 and is_train:
26-
# print(self.load_state_dict(torch.load(pretrained_s1,map_location="cpu")["state_dict"]))
27-
print(
28-
self.load_state_dict(
29-
torch.load(
30-
pretrained_s1,
31-
map_location="cpu",
32-
)["weight"],
33-
),
34-
)
35-
if is_train:
36-
self.automatic_optimization = False
37-
self.save_hyperparameters()
38-
self.eval_dir = output_dir / "eval"
39-
self.eval_dir.mkdir(parents=True, exist_ok=True)
40-
41-
def training_step(self, batch: Dict, batch_idx: int):
42-
opt = self.optimizers()
43-
scheduler = self.lr_schedulers()
44-
loss, acc = self.model.forward(
45-
batch["phoneme_ids"],
46-
batch["phoneme_ids_len"],
47-
batch["semantic_ids"],
48-
batch["semantic_ids_len"],
49-
batch["bert_feature"],
50-
)
51-
self.manual_backward(loss)
52-
if batch_idx > 0 and batch_idx % 4 == 0:
53-
opt.step()
54-
opt.zero_grad()
55-
scheduler.step()
56-
57-
self.log(
58-
"total_loss",
59-
loss,
60-
on_step=True,
61-
on_epoch=True,
62-
prog_bar=True,
63-
sync_dist=True,
64-
)
65-
self.log(
66-
"lr",
67-
scheduler.get_last_lr()[0],
68-
on_epoch=True,
69-
prog_bar=True,
70-
sync_dist=True,
71-
)
72-
self.log(
73-
f"top_{self.top_k}_acc",
74-
acc,
75-
on_step=True,
76-
on_epoch=True,
77-
prog_bar=True,
78-
sync_dist=True,
79-
)
80-
81-
def validation_step(self, batch: Dict, batch_idx: int):
82-
return
83-
84-
def configure_optimizers(self):
85-
model_parameters = self.model.parameters()
86-
parameters_names = []
87-
parameters_names.append([name_param_pair[0] for name_param_pair in self.model.named_parameters()])
88-
lm_opt = ScaledAdam(
89-
model_parameters,
90-
lr=0.01,
91-
betas=(0.9, 0.95),
92-
clipping_scale=2.0,
93-
parameters_names=parameters_names,
94-
show_dominant_parameters=False,
95-
clipping_update_period=1000,
96-
)
97-
98-
return {
99-
"optimizer": lm_opt,
100-
"lr_scheduler": {
101-
"scheduler": WarmupCosineLRSchedule(
102-
lm_opt,
103-
init_lr=self.config["optimizer"]["lr_init"],
104-
peak_lr=self.config["optimizer"]["lr"],
105-
end_lr=self.config["optimizer"]["lr_end"],
106-
warmup_steps=self.config["optimizer"]["warmup_steps"],
107-
total_steps=self.config["optimizer"]["decay_steps"],
108-
)
109-
},
110-
}

0 commit comments

Comments
 (0)