Skip to content

Conversation

@mmangkad
Copy link
Contributor

@mmangkad mmangkad commented Nov 6, 2025

Add trust remote code for Kimi-K2-Thinking

(APIServer pid=4) Traceback (most recent call last):
(APIServer pid=4)   File "/usr/local/bin/vllm", line 10, in <module>
(APIServer pid=4)     sys.exit(main())
(APIServer pid=4)              ^^^^^^
(APIServer pid=4)   File "/vllm/vllm/entrypoints/cli/main.py", line 73, in main
(APIServer pid=4)     args.dispatch_function(args)
(APIServer pid=4)   File "/vllm/vllm/entrypoints/cli/serve.py", line 59, in cmd
(APIServer pid=4)     uvloop.run(run_server(args))
(APIServer pid=4)   File "/usr/local/lib/python3.12/site-packages/uvloop/__init__.py", line 96, in run
(APIServer pid=4)     return __asyncio.run(
(APIServer pid=4)            ^^^^^^^^^^^^^^
(APIServer pid=4)   File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
(APIServer pid=4)     return runner.run(main)
(APIServer pid=4)            ^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
(APIServer pid=4)     return self._loop.run_until_complete(task)
(APIServer pid=4)            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
(APIServer pid=4)   File "/usr/local/lib/python3.12/site-packages/uvloop/__init__.py", line 48, in wrapper
(APIServer pid=4)     return await main
(APIServer pid=4)            ^^^^^^^^^^
(APIServer pid=4)   File "/vllm/vllm/entrypoints/openai/api_server.py", line 2007, in run_server
(APIServer pid=4)     await run_server_worker(listen_address, sock, args, **uvicorn_kwargs)
(APIServer pid=4)   File "/vllm/vllm/entrypoints/openai/api_server.py", line 2026, in run_server_worker
(APIServer pid=4)     async with build_async_engine_client(
(APIServer pid=4)                ^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
(APIServer pid=4)     return await anext(self.gen)
(APIServer pid=4)            ^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "/vllm/vllm/entrypoints/openai/api_server.py", line 195, in build_async_engine_client
(APIServer pid=4)     async with build_async_engine_client_from_engine_args(
(APIServer pid=4)                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
(APIServer pid=4)     return await anext(self.gen)
(APIServer pid=4)            ^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "/vllm/vllm/entrypoints/openai/api_server.py", line 221, in build_async_engine_client_from_engine_args
(APIServer pid=4)     vllm_config = engine_args.create_engine_config(usage_context=usage_context)
(APIServer pid=4)                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "/vllm/vllm/engine/arg_utils.py", line 1315, in create_engine_config
(APIServer pid=4)     model_config = self.create_model_config()
(APIServer pid=4)                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=4)   File "/vllm/vllm/engine/arg_utils.py", line 1170, in create_model_config
(APIServer pid=4)     return ModelConfig(
(APIServer pid=4)            ^^^^^^^^^^^^
(APIServer pid=4)   File "/usr/local/lib/python3.12/site-packages/pydantic/_internal/_dataclasses.py", line 121, in __init__
(APIServer pid=4)     s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s)
(APIServer pid=4) pydantic_core._pydantic_core.ValidationError: 1 validation error for ModelConfig
(APIServer pid=4)   Value error, The repository moonshotai/Kimi-K2-Thinking contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co/moonshotai/Kimi-K2-Thinking .
(APIServer pid=4)  You can inspect the repository content at https://hf.co/moonshotai/Kimi-K2-Thinking.
(APIServer pid=4) Please pass the argument `trust_remote_code=True` to allow custom code to be run. [type=value_error, input_value=ArgsKwargs((), {'model': ...rocessor_plugin': None}), input_type=ArgsKwargs]
(APIServer pid=4)     For further information visit https://errors.pydantic.dev/2.12/v/value_error

cc @jeejeelee

Add trust remote code for Kimi-K2-Thinking

Signed-off-by: Mohammad Miadh Angkad <[email protected]>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mmangkad, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the documentation for serving the moonshotai/Kimi-K2-Thinking model using vllm. The primary change involves adding the --trust-remote-code flag to the example vllm serve commands, which is essential for models that incorporate custom code in their definitions. This ensures that users can successfully execute the provided commands and properly load the model, enhancing the clarity and correctness of the documentation.

Highlights

  • Documentation Update for vllm serve: The --trust-remote-code flag has been added to two vllm serve command examples within the moonshotai/Kimi-K2-Think.md file. This flag is crucial for correctly loading models that rely on custom code.
  • Minor Formatting Fix: A small adjustment was made to ensure the moonshotai/Kimi-K2-Think.md file ends with a newline character, improving file consistency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly adds the --trust-remote-code flag to the vllm serve example commands in the documentation for the Kimi-K2-Thinking model, which is a necessary change. The change also adds a newline at the end of the file, which is good practice. My review includes one suggestion to improve the documentation by adding a note about the security implications of using the --trust-remote-code flag.


```bash
vllm serve moonshotai/Kimi-K2-Thinking \
--trust-remote-code \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While adding --trust-remote-code is necessary for this model to run, it's good practice to also inform users about the security implications of this flag. It allows arbitrary code execution from the model's repository. Consider adding a brief note in the documentation (for both this command and the one in the 'DCP Usage' section) to advise users to only use this flag if they trust the model's source.

Copy link
Collaborator

@jeejeelee jeejeelee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@jeejeelee jeejeelee merged commit b74da07 into vllm-project:main Nov 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants