Skip to content

Training parameter settings, regarding codebooks #16

Description

@xinyinan9527

Operating system

Linux

Hardware

GPU with CUDA

Description

Awesome work!
However, I encountered a problem when training with Chinese corpus: the codebook and K values ​​did not match.

[rank0]:   File "/home/conda/envs/real_moshi/lib/python3.12/site-packages/moshi/models/lm.py", line 338, in forward
[rank0]:     assert K == self.num_codebooks, (K, self.num_codebooks)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: AssertionError: (9, 17)

I made some changes to the train.py file.
Around line 141, I made the following changes.

    mimi = checkpoint_info.get_mimi(device="cuda")
    # 重要:Moshi 7B 模型期望 n_q=16 个音频 codebooks
    # 必须手动设置 Mimi 使用正确的 codebooks 数量以匹配模型
    mimi.set_num_codebooks(lm_config["n_q"])
    main_logger_info(f"Mimi 设置为使用 {mimi.num_codebooks} 个 codebooks")
    mimi.eval()

Everything seems to be working now.

Extra information

nothing

Environment

Fill in the following information on your system.

  • Operating system version:
  • Python version:
  • PyTorch version:
  • CUDA version (run python -c 'import torch; print(torch.version.cuda)'):
  • GPU model and memory:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions