RVC-Project / RVC-Project/Retrieval-based-Voice-Conversion-WebUI

Error using torch.save after loaded and traced hubert model with infer.lib.jit.to_jit_model

Open
#2,049 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
38.4k
Forks
5.3k
PR merge metrics
No merged PRs in 30d

Description

I need to bring the model in c++ but I'm encountering some problem in saving hubert using TorchScript.
The following error appeare after I run torch.save for the traced model.

Could not export Python function call 'GradMultiply'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__

The error is reproducible using the following code

import os
import sys

now_dir = os.getcwd()
sys.path.append(now_dir)

from infer.lib.jit import to_jit_model

hb_model, traced = to_jit_model("assets/hubert/hubert_base.pt", "hubert", "trace", "assets/hubert/hubert_inputs.pth")

#after creating a folder traced
traced.save("traced/hubert_traced.pt")

I understand that maybe the problem is related with lib fairseq also, but I hope it can be resolved here

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by rerunning the provided example through infer.lib.jit.to_jit_model with assets/hubert/hubert_base.pt and assets/hubert/hubert_inputs.pth. Trace where GradMultiply is encountered during traced.save("traced/hubert_traced.pt") and check the related fairseq interaction. Done means the traced Hubert model saves successfully and remains usable for the intended C++ integration.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.