prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [Bug] RPC Server Can't Serve Through Proxy Because of Missing Command Line Option
  Now we have RPC server, proxy, and tracker, so if the host machine can't access the RPC server directly, then we can put RPC proxy between host machine and RPC server like "Host --> RPC Proxy --> RPC Server", we can do it from Python API, but we can't do it through command line. Because "tvm.exec.rpc_server" haven't exposed the parameter "is_proxy" of class "tvm.rpc.server.Server" through command line option.
  
  ### Expected behavior
  
  Can register the RPC server to RPC proxy from command line like something below.
  ```shell
  python -m tvm.exec.rpc_server --host 0.0.0.0 --port 9090 --through-proxy
  ```
  
  ### Actual behavior
  
  Currently haven't any command line option to set the parameter "is_proxy".
  
  ### Environment
  
  No
  
  ### Steps to reproduce
  
  Any
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `python/tvm/exec/rpc_server.py`
  Content:
  ```
  1 # Licensed to the Apache Software Foundation (ASF) under one
  2 # or more contributor license agreements.  See the NOTICE file
  3 # distributed with this work for additional information
  4 # regarding copyright ownership.  The ASF licenses this file
  5 # to you under the Apache License, Version 2.0 (the
  6 # "License"); you may not use this file except in compliance
  7 # with the License.  You may obtain a copy of the License at
  8 #
  9 #   http://www.apache.org/licenses/LICENSE-2.0
  10 #
  11 # Unless required by applicable law or agreed to in writing,
  12 # software distributed under the License is distributed on an
  13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14 # KIND, either express or implied.  See the License for the
  15 # specific language governing permissions and limitations
  16 # under the License.
  17 # pylint: disable=redefined-outer-name, invalid-name
  18 """Start an RPC server"""
  19 import argparse
  20 import logging
  21 from .. import rpc
  22 
  23 
  24 def main(args):
  25     """Main function
  26 
  27     Parameters
  28     ----------
  29     args : argparse.Namespace
  30         parsed args from command-line invocation
  31     """
  32     if args.tracker:
  33         url, port = args.tracker.rsplit(":", 1)
  34         port = int(port)
  35         tracker_addr = (url, port)
  36         if not args.key:
  37             raise RuntimeError("Need key to present type of resource when tracker is available")
  38     else:
  39         tracker_addr = None
  40 
  41     server = rpc.Server(
  42         args.host,
  43         args.port,
  44         args.port_end,
  45         key=args.key,
  46         tracker_addr=tracker_addr,
  47         load_library=args.load_library,
  48         custom_addr=args.custom_addr,
  49         silent=args.silent,
  50         no_fork=not args.fork,
  51     )
  52     server.proc.join()
  53 
  54 
  55 if __name__ == "__main__":
  56     parser = argparse.ArgumentParser()
  57     parser.add_argument(
  58         "--host", type=str, default="0.0.0.0", help="The host IP address the tracker binds to"
  59     )
  60     parser.add_argument("--port", type=int, default=9090, help="The port of the RPC")
  61     parser.add_argument("--port-end", type=int, default=9199, help="The end search port of the RPC")
  62     parser.add_argument(
  63         "--tracker",
  64         type=str,
  65         help=("The address of RPC tracker in host:port format. " "e.g. (10.77.1.234:9190)"),
  66     )
  67     parser.add_argument(
  68         "--key", type=str, default="", help="The key used to identify the device type in tracker."
  69     )
  70     parser.add_argument("--silent", action="store_true", help="Whether run in silent mode.")
  71     parser.add_argument("--load-library", type=str, help="Additional library to load")
  72     parser.add_argument(
  73         "--no-fork",
  74         dest="fork",
  75         action="store_false",
  76         help="Use spawn mode to avoid fork. This option \
  77                         is able to avoid potential fork problems with Metal, OpenCL \
  78                         and ROCM compilers.",
  79     )
  80     parser.add_argument(
  81         "--custom-addr", type=str, help="Custom IP Address to Report to RPC Tracker"
  82     )
  83 
  84     parser.set_defaults(fork=True)
  85     args = parser.parse_args()
  86     logging.basicConfig(level=logging.INFO)
  87     if not args.fork is False and not args.silent:
  88         logging.info(
  89             "If you are running ROCM/Metal, fork will cause "
  90             "compiler internal error. Try to launch with arg ```--no-fork```"
  91         )
  92     main(args)
  93
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/python/tvm/exec/rpc_server.py b/python/tvm/exec/rpc_server.py
  --- a/python/tvm/exec/rpc_server.py
  +++ b/python/tvm/exec/rpc_server.py
  @@ -42,6 +42,7 @@
           args.host,
           args.port,
           args.port_end,
  +        is_proxy=args.through_proxy,
           key=args.key,
           tracker_addr=tracker_addr,
           load_library=args.load_library,
  @@ -58,6 +59,15 @@
           "--host", type=str, default="0.0.0.0", help="The host IP address the tracker binds to"
       )
       parser.add_argument("--port", type=int, default=9090, help="The port of the RPC")
  +    parser.add_argument(
  +        "--through-proxy",
  +        dest="through_proxy",
  +        action="store_true",
  +        help=(
  +            "Whether this server provide service through a proxy. If this is true, the host and"
  +            "port actually is the address of the proxy."
  +        ),
  +    )
       parser.add_argument("--port-end", type=int, default=9199, help="The end search port of the RPC")
       parser.add_argument(
           "--tracker",
  
verification_info: {"golden_diff": "diff --git a/python/tvm/exec/rpc_server.py b/python/tvm/exec/rpc_server.py\n--- a/python/tvm/exec/rpc_server.py\n+++ b/python/tvm/exec/rpc_server.py\n@@ -42,6 +42,7 @@\n         args.host,\n         args.port,\n         args.port_end,\n+        is_proxy=args.through_proxy,\n         key=args.key,\n         tracker_addr=tracker_addr,\n         load_library=args.load_library,\n@@ -58,6 +59,15 @@\n         \"--host\", type=str, default=\"0.0.0.0\", help=\"The host IP address the tracker binds to\"\n     )\n     parser.add_argument(\"--port\", type=int, default=9090, help=\"The port of the RPC\")\n+    parser.add_argument(\n+        \"--through-proxy\",\n+        dest=\"through_proxy\",\n+        action=\"store_true\",\n+        help=(\n+            \"Whether this server provide service through a proxy. If this is true, the host and\"\n+            \"port actually is the address of the proxy.\"\n+        ),\n+    )\n     parser.add_argument(\"--port-end\", type=int, default=9199, help=\"The end search port of the RPC\")\n     parser.add_argument(\n         \"--tracker\",\n", "issue": "[Bug] RPC Server Can't Serve Through Proxy Because of Missing Command Line Option\nNow we have RPC server, proxy, and tracker, so if the host machine can't access the RPC server directly, then we can put RPC proxy between host machine and RPC server like \"Host --> RPC Proxy --> RPC Server\", we can do it from Python API, but we can't do it through command line. Because \"tvm.exec.rpc_server\" haven't exposed the parameter \"is_proxy\" of class \"tvm.rpc.server.Server\" through command line option.\r\n\r\n### Expected behavior\r\n\r\nCan register the RPC server to RPC proxy from command line like something below.\r\n```shell\r\npython -m tvm.exec.rpc_server --host 0.0.0.0 --port 9090 --through-proxy\r\n```\r\n\r\n### Actual behavior\r\n\r\nCurrently haven't any command line option to set the parameter \"is_proxy\".\r\n\r\n### Environment\r\n\r\nNo\r\n\r\n### Steps to reproduce\r\n\r\nAny\n", "before_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n# pylint: disable=redefined-outer-name, invalid-name\n\"\"\"Start an RPC server\"\"\"\nimport argparse\nimport logging\nfrom .. import rpc\n\n\ndef main(args):\n    \"\"\"Main function\n\n    Parameters\n    ----------\n    args : argparse.Namespace\n        parsed args from command-line invocation\n    \"\"\"\n    if args.tracker:\n        url, port = args.tracker.rsplit(\":\", 1)\n        port = int(port)\n        tracker_addr = (url, port)\n        if not args.key:\n            raise RuntimeError(\"Need key to present type of resource when tracker is available\")\n    else:\n        tracker_addr = None\n\n    server = rpc.Server(\n        args.host,\n        args.port,\n        args.port_end,\n        key=args.key,\n        tracker_addr=tracker_addr,\n        load_library=args.load_library,\n        custom_addr=args.custom_addr,\n        silent=args.silent,\n        no_fork=not args.fork,\n    )\n    server.proc.join()\n\n\nif __name__ == \"__main__\":\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        \"--host\", type=str, default=\"0.0.0.0\", help=\"The host IP address the tracker binds to\"\n    )\n    parser.add_argument(\"--port\", type=int, default=9090, help=\"The port of the RPC\")\n    parser.add_argument(\"--port-end\", type=int, default=9199, help=\"The end search port of the RPC\")\n    parser.add_argument(\n        \"--tracker\",\n        type=str,\n        help=(\"The address of RPC tracker in host:port format. \" \"e.g. (10.77.1.234:9190)\"),\n    )\n    parser.add_argument(\n        \"--key\", type=str, default=\"\", help=\"The key used to identify the device type in tracker.\"\n    )\n    parser.add_argument(\"--silent\", action=\"store_true\", help=\"Whether run in silent mode.\")\n    parser.add_argument(\"--load-library\", type=str, help=\"Additional library to load\")\n    parser.add_argument(\n        \"--no-fork\",\n        dest=\"fork\",\n        action=\"store_false\",\n        help=\"Use spawn mode to avoid fork. This option \\\n                        is able to avoid potential fork problems with Metal, OpenCL \\\n                        and ROCM compilers.\",\n    )\n    parser.add_argument(\n        \"--custom-addr\", type=str, help=\"Custom IP Address to Report to RPC Tracker\"\n    )\n\n    parser.set_defaults(fork=True)\n    args = parser.parse_args()\n    logging.basicConfig(level=logging.INFO)\n    if not args.fork is False and not args.silent:\n        logging.info(\n            \"If you are running ROCM/Metal, fork will cause \"\n            \"compiler internal error. Try to launch with arg ```--no-fork```\"\n        )\n    main(args)\n", "path": "python/tvm/exec/rpc_server.py"}], "after_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n# pylint: disable=redefined-outer-name, invalid-name\n\"\"\"Start an RPC server\"\"\"\nimport argparse\nimport logging\nfrom .. import rpc\n\n\ndef main(args):\n    \"\"\"Main function\n\n    Parameters\n    ----------\n    args : argparse.Namespace\n        parsed args from command-line invocation\n    \"\"\"\n    if args.tracker:\n        url, port = args.tracker.rsplit(\":\", 1)\n        port = int(port)\n        tracker_addr = (url, port)\n        if not args.key:\n            raise RuntimeError(\"Need key to present type of resource when tracker is available\")\n    else:\n        tracker_addr = None\n\n    server = rpc.Server(\n        args.host,\n        args.port,\n        args.port_end,\n        is_proxy=args.through_proxy,\n        key=args.key,\n        tracker_addr=tracker_addr,\n        load_library=args.load_library,\n        custom_addr=args.custom_addr,\n        silent=args.silent,\n        no_fork=not args.fork,\n    )\n    server.proc.join()\n\n\nif __name__ == \"__main__\":\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        \"--host\", type=str, default=\"0.0.0.0\", help=\"The host IP address the tracker binds to\"\n    )\n    parser.add_argument(\"--port\", type=int, default=9090, help=\"The port of the RPC\")\n    parser.add_argument(\n        \"--through-proxy\",\n        dest=\"through_proxy\",\n        action=\"store_true\",\n        help=(\n            \"Whether this server provide service through a proxy. If this is true, the host and\"\n            \"port actually is the address of the proxy.\"\n        ),\n    )\n    parser.add_argument(\"--port-end\", type=int, default=9199, help=\"The end search port of the RPC\")\n    parser.add_argument(\n        \"--tracker\",\n        type=str,\n        help=(\"The address of RPC tracker in host:port format. \" \"e.g. (10.77.1.234:9190)\"),\n    )\n    parser.add_argument(\n        \"--key\", type=str, default=\"\", help=\"The key used to identify the device type in tracker.\"\n    )\n    parser.add_argument(\"--silent\", action=\"store_true\", help=\"Whether run in silent mode.\")\n    parser.add_argument(\"--load-library\", type=str, help=\"Additional library to load\")\n    parser.add_argument(\n        \"--no-fork\",\n        dest=\"fork\",\n        action=\"store_false\",\n        help=\"Use spawn mode to avoid fork. This option \\\n                        is able to avoid potential fork problems with Metal, OpenCL \\\n                        and ROCM compilers.\",\n    )\n    parser.add_argument(\n        \"--custom-addr\", type=str, help=\"Custom IP Address to Report to RPC Tracker\"\n    )\n\n    parser.set_defaults(fork=True)\n    args = parser.parse_args()\n    logging.basicConfig(level=logging.INFO)\n    if not args.fork is False and not args.silent:\n        logging.info(\n            \"If you are running ROCM/Metal, fork will cause \"\n            \"compiler internal error. Try to launch with arg ```--no-fork```\"\n        )\n    main(args)\n", "path": "python/tvm/exec/rpc_server.py"}]}