Unverified Commit 9acc6e35 authored by Liangsheng Yin's avatar Liangsheng Yin Committed by GitHub
Browse files

add `.isort.cfg` (#378)

parent cf9d8efd
import json
import unittest import unittest
from sglang.test.test_programs import test_mt_bench, test_stream
from sglang import Anthropic, set_default_backend from sglang import Anthropic, set_default_backend
from sglang.test.test_programs import test_mt_bench, test_stream
class TestAnthropicBackend(unittest.TestCase): class TestAnthropicBackend(unittest.TestCase):
......
import unittest import unittest
from sglang.backend.runtime_endpoint import RuntimeEndpoint
import sglang as sgl import sglang as sgl
from sglang.backend.runtime_endpoint import RuntimeEndpoint
class TestBind(unittest.TestCase): class TestBind(unittest.TestCase):
......
import unittest import unittest
from sglang import OpenAI, set_default_backend
from sglang.test.test_programs import ( from sglang.test.test_programs import (
test_decode_int, test_decode_int,
test_decode_json, test_decode_json,
...@@ -15,8 +16,6 @@ from sglang.test.test_programs import ( ...@@ -15,8 +16,6 @@ from sglang.test.test_programs import (
test_tool_use, test_tool_use,
) )
from sglang import OpenAI, set_default_backend
class TestOpenAIBackend(unittest.TestCase): class TestOpenAIBackend(unittest.TestCase):
backend = None backend = None
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
python3 -m sglang.launch_server --model-path meta-llama/Llama-2-7b-chat-hf --port 30000 python3 -m sglang.launch_server --model-path meta-llama/Llama-2-7b-chat-hf --port 30000
""" """
import json
import unittest import unittest
import sglang as sgl
from sglang.test.test_programs import ( from sglang.test.test_programs import (
test_decode_int, test_decode_int,
test_decode_json_regex, test_decode_json_regex,
...@@ -12,16 +12,12 @@ from sglang.test.test_programs import ( ...@@ -12,16 +12,12 @@ from sglang.test.test_programs import (
test_few_shot_qa, test_few_shot_qa,
test_mt_bench, test_mt_bench,
test_parallel_decoding, test_parallel_decoding,
test_parallel_encoding,
test_react,
test_regex, test_regex,
test_select, test_select,
test_stream, test_stream,
test_tool_use, test_tool_use,
) )
import sglang as sgl
class TestSRTBackend(unittest.TestCase): class TestSRTBackend(unittest.TestCase):
backend = None backend = None
......
import unittest import unittest
import sglang as sgl
from sglang.backend.base_backend import BaseBackend from sglang.backend.base_backend import BaseBackend
from sglang.lang.chat_template import get_chat_template from sglang.lang.chat_template import get_chat_template
import sglang as sgl
class TestTracing(unittest.TestCase): class TestTracing(unittest.TestCase):
def test_few_shot_qa(self): def test_few_shot_qa(self):
...@@ -111,7 +110,7 @@ class TestTracing(unittest.TestCase): ...@@ -111,7 +110,7 @@ class TestTracing(unittest.TestCase):
forks = s.fork(3) forks = s.fork(3)
for i in range(3): for i in range(3):
forks[i] += f"Now, expand tip {i+1} into a paragraph:\n" forks[i] += f"Now, expand tip {i+1} into a paragraph:\n"
forks[i] += sgl.gen(f"detailed_tip") forks[i] += sgl.gen("detailed_tip")
s += "Tip 1:" + forks[0]["detailed_tip"] + "\n" s += "Tip 1:" + forks[0]["detailed_tip"] + "\n"
s += "Tip 2:" + forks[1]["detailed_tip"] + "\n" s += "Tip 2:" + forks[1]["detailed_tip"] + "\n"
......
import unittest import unittest
from sglang import VertexAI, set_default_backend
from sglang.test.test_programs import ( from sglang.test.test_programs import (
test_expert_answer, test_expert_answer,
test_few_shot_qa, test_few_shot_qa,
...@@ -10,8 +11,6 @@ from sglang.test.test_programs import ( ...@@ -10,8 +11,6 @@ from sglang.test.test_programs import (
test_stream, test_stream,
) )
from sglang import VertexAI, set_default_backend
class TestVertexAIBackend(unittest.TestCase): class TestVertexAIBackend(unittest.TestCase):
backend = None backend = None
......
...@@ -4,6 +4,7 @@ from dataclasses import dataclass ...@@ -4,6 +4,7 @@ from dataclasses import dataclass
import torch import torch
import torch.distributed as dist import torch.distributed as dist
from sglang.srt.managers.router.model_runner import ModelRunner from sglang.srt.managers.router.model_runner import ModelRunner
from sglang.srt.model_config import ModelConfig from sglang.srt.model_config import ModelConfig
...@@ -66,9 +67,9 @@ class BenchBatch: ...@@ -66,9 +67,9 @@ class BenchBatch:
p_idx = prefix_req_idx[i // fork_num].item() p_idx = prefix_req_idx[i // fork_num].item()
n_idx = self.req_pool_indices[i].item() n_idx = self.req_pool_indices[i].item()
req_to_token[n_idx, :prefix_len] = req_to_token[p_idx, :prefix_len] req_to_token[n_idx, :prefix_len] = req_to_token[p_idx, :prefix_len]
req_to_token[ req_to_token[n_idx, prefix_len : prefix_len + extend_len] = (
n_idx, prefix_len : prefix_len + extend_len self.out_cache_loc[i * extend_len : (i + 1) * extend_len]
] = self.out_cache_loc[i * extend_len : (i + 1) * extend_len] )
def update_decode(self, predict_ids, batch_size): def update_decode(self, predict_ids, batch_size):
assert predict_ids.shape[0] == batch_size assert predict_ids.shape[0] == batch_size
...@@ -81,9 +82,9 @@ class BenchBatch: ...@@ -81,9 +82,9 @@ class BenchBatch:
self.out_cache_cont_start, self.out_cache_cont_start,
self.out_cache_cont_end, self.out_cache_cont_end,
) = self.token_to_kv_pool.alloc_contiguous(batch_size) ) = self.token_to_kv_pool.alloc_contiguous(batch_size)
self.req_to_token_pool.req_to_token[ self.req_to_token_pool.req_to_token[self.req_pool_indices, self.seq_lens] = (
self.req_pool_indices, self.seq_lens self.out_cache_loc
] = self.out_cache_loc )
self.seq_lens.add_(1) self.seq_lens.add_(1)
......
import argparse import argparse
import os
import torch import torch
from transformers import AutoModelForCausalLM, AutoTokenizer from transformers import AutoModelForCausalLM, AutoTokenizer
......
import multiprocessing import multiprocessing
import os import os
import time
import numpy as np
import torch
import torch.distributed as dist
import transformers import transformers
from sglang.srt.managers.router.infer_batch import Batch, ForwardMode, Req from sglang.srt.managers.router.infer_batch import Batch, ForwardMode, Req
from sglang.srt.managers.router.model_runner import ModelRunner from sglang.srt.managers.router.model_runner import ModelRunner
from sglang.srt.model_config import ModelConfig from sglang.srt.model_config import ModelConfig
......
...@@ -4,6 +4,7 @@ import time ...@@ -4,6 +4,7 @@ import time
import numpy as np import numpy as np
import torch import torch
import torch.distributed as dist import torch.distributed as dist
from sglang.srt.managers.router.model_runner import ModelRunner from sglang.srt.managers.router.model_runner import ModelRunner
from sglang.srt.model_config import ModelConfig from sglang.srt.model_config import ModelConfig
......
import multiprocessing import multiprocessing
import time
import numpy as np import numpy as np
import torch import torch
import torch.distributed as dist
from sglang.srt.hf_transformers_utils import get_processor from sglang.srt.hf_transformers_utils import get_processor
from sglang.srt.managers.router.infer_batch import ForwardMode from sglang.srt.managers.router.model_runner import ModelRunner
from sglang.srt.managers.router.model_runner import InputMetadata, ModelRunner
from sglang.srt.model_config import ModelConfig from sglang.srt.model_config import ModelConfig
from sglang.srt.utils import load_image from sglang.srt.utils import load_image
......
import flashinfer import flashinfer
import pytest import pytest
import torch import torch
from sglang.srt.layers.extend_attention import extend_attention_fwd from sglang.srt.layers.extend_attention import extend_attention_fwd
from sglang.srt.layers.token_attention import token_attention_fwd from sglang.srt.layers.token_attention import token_attention_fwd
......
...@@ -9,11 +9,8 @@ The capital of the United Kindom is London.\nThe capital of the United Kingdom i ...@@ -9,11 +9,8 @@ The capital of the United Kindom is London.\nThe capital of the United Kingdom i
import argparse import argparse
import asyncio import asyncio
import json
import time
import aiohttp import aiohttp
import requests
async def send_request(url, data, delay=0): async def send_request(url, data, delay=0):
......
...@@ -10,7 +10,6 @@ The image features a man standing on the back of a yellow taxi cab, holding ...@@ -10,7 +10,6 @@ The image features a man standing on the back of a yellow taxi cab, holding
import argparse import argparse
import asyncio import asyncio
import json import json
import time
import aiohttp import aiohttp
import requests import requests
......
...@@ -6,7 +6,6 @@ The capital of France is Paris.\nThe capital of the United States is Washington, ...@@ -6,7 +6,6 @@ The capital of France is Paris.\nThe capital of the United States is Washington,
""" """
import argparse import argparse
import time
import requests import requests
......
...@@ -2,14 +2,14 @@ import argparse ...@@ -2,14 +2,14 @@ import argparse
from enum import Enum from enum import Enum
from pydantic import BaseModel, constr from pydantic import BaseModel, constr
import sglang as sgl
from sglang.srt.constrained import build_regex_from_object from sglang.srt.constrained import build_regex_from_object
from sglang.test.test_utils import ( from sglang.test.test_utils import (
add_common_sglang_args_and_parse, add_common_sglang_args_and_parse,
select_sglang_backend, select_sglang_backend,
) )
import sglang as sgl
IP_REGEX = r"((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)" IP_REGEX = r"((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)"
ip_jump_forward = ( ip_jump_forward = (
......
...@@ -2,13 +2,13 @@ import argparse ...@@ -2,13 +2,13 @@ import argparse
import random import random
import string import string
from vllm.transformers_utils.tokenizer import get_tokenizer
import sglang as sgl
from sglang.test.test_utils import ( from sglang.test.test_utils import (
add_common_sglang_args_and_parse, add_common_sglang_args_and_parse,
select_sglang_backend, select_sglang_backend,
) )
from vllm.transformers_utils.tokenizer import get_tokenizer
import sglang as sgl
TOKENIZER = None TOKENIZER = None
RANDOM_PREFILL_LEN = None RANDOM_PREFILL_LEN = None
......
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