Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ Dynamo provides a simple way to spin up a local set of inference components incl
- **Workers** – Set of pre-configured LLM serving engines.

```
# Start an OpenAI compatible HTTP server, a pre-processor (prompt templating and tokenization) and a router:
python -m dynamo.frontend --http-port 8080
# Start an OpenAI compatible HTTP server, a pre-processor (prompt templating and tokenization) and a router.
# Pass the TLS certificate and key paths to use HTTPS instead of HTTP.
python -m dynamo.frontend --http-port 8080 [--tls-cert-path cert.pem] [--tls-key-path key.pem]

# Start the SGLang engine, connecting to NATS and etcd to receive requests. You can run several of these,
# both for the same model and for multiple models. The frontend node will discover them.
Expand Down
23 changes: 23 additions & 0 deletions components/frontend/src/dynamo/frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
# Worker example:
# - cd lib/bindings/python/examples/hello_world
# - python server_sglang_static.py
#
# For TLS:
# - python -m dynamo.frontend --http-port 8443 --tls-cert-path cert.pem --tls-key-path key.pem
#

import argparse
import asyncio
import os
import pathlib
import re

import uvloop
Expand Down Expand Up @@ -85,6 +90,18 @@ def parse_args():
parser.add_argument(
"--http-port", type=int, default=8080, help="HTTP port for the engine (u16)."
)
parser.add_argument(
"--tls-cert-path",
type=pathlib.Path,
default=None,
help="TLS certificate path, PEM format.",
)
parser.add_argument(
"--tls-key-path",
type=pathlib.Path,
default=None,
help="TLS certificate key path, PEM format.",
)
parser.add_argument(
"--router-mode",
type=str,
Expand Down Expand Up @@ -149,6 +166,8 @@ def parse_args():

if flags.static_endpoint and (not flags.model_name or not flags.model_path):
parser.error("--static-endpoint requires both --model-name and --model-path")
if bool(flags.tls_cert_path) ^ bool(flags.tls_key_path): # ^ is XOR
parser.error("--tls-cert-path and --tls-key-path must be provided together")

return flags

Expand Down Expand Up @@ -192,6 +211,10 @@ async def async_main():
kwargs["model_name"] = flags.model_name
if flags.model_path:
kwargs["model_path"] = flags.model_path
if flags.tls_cert_path:
kwargs["tls_cert_path"] = flags.tls_cert_path
if flags.tls_key_path:
kwargs["tls_key_path"] = flags.tls_key_path

if is_static:
# out=dyn://<static_endpoint>
Expand Down
9 changes: 9 additions & 0 deletions launch/dynamo-run/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ pub struct Flags {
pub model_path_flag: Option<PathBuf>,

/// HTTP port. `in=http` only
/// If tls_cert_path and tls_key_path are provided, this will be TLS/HTTPS.
#[arg(long, default_value = "8080")]
pub http_port: u16,

/// TLS certificate file
#[arg(long, requires = "tls_key_path")]
pub tls_cert_path: Option<PathBuf>,

/// TLS certificate key file
#[arg(long, requires = "tls_cert_path")]
pub tls_key_path: Option<PathBuf>,

/// The name of the model we are serving
#[arg(long)]
pub model_name: Option<String>,
Expand Down
6 changes: 4 additions & 2 deletions launch/dynamo-run/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub async fn run(
runtime: Runtime,
in_opt: Input,
out_opt: Option<Output>,
flags: Flags,
mut flags: Flags,
) -> anyhow::Result<()> {
//
// Configure
Expand All @@ -39,7 +39,9 @@ pub async fn run(
.kv_cache_block_size(flags.kv_cache_block_size)
// Only set if user provides. Usually loaded from tokenizer_config.json
.context_length(flags.context_length)
.http_port(Some(flags.http_port))
.http_port(flags.http_port)
.tls_cert_path(flags.tls_cert_path.take())
.tls_key_path(flags.tls_key_path.take())
.router_config(Some(flags.router_config()))
.request_template(flags.request_template.clone())
.migration_limit(flags.migration_limit)
Expand Down
Loading
Loading