Skip to content

Commit 7489eff

Browse files
justinchubyCopilot
andcommitted
personaplex: default server to 127.0.0.1; fix branch lint warnings
- server.py/README: default --host to 127.0.0.1 (localhost) instead of 0.0.0.0, matching the documented SSH port-forward workflow and avoiding binding to all interfaces by default. - Fix ruff warnings across the Moshi branch: D205 docstring summary/blank line (mimi.py), RUF005 list concatenation -> unpacking (golden script + integration test). Import sort/format auto-applied by lintrunner. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
1 parent 7928a81 commit 7489eff

5 files changed

Lines changed: 19 additions & 12 deletions

File tree

examples/personaplex/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The server only loads ONNX models, so it can run in a lightweight
5454
pip install aiohttp onnxruntime-gpu numpy sentencepiece huggingface_hub
5555
python examples/personaplex/server.py \
5656
--model-dir output/personaplex/onnx --device cuda \
57-
--host 0.0.0.0 --port 7681
57+
--host 127.0.0.1 --port 7681
5858
```
5959

6060
On Ampere+/H200 GPUs ORT defaults to TF32 for fp32 matmuls, which can flip

examples/personaplex/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
pip install aiohttp sentencepiece huggingface_hub
3131
python examples/personaplex/server.py \
3232
--model-dir output/personaplex/onnx --device cuda \
33-
--host 0.0.0.0 --port 7681
33+
--host 127.0.0.1 --port 7681
3434
3535
Open ``http://localhost:7681`` (or port-forward the remote port over SSH:
3636
``ssh -L 7681:localhost:7681 <host>``), set a persona / optional voice sample,
@@ -254,7 +254,7 @@ def main() -> None:
254254
action="store_true",
255255
help="keep CUDA TF32 (faster, lower precision) for fp32 matmuls",
256256
)
257-
parser.add_argument("--host", default="0.0.0.0")
257+
parser.add_argument("--host", default="127.0.0.1")
258258
parser.add_argument("--port", type=int, default=7681)
259259
parser.add_argument(
260260
"--tokenizer",

scripts/generate_moshi_lm_golden.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def make_prev_tokens() -> list[int]:
5757
rng = np.random.RandomState(7)
5858
text_prev = int(rng.randint(0, TEXT_CARD))
5959
audio_prev = rng.randint(0, AUDIO_CARD, size=DEP_Q - 1).tolist()
60-
return [text_prev] + audio_prev
60+
return [text_prev, *audio_prev]
6161

6262

6363
def _resolve_lm(model: str) -> str:

src/mobius/models/mimi.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
from __future__ import annotations
3737

38-
3938
import numpy as np
4039
import onnx_ir as ir
4140
import torch
@@ -236,8 +235,10 @@ def forward(self, op: OpBuilder, x: ir.Value):
236235

237236

238237
class _ELU(nn.Module):
239-
"""ELU activation (alpha=1.0); paramless, kept in the module list to
240-
preserve Kyutai ``model.<i>`` indexing."""
238+
"""ELU activation (alpha=1.0).
239+
240+
Paramless; kept in the module list to preserve Kyutai ``model.<i>`` indexing.
241+
"""
241242

242243
def forward(self, op: OpBuilder, x: ir.Value):
243244
return op.Elu(x, alpha=1.0)
@@ -687,8 +688,11 @@ def _interleaved_to_halfsplit(w: torch.Tensor, head_dim: int) -> torch.Tensor:
687688
def _convert_transformer_layer(
688689
out: dict[str, torch.Tensor], prefix: str, lprefix: str, sd: dict
689690
) -> None:
690-
"""Convert one Kyutai transformer layer (``lprefix``) into mobius names
691-
under ``prefix`` (the fully-qualified ``<enc|dec>oder.<...>.layers.<i>``)."""
691+
"""Convert one Kyutai transformer layer into mobius parameter names.
692+
693+
``lprefix`` is the Kyutai source prefix; ``prefix`` is the fully-qualified
694+
destination (``<enc|dec>oder.<...>.layers.<i>``).
695+
"""
692696
# Norms
693697
out[f"{prefix}.input_layernorm.weight"] = sd[f"{lprefix}.norm1.weight"]
694698
out[f"{prefix}.input_layernorm.bias"] = sd[f"{lprefix}.norm1.bias"]
@@ -711,8 +715,11 @@ def _convert_transformer_layer(
711715

712716

713717
def _codebook_embedding(sd: dict, prefix: str) -> torch.Tensor:
714-
"""Reconstruct a codebook embedding table from ``embedding_sum`` and
715-
``cluster_usage`` (Kyutai stores running statistics, not the table)."""
718+
"""Reconstruct a codebook embedding table from running statistics.
719+
720+
Kyutai stores ``embedding_sum`` and ``cluster_usage`` (running statistics),
721+
not the embedding table itself.
722+
"""
716723
embedding_sum = sd[f"{prefix}.embedding_sum"].float() # (bins, dim)
717724
cluster_usage = sd[f"{prefix}.cluster_usage"].float() # (bins,)
718725
denom = cluster_usage.clamp(min=1e-8).unsqueeze(-1)

tests/moshi_lm_integration_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _make_prev_tokens() -> list[int]:
6464
rng = np.random.RandomState(7)
6565
text_prev = int(rng.randint(0, _TEXT_CARD))
6666
audio_prev = rng.randint(0, _AUDIO_CARD, size=_DEP_Q - 1).tolist()
67-
return [text_prev] + audio_prev
67+
return [text_prev, *audio_prev]
6868

6969

7070
def _find_onnx(root: str) -> str:

0 commit comments

Comments
 (0)