Spaces:
Running on Zero
Running on Zero
Commit ·
a4a16d2
1
Parent(s): e9d083e
Warm PersonaPlex under live inference mode
Browse files- streaming_app.py +14 -10
streaming_app.py
CHANGED
|
@@ -128,16 +128,20 @@ def prepare_assets(token):
|
|
| 128 |
|
| 129 |
|
| 130 |
def warmup(mimi, other_mimi, lm_gen, frame_size):
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
for
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
mimi.reset_streaming()
|
| 142 |
other_mimi.reset_streaming()
|
| 143 |
lm_gen.reset_streaming()
|
|
|
|
| 128 |
|
| 129 |
|
| 130 |
def warmup(mimi, other_mimi, lm_gen, frame_size):
|
| 131 |
+
# The live loop uses inference_mode. PyTorch specializes compiled graphs on
|
| 132 |
+
# that dispatch state, so warming under no_grad would force a recompile when
|
| 133 |
+
# CUDAGraphed starts capturing the first live depformer call.
|
| 134 |
+
with torch.inference_mode():
|
| 135 |
+
for _ in range(2):
|
| 136 |
+
chunk = torch.zeros(1, 1, frame_size, dtype=torch.float32, device=DEVICE)
|
| 137 |
+
codes = mimi.encode(chunk)
|
| 138 |
+
_ = other_mimi.encode(chunk)
|
| 139 |
+
for index in range(codes.shape[-1]):
|
| 140 |
+
tokens = lm_gen.step(codes[:, :, index:index + 1])
|
| 141 |
+
if tokens is not None:
|
| 142 |
+
_ = mimi.decode(tokens[:, 1:9])
|
| 143 |
+
_ = other_mimi.decode(tokens[:, 1:9])
|
| 144 |
+
torch.cuda.synchronize()
|
| 145 |
mimi.reset_streaming()
|
| 146 |
other_mimi.reset_streaming()
|
| 147 |
lm_gen.reset_streaming()
|