Instructions to use jiaaom/CosyVoice3-TalkingFlowerZH with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- CosyVoice
How to use jiaaom/CosyVoice3-TalkingFlowerZH with CosyVoice:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Mason commited on
Commit ·
10a2949
1
Parent(s): 5e636e5
Quantize Qwen2 embed_tokens before moving module tensors to CUDA to avoid fp16 embedding residency during load.
Browse filesResult: {"status":"keep","peak_rss_mb":4261.316,"cuda_peak_allocated_mb":1753.854,"log_mel_mse":0,"snr_db":167.147,"length_delta_ms":0,"duration_s":2.16,"elapsed_s":45.363}
- cosyvoice/cli/model.py +5 -1
- cosyvoice/llm/llm.py +2 -0
cosyvoice/cli/model.py
CHANGED
|
@@ -120,7 +120,11 @@ class CosyVoiceModel:
|
|
| 120 |
|
| 121 |
def _move_module_tensors(self, module: torch.nn.Module):
|
| 122 |
target_dtype = torch.float16 if self.fp16 else torch.float32
|
| 123 |
-
for child in module.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
self._move_module_tensors(child)
|
| 125 |
for name, param in list(module._parameters.items()):
|
| 126 |
if param is None:
|
|
|
|
| 120 |
|
| 121 |
def _move_module_tensors(self, module: torch.nn.Module):
|
| 122 |
target_dtype = torch.float16 if self.fp16 else torch.float32
|
| 123 |
+
for name, child in list(module.named_children()):
|
| 124 |
+
if os.environ.get('COSYVOICE_LLM_EMBED_INT8') == '1' and name == 'embed_tokens' and isinstance(child, torch.nn.Embedding):
|
| 125 |
+
from cosyvoice.llm.llm import Int8WeightOnlyEmbedding
|
| 126 |
+
child = Int8WeightOnlyEmbedding(child)
|
| 127 |
+
module._modules[name] = child
|
| 128 |
self._move_module_tensors(child)
|
| 129 |
for name, param in list(module._parameters.items()):
|
| 130 |
if param is None:
|
cosyvoice/llm/llm.py
CHANGED
|
@@ -45,6 +45,8 @@ class Int8WeightOnlyEmbedding(torch.nn.Module):
|
|
| 45 |
|
| 46 |
|
| 47 |
def quantize_qwen_embed_int8(qwen_model: torch.nn.Module):
|
|
|
|
|
|
|
| 48 |
qwen_model.embed_tokens = Int8WeightOnlyEmbedding(qwen_model.embed_tokens)
|
| 49 |
|
| 50 |
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
def quantize_qwen_embed_int8(qwen_model: torch.nn.Module):
|
| 48 |
+
if isinstance(qwen_model.embed_tokens, Int8WeightOnlyEmbedding):
|
| 49 |
+
return
|
| 50 |
qwen_model.embed_tokens = Int8WeightOnlyEmbedding(qwen_model.embed_tokens)
|
| 51 |
|
| 52 |
|