Is there a way to add trust_remote_code=True param to the convert app? otherwise, cannot convert.

#17
by PengZhang424242 - opened

For some models cannot convert due to not to set trust_remote_code=True.

ONNX Community org

Yes, it's possible. I've added the parameter to the execution of the script.
Please try now and let us know if it worked.

ONNX Community org

@Felladrin Just a reminder than this may be used be a malicious actor to obtain the HF_TOKEN used for uploading. For that reason, I disabled it again for now until we have a better solution for conversion: https://huggingface.co/spaces/onnx-community/convert-to-onnx/commit/98ae8d1555c7ebf7193255fd1aed23130941079f

ONNX Community org

Got it, @Xenova ! I hope we can find better way to do this.

ONNX Community org

just have a toggle for the parameter?

ONNX Community org

i did it: https://huggingface.co/spaces/onnx-community/convert-to-onnx/discussions/19

@1TSnakers , that’s a great idea! I also liked the warning you added.

I’m okay with that, as long as the user is required to use their own Access Token if the “trust_remote_code” toggle is enabled. Could you make this change?
Currently, inputting the access token is optional. If the token is empty, the access token used is the one set in the environment variable, which has write access to https://huggingface.co/spaces/onnx-community.

What do you think, @Xenova ?

ONNX Community org

updated!

ONNX Community org

Thanks, @1TSnakers ! The PR looks good to me. But we'll also need @Xenova 's approval on this one.

ONNX Community org

Hey, @Xenova 👋

When you have a chance, could you please check if it's fine to enable trust_remote_code only when the user use their own access token and voluntarily enables the trust_remote_code switch, as @1TSnakers is proposing in this PR?

ONNX Community org
edited 11 days ago

Hi! This is indeed a much better solution and could work well.

Are we sure that the proposed solution uses the user's token when specified though? At first glance, it looks like it's still using the space's token.

image.png

We'd probably need to append this to the call to running the subprocess (for download and upload). See docs.

ONNX Community org
edited 9 days ago

Good question!

I've made some tests and confirmed that when we set env={} in a subprocess, the subprocess won't have any access of the system environment variables.

But changed it to specifically set the HF_TOKEN as gated models will need the subprocess to have access to it.

env={
    "HF_TOKEN": self.config.hf_token,
},

Note: self.config.hf_token will always have some value. If the user has set their own token, it will have the user's token. Otherwise, it will have the token defined in the system.

The PR has been updated.

ONNX Community org

The PR has been merged, and we now have the toggle button for trusting remote code.

image.png

Sign up or log in to comment