View on GitHub
"```python\nfrom modal_training_gym.deploy_recipes.sglang_recipe import SglangRecipe\n```\n\nSGLang serving configuration.\n\n**Inherits from:** `BaseDeployRecipe`\n\n## Fields\n\n| Field | Type | Default | Description |\n|-------|------|---------|-------------|\n| `recipe_type` | `DeployRecipeType` | `sglang` | |\n| `gpu` | `Literal['H100', 'H200', 'B200', 'B300']` | `\"H100\"` | GPU type for the serving container. Default `\"H100\"`. |\n| `tp` | `int \\| None` | `None` | Tensor parallelism degree. Default `None` (SGLang infers from GPU count). |\n| `dp` | `int \\| None` | `None` | Data parallelism degree. Emitted as `--dp-size` and enables `--enable-dp-attention` when set. Default `None`. |\n| `context_length` | `int \\| None` | `None` | Maximum context length. Default `None` (model default). |\n| `mem_fraction_static` | `float \\| None` | `None` | Fraction of GPU memory for KV cache. Default `None` (SGLang default). |\n| `chunked_prefill_size` | `int \\| None` | `None` | Chunked prefill token budget. Default `None`. |\n| `max_running_requests` | `int \\| None` | `None` | Max concurrent requests per worker. Default `None`. |\n| `sglang_image` | `str` | `\"lmsysorg/sglang:v0.5.12\"` | Docker image tag for the SGLang container. Default is a recent nightly. |\n| `extra_server_args` | `dict[str, str] \\| None` | `None` | Additional `--flag value` pairs passed to `sglang.launch_server`. Use an empty string value for boolean flags (e.g. `{\"--trust-remote-code\": \"\"}`). Default `None`. |\n| `env_vars` | `dict[str, str]` | `{}` | Extra environment variables baked into the serving image (e.g. DeepGEMM MegaMoE knobs). Merged on top of the base HF cache env. Default empty. |\n| `install_transformers_from_git` | `bool` | `True` | If `True` (default), the serve image `pip install`s transformers from GitHub so brand-new architectures (historically DeepSeek-V4 on older SGLang tags) are recognized by `AutoConfig`. Set `False` when the chosen `sglang_image` already ships a compatible transformers — otherwise the git install double-registers configs (e.g. `qwen3_asr`) and the server crashloops on import. |\n| `environment_name` | `str \\| None` | `None` | Modal environment to deploy into. Default `None`. |\n| `deploy_strategy` | `str` | `\"rolling\"` | Modal deployment strategy. Default `\"rolling\"`. |\n| `startup_timeout` | `int` | `1200` | Seconds the server container is allowed to spend in startup before Modal kills it — gates both Modal's container `startup_timeout` and the SGLang health-check poll. Bump this for very large models whose weight load exceeds the default (e.g. GLM-4.7 at 355B, Kimi-K2.5 at ~1T). Default `1200` (20 minutes). |\n\n## Methods\n\n### `server_args(self, *, served_model_name: 'str') -> 'dict[str, str]'`\n\nBuild the `--flag value` dict for the SGLang launch command.\n\n**Source:** [`modal_training_gym/deploy_recipes/sglang_recipe.py`](https://github.com/modal-projects/training-gym/blob/main/modal_training_gym/deploy_recipes/sglang_recipe.py)\n"
SglangRecipe
SGLang serving configuration.
from modal_training_gym.deploy_recipes.sglang_recipe import SglangRecipeSGLang serving configuration.
Inherits from: BaseDeployRecipe
Fields
Section titled “Fields”| Field | Type | Default | Description |
|---|---|---|---|
recipe_type | DeployRecipeType | sglang | |
gpu | Literal['H100', 'H200', 'B200', 'B300'] | "H100" | GPU type for the serving container. Default "H100". |
tp | int | None | None | Tensor parallelism degree. Default None (SGLang infers from GPU count). |
dp | int | None | None | Data parallelism degree. Emitted as --dp-size and enables --enable-dp-attention when set. Default None. |
context_length | int | None | None | Maximum context length. Default None (model default). |
mem_fraction_static | float | None | None | Fraction of GPU memory for KV cache. Default None (SGLang default). |
chunked_prefill_size | int | None | None | Chunked prefill token budget. Default None. |
max_running_requests | int | None | None | Max concurrent requests per worker. Default None. |
sglang_image | str | "lmsysorg/sglang:v0.5.12" | Docker image tag for the SGLang container. Default is a recent nightly. |
extra_server_args | dict[str, str] | None | None | Additional --flag value pairs passed to sglang.launch_server. Use an empty string value for boolean flags (e.g. {"--trust-remote-code": ""}). Default None. |
env_vars | dict[str, str] | {} | Extra environment variables baked into the serving image (e.g. DeepGEMM MegaMoE knobs). Merged on top of the base HF cache env. Default empty. |
install_transformers_from_git | bool | True | If True (default), the serve image pip installs transformers from GitHub so brand-new architectures (historically DeepSeek-V4 on older SGLang tags) are recognized by AutoConfig. Set False when the chosen sglang_image already ships a compatible transformers — otherwise the git install double-registers configs (e.g. qwen3_asr) and the server crashloops on import. |
environment_name | str | None | None | Modal environment to deploy into. Default None. |
deploy_strategy | str | "rolling" | Modal deployment strategy. Default "rolling". |
startup_timeout | int | 1200 | Seconds the server container is allowed to spend in startup before Modal kills it — gates both Modal’s container startup_timeout and the SGLang health-check poll. Bump this for very large models whose weight load exceeds the default (e.g. GLM-4.7 at 355B, Kimi-K2.5 at ~1T). Default 1200 (20 minutes). |
Methods
Section titled “Methods”server_args(self, *, served_model_name: 'str') -> 'dict[str, str]'
Section titled “server_args(self, *, served_model_name: 'str') -> 'dict[str, str]'”Build the --flag value dict for the SGLang launch command.