Commit f6dbd240 authored by Lianmin Zheng's avatar Lianmin Zheng
Browse files

Improve doc strings (#518)

parent e8a2327d
...@@ -10,8 +10,8 @@ SGLang is a structured generation language designed for large language models (L ...@@ -10,8 +10,8 @@ SGLang is a structured generation language designed for large language models (L
It makes your interaction with LLMs faster and more controllable by co-designing the frontend language and the runtime system. It makes your interaction with LLMs faster and more controllable by co-designing the frontend language and the runtime system.
The core features include: The core features include:
- **A Flexible Front-End Language**: This allows for easy programming of LLM applications with multiple chained generation calls, advanced prompting techniques, control flow, multiple modalities, parallelism, and external interaction. - **Flexible Frontend Language**: Enables easy programming of LLM applications with chained generation calls, advanced prompting, control flow, multiple modalities, parallelism, and external interactions.
- **A High-Performance Runtime with RadixAttention**: This feature significantly accelerates the execution of complex LLM programs by automatically reusing the KV cache across multiple calls. It can also be used as a standalone serving engine with all common techniques implemented, such as continuous batching and tensor parallelism. - **High-Performance Backend Runtime**: Features RadixAttention for accelerating complex LLM programs by reusing the KV cache across multiple calls. It can also serve as a standalone engine with all common techniques implemented (e.g., continuous batching and tensor parallelism).
## News ## News
- [2024/02] 🔥 SGLang enables **3x faster JSON decoding** with compressed finite state machine ([blog](https://lmsys.org/blog/2024-02-05-compressed-fsm/)). - [2024/02] 🔥 SGLang enables **3x faster JSON decoding** with compressed finite state machine ([blog](https://lmsys.org/blog/2024-02-05-compressed-fsm/)).
...@@ -403,10 +403,10 @@ https://github.com/sgl-project/sglang/issues/157 ...@@ -403,10 +403,10 @@ https://github.com/sgl-project/sglang/issues/157
## Citation And Acknowledgment ## Citation And Acknowledgment
``` ```
@misc{zheng2023efficiently, @misc{zheng2024sglang,
title={Efficiently Programming Large Language Models using SGLang}, title={SGLang: Efficient Execution of Structured Language Model Programs},
author={Lianmin Zheng and Liangsheng Yin and Zhiqiang Xie and Jeff Huang and Chuyue Sun and Cody Hao Yu and Shiyi Cao and Christos Kozyrakis and Ion Stoica and Joseph E. Gonzalez and Clark Barrett and Ying Sheng}, author={Lianmin Zheng and Liangsheng Yin and Zhiqiang Xie and Chuyue Sun and Jeff Huang and Cody Hao Yu and Shiyi Cao and Christos Kozyrakis and Ion Stoica and Joseph E. Gonzalez and Clark Barrett and Ying Sheng},
year={2023}, year={2024},
eprint={2312.07104}, eprint={2312.07104},
archivePrefix={arXiv}, archivePrefix={arXiv},
primaryClass={cs.AI} primaryClass={cs.AI}
......
"""Some Public API Definitions""" """Public APIs of the language."""
import os import os
import re import re
......
"""Launch the inference server."""
import argparse import argparse
from sglang.srt.server import ServerArgs, launch_server from sglang.srt.server import ServerArgs, launch_server
...@@ -8,4 +10,4 @@ if __name__ == "__main__": ...@@ -8,4 +10,4 @@ if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
server_args = ServerArgs.from_cli_args(args) server_args = ServerArgs.from_cli_args(args)
launch_server(server_args, None) launch_server(server_args, None)
\ No newline at end of file
"""Launch the inference server for Llava-video model."""
import argparse import argparse
import multiprocessing as mp import multiprocessing as mp
......
"""Cache for the compressed finite state machine."""
from sglang.srt.constrained import RegexFSM, TransformerTokenizer from sglang.srt.constrained import RegexFSM, TransformerTokenizer
from sglang.srt.constrained.base_cache import BaseCache from sglang.srt.constrained.base_cache import BaseCache
......
"""
Faster constrained decoding.
Reference: https://lmsys.org/blog/2024-02-05-compressed-fsm/
"""
import interegular import interegular
from sglang.srt.constrained import FSMInfo, disk_cache, make_deterministic_fsm from sglang.srt.constrained import FSMInfo, disk_cache, make_deterministic_fsm
......
"""Conversation templates."""
# Adapted from # Adapted from
# https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py # https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py
import dataclasses import dataclasses
......
""" """
Flush the KV cache.
Usage: Usage:
python3 -m sglang.srt.flush_cache --url http://localhost:30000 python3 -m sglang.srt.flush_cache --url http://localhost:30000
""" """
......
"""Logits processing."""
import torch import torch
from torch import nn from torch import nn
from vllm.distributed import ( from vllm.distributed import (
......
"""Radix attention."""
import torch import torch
import numpy as np import numpy as np
from torch import nn from torch import nn
......
"""A data parallel worker thread.""" """A data parallel worker thread."""
import asyncio import asyncio
import logging import logging
import queue import queue
......
"""Meta data for requests and batches""" """Meta data for requests and batches"""
from dataclasses import dataclass from dataclasses import dataclass
from enum import IntEnum, auto from enum import IntEnum, auto
from typing import List from typing import List
......
"""ModelRunner runs the forward passes of the models."""
import importlib import importlib
import importlib.resources import importlib.resources
import logging import logging
......
"""
The radix tree data structure for managing the KV cache.
"""
import heapq import heapq
import time import time
from collections import defaultdict from collections import defaultdict
......
"""Request scheduler heuristic."""
import random import random
from collections import defaultdict from collections import defaultdict
......
"""A tensor parallel worker."""
import asyncio import asyncio
import logging import logging
import time import time
......
"""DetokenizerManager is a process that detokenizes the token ids."""
import asyncio import asyncio
import inspect import inspect
......
"""
The definition of objects transfered between different
processes (TokenizerManager, DetokenizerManager, Controller).
"""
import uuid import uuid
from dataclasses import dataclass from dataclasses import dataclass
from typing import Dict, List, Optional, Union from typing import Dict, List, Optional, Union
......
"""TokenizerManager is a process that tokenizes the text."""
import asyncio import asyncio
import concurrent.futures import concurrent.futures
import dataclasses import dataclasses
...@@ -283,7 +284,7 @@ class TokenizerManager: ...@@ -283,7 +284,7 @@ class TokenizerManager:
req = AbortReq(rid) req = AbortReq(rid)
self.send_to_router.send_pyobj(req) self.send_to_router.send_pyobj(req)
def create_abort_task(self, obj): def create_abort_task(self, obj: GenerateReqInput):
# Abort the request if the client is disconnected. # Abort the request if the client is disconnected.
async def abort_request(): async def abort_request():
await asyncio.sleep(3) await asyncio.sleep(3)
......
"""pydantic models for OpenAI API protocol""" """Pydantic models for OpenAI API protocol"""
import time import time
from typing import Dict, List, Optional, Union from typing import Dict, List, Optional, Union
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment