Fix voice cloning with quantization (#181)
Fix https://github.com/kyutai-labs/pocket-tts/issues/178
This commit is contained in:
@@ -118,8 +118,15 @@ class StreamingMultiheadAttention(StatefulModule):
|
|||||||
self.out_proj = nn.Linear(embed_dim, mult * embed_dim, bias=False)
|
self.out_proj = nn.Linear(embed_dim, mult * embed_dim, bias=False)
|
||||||
|
|
||||||
def init_state(self, batch_size: int, sequence_length: int) -> dict[str, torch.Tensor]:
|
def init_state(self, batch_size: int, sequence_length: int) -> dict[str, torch.Tensor]:
|
||||||
device = self.in_proj.weight.device
|
weight = self.in_proj.weight
|
||||||
dtype = self.in_proj.weight.dtype
|
if callable(weight):
|
||||||
|
# torch.ao dynamic-quantized Linear: weight is a method returning a
|
||||||
|
# qint8 tensor, but activations stay float32 — that's what the cache holds.
|
||||||
|
device = weight().device
|
||||||
|
dtype = torch.float32
|
||||||
|
else:
|
||||||
|
device = weight.device
|
||||||
|
dtype = weight.dtype
|
||||||
return self._cache_backend.init_state(batch_size, sequence_length, device, dtype)
|
return self._cache_backend.init_state(batch_size, sequence_length, device, dtype)
|
||||||
|
|
||||||
def increment_step(self, state: dict, increment: int = 1):
|
def increment_step(self, state: dict, increment: int = 1):
|
||||||
|
|||||||
Reference in New Issue
Block a user