update pre-commit config (#18860)
This commit is contained in:
@@ -26,9 +26,9 @@ jobs:
|
||||
run: SKIP=no-commit-to-branch pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
- name: Run sgl-kernel clang-format checks
|
||||
uses: DoozyX/clang-format-lint-action@v0.18.1
|
||||
uses: DoozyX/clang-format-lint-action@v0.20
|
||||
with:
|
||||
source: sgl-kernel
|
||||
extensions: h,c,cpp,hpp,cu,cuh,cc
|
||||
clangFormatVersion: 18
|
||||
clangFormatVersion: 20
|
||||
style: file
|
||||
|
||||
@@ -3,7 +3,7 @@ exclude: ^(python/sglang/multimodal_gen/csrc|python/sglang/jit_kernel/flash_atte
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
rev: v6.0.0
|
||||
hooks:
|
||||
- id: check-symlinks
|
||||
- id: destroyed-symlinks
|
||||
@@ -21,12 +21,12 @@ repos:
|
||||
- id: debug-statements
|
||||
- id: no-commit-to-branch
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.13.2
|
||||
rev: 7.0.0
|
||||
hooks:
|
||||
- id: isort
|
||||
exclude: '^python/sglang/srt/grpc/.*_pb2\.py$|^python/sglang/srt/grpc/.*_pb2_grpc\.py$|^python/sglang/srt/grpc/.*_pb2\.pyi$|^python/sglang/srt/grpc/.*_pb2_grpc\.pyi$'
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.11.7
|
||||
rev: v0.15.1
|
||||
hooks:
|
||||
- id: ruff
|
||||
args:
|
||||
@@ -43,7 +43,7 @@ repos:
|
||||
python/sglang/srt/grpc/.*_pb2_grpc\.pyi$|
|
||||
)$
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 24.10.0
|
||||
rev: 26.1.0
|
||||
hooks:
|
||||
- id: black-jupyter
|
||||
exclude: '^python/sglang/srt/grpc/.*_pb2\.py$|^python/sglang/srt/grpc/.*_pb2_grpc\.py$|^python/sglang/srt/grpc/.*_pb2\.pyi$|^python/sglang/srt/grpc/.*_pb2_grpc\.pyi$'
|
||||
@@ -53,13 +53,13 @@ repos:
|
||||
- id: codespell
|
||||
args: ['--config', '.codespellrc']
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v18.1.8
|
||||
rev: v20.1.7
|
||||
hooks:
|
||||
- id: clang-format
|
||||
types_or: [c++, cuda]
|
||||
args: [--style=file, --verbose]
|
||||
- repo: https://github.com/kynan/nbstripout
|
||||
rev: 0.8.1
|
||||
rev: 0.9.0
|
||||
hooks:
|
||||
- id: nbstripout
|
||||
args:
|
||||
|
||||
+2
-4
@@ -187,10 +187,8 @@ def run_grid(bs, model, method, tp_size, dtype: str):
|
||||
|
||||
configs = union_of_list_of_dicts(prune_configs_1, prune_configs_2)
|
||||
|
||||
print(
|
||||
f"{bs=} || {len(full_configs)=} | {len(prune_configs_1)=} | \
|
||||
{len(prune_configs_2)=} | {len(configs)=}"
|
||||
)
|
||||
print(f"{bs=} || {len(full_configs)=} | {len(prune_configs_1)=} | \
|
||||
{len(prune_configs_2)=} | {len(configs)=}")
|
||||
|
||||
best_config = None
|
||||
best_time_us = 1e20
|
||||
|
||||
@@ -7,7 +7,9 @@ import torch
|
||||
from sglang.srt.layers.attention.fla.layernorm_gated import (
|
||||
_layer_norm_fwd as layer_norm_fwd,
|
||||
)
|
||||
from sglang.srt.layers.attention.fla.layernorm_gated import rms_norm_ref
|
||||
from sglang.srt.layers.attention.fla.layernorm_gated import (
|
||||
rms_norm_ref,
|
||||
)
|
||||
|
||||
|
||||
def benchmark_layer_norm_fwd(
|
||||
|
||||
@@ -13,8 +13,7 @@ number = 5
|
||||
|
||||
|
||||
def expand_tip(topic, tip, generate):
|
||||
s = (
|
||||
"""Please expand a tip for a topic into a detailed paragraph.
|
||||
s = """Please expand a tip for a topic into a detailed paragraph.
|
||||
|
||||
Topic: staying healthy
|
||||
Tip: Regular Exercise
|
||||
@@ -28,12 +27,7 @@ Topic: writing a blog post
|
||||
Tip: structure your content effectively
|
||||
Paragraph: A well-structured post is easier to read and more enjoyable. Start with an engaging introduction that hooks the reader and clearly states the purpose of your post. Use headings and subheadings to break up the text and guide readers through your content. Bullet points and numbered lists can make information more digestible. Ensure each paragraph flows logically into the next, and conclude with a summary or call-to-action that encourages reader engagement.
|
||||
|
||||
Topic: """
|
||||
+ topic
|
||||
+ "\nTip: "
|
||||
+ tip
|
||||
+ "\nParagraph:"
|
||||
)
|
||||
Topic: """ + topic + "\nTip: " + tip + "\nParagraph:"
|
||||
return generate(s, max_tokens=128, stop=["\n\n"])
|
||||
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ number = 5
|
||||
|
||||
@sgl.function
|
||||
def expand_tip(s, topic, tip):
|
||||
s += (
|
||||
"""Please expand a tip for a topic into a detailed paragraph.
|
||||
s += """Please expand a tip for a topic into a detailed paragraph.
|
||||
|
||||
Topic: staying healthy
|
||||
Tip: Regular Exercise
|
||||
@@ -29,12 +28,7 @@ Topic: writing a blog post
|
||||
Tip: structure your content effectively
|
||||
Paragraph: A well-structured post is easier to read and more enjoyable. Start with an engaging introduction that hooks the reader and clearly states the purpose of your post. Use headings and subheadings to break up the text and guide readers through your content. Bullet points and numbered lists can make information more digestible. Ensure each paragraph flows logically into the next, and conclude with a summary or call-to-action that encourages reader engagement.
|
||||
|
||||
Topic: """
|
||||
+ topic
|
||||
+ "\nTip: "
|
||||
+ tip
|
||||
+ "\nParagraph:"
|
||||
)
|
||||
Topic: """ + topic + "\nTip: " + tip + "\nParagraph:"
|
||||
s += sgl.gen("paragraph", max_tokens=128, stop=["\n\n"], temperature=0)
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ number = 5
|
||||
|
||||
|
||||
async def expand_tip_async(topic, tip, generate):
|
||||
s = (
|
||||
"""Please expand a tip for a topic into a detailed paragraph.
|
||||
s = """Please expand a tip for a topic into a detailed paragraph.
|
||||
|
||||
Topic: staying healthy
|
||||
Tip: Regular Exercise
|
||||
@@ -17,12 +16,7 @@ Topic: writing a blog post
|
||||
Tip: structure your content effectively
|
||||
Paragraph: A well-structured post is easier to read and more enjoyable. Start with an engaging introduction that hooks the reader and clearly states the purpose of your post. Use headings and subheadings to break up the text and guide readers through your content. Bullet points and numbered lists can make information more digestible. Ensure each paragraph flows logically into the next, and conclude with a summary or call-to-action that encourages reader engagement.
|
||||
|
||||
Topic: """
|
||||
+ topic
|
||||
+ "\nTip: "
|
||||
+ tip
|
||||
+ "\nParagraph:"
|
||||
)
|
||||
Topic: """ + topic + "\nTip: " + tip + "\nParagraph:"
|
||||
return await generate(s, max_tokens=128, stop="\n\n")
|
||||
|
||||
|
||||
|
||||
@@ -151,16 +151,14 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"server_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"server_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path meta-llama/Meta-Llama-3.1-8B-Instruct \\\n",
|
||||
" --enable-lora \\\n",
|
||||
" --lora-paths lora0=algoprog/fact-generation-llama-3.1-8b-instruct-lora \\\n",
|
||||
" lora1=Nutanix/Meta-Llama-3.1-8B-Instruct_lora_4_alpha_16 \\\n",
|
||||
" --max-loras-per-batch 2 \\\n",
|
||||
" --log-level warning \\\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=server_process)"
|
||||
]
|
||||
@@ -227,8 +225,7 @@
|
||||
"\n",
|
||||
"# The `--target-lora-modules` param below is technically not needed, as the server will infer it from lora0 which already has all the target modules specified.\n",
|
||||
"# We are adding it here just to demonstrate usage.\n",
|
||||
"server_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"server_process, port = launch_server_cmd(\"\"\"\n",
|
||||
" python3 -m sglang.launch_server --model-path meta-llama/Meta-Llama-3.1-8B-Instruct \\\n",
|
||||
" --enable-lora \\\n",
|
||||
" --cuda-graph-max-bs 2 \\\n",
|
||||
@@ -236,8 +233,7 @@
|
||||
" --max-lora-rank 256\n",
|
||||
" --lora-target-modules all\n",
|
||||
" --log-level warning\n",
|
||||
" \"\"\"\n",
|
||||
")\n",
|
||||
" \"\"\")\n",
|
||||
"\n",
|
||||
"url = f\"http://127.0.0.1:{port}\"\n",
|
||||
"wait_for_server(url, process=server_process)"
|
||||
@@ -435,8 +431,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"server_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"server_process, port = launch_server_cmd(\"\"\"\n",
|
||||
" python3 -m sglang.launch_server --model-path meta-llama/Meta-Llama-3.1-8B-Instruct \\\n",
|
||||
" --enable-lora \\\n",
|
||||
" --cuda-graph-max-bs 8 \\\n",
|
||||
@@ -448,8 +443,7 @@
|
||||
" {\"lora_name\":\"lora1\",\"lora_path\":\"algoprog/fact-generation-llama-3.1-8b-instruct-lora\"} \\\n",
|
||||
" lora2=philschmid/code-llama-3-1-8b-text-to-sql-lora\n",
|
||||
" --log-level warning\n",
|
||||
" \"\"\"\n",
|
||||
")\n",
|
||||
" \"\"\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"url = f\"http://127.0.0.1:{port}\"\n",
|
||||
@@ -548,16 +542,14 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"server_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"server_process, port = launch_server_cmd(\"\"\"\n",
|
||||
" python3 -m sglang.launch_server \\\n",
|
||||
" --model-path meta-llama/Meta-Llama-3.1-8B-Instruct \\\n",
|
||||
" --enable-lora \\\n",
|
||||
" --lora-backend csgmv \\\n",
|
||||
" --max-loras-per-batch 16 \\\n",
|
||||
" --lora-paths lora1=path/to/lora1 lora2=path/to/lora2\n",
|
||||
" \"\"\"\n",
|
||||
")"
|
||||
" \"\"\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -594,8 +586,7 @@
|
||||
"lora2 = \"philschmid/code-llama-3-1-8b-text-to-sql-lora\"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"server_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"server_process, port = launch_server_cmd(\"\"\"\n",
|
||||
" python3 -m sglang.launch_server \\\n",
|
||||
" --model-path meta-llama/Meta-Llama-3.1-8B-Instruct \\\n",
|
||||
" --enable-lora \\\n",
|
||||
@@ -606,8 +597,7 @@
|
||||
" --max-lora-rank 256 \\\n",
|
||||
" --max-loras-per-batch 2 \\\n",
|
||||
" --max-loaded-loras 4\n",
|
||||
" \"\"\"\n",
|
||||
")\n",
|
||||
" \"\"\")\n",
|
||||
"\n",
|
||||
"url = f\"http://127.0.0.1:{port}\"\n",
|
||||
"wait_for_server(url, process=server_process)"
|
||||
|
||||
@@ -740,7 +740,6 @@
|
||||
"import json\n",
|
||||
"from pydantic import BaseModel, Field\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"prompts = [\n",
|
||||
" \"Give me the information of the capital of China in the JSON format.\",\n",
|
||||
" \"Give me the information of the capital of France in the JSON format.\",\n",
|
||||
|
||||
@@ -642,7 +642,6 @@
|
||||
"import json\n",
|
||||
"from pydantic import BaseModel, Field\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"prompts = [\n",
|
||||
" \"Give me the information of the capital of China in the JSON format.\",\n",
|
||||
" \"Give me the information of the capital of France in the JSON format.\",\n",
|
||||
|
||||
@@ -117,7 +117,6 @@
|
||||
"source": [
|
||||
"from sglang import Engine\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"llm = Engine(model_path=model_path, chat_template=chat_template, log_level=\"warning\")"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -275,12 +275,10 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"embedding_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"embedding_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path Alibaba-NLP/gte-Qwen2-1.5B-instruct \\\n",
|
||||
" --host 0.0.0.0 --is-embedding --log-level warning\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=embedding_process)"
|
||||
]
|
||||
@@ -324,12 +322,10 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"reranker_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"reranker_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path BAAI/bge-reranker-v2-m3 \\\n",
|
||||
" --host 0.0.0.0 --disable-radix-cache --chunked-prefill-size -1 --attention-backend triton --is-embedding --log-level warning\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=reranker_process)"
|
||||
]
|
||||
@@ -392,12 +388,10 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"score_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"score_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path qwen/qwen2.5-0.5b-instruct \\\n",
|
||||
" --host 0.0.0.0 --log-level warning\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=score_process)"
|
||||
]
|
||||
@@ -456,11 +450,9 @@
|
||||
"# Note that SGLang now treats embedding models and reward models as the same type of models.\n",
|
||||
"# This will be updated in the future.\n",
|
||||
"\n",
|
||||
"reward_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"reward_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path Skywork/Skywork-Reward-Llama-3.1-8B-v0.2 --host 0.0.0.0 --is-embedding --log-level warning\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=reward_process)"
|
||||
]
|
||||
@@ -575,11 +567,9 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"tokenizer_free_server_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"tokenizer_free_server_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path qwen/qwen2.5-0.5b-instruct\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=tokenizer_free_server_process)"
|
||||
]
|
||||
|
||||
@@ -30,12 +30,10 @@
|
||||
"from sglang.test.doc_patch import launch_server_cmd\n",
|
||||
"from sglang.utils import wait_for_server, print_highlight, terminate_process\n",
|
||||
"\n",
|
||||
"embedding_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"embedding_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path Alibaba-NLP/gte-Qwen2-1.5B-instruct \\\n",
|
||||
" --host 0.0.0.0 --is-embedding --log-level warning\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=embedding_process)"
|
||||
]
|
||||
|
||||
@@ -33,11 +33,9 @@
|
||||
"from sglang.test.doc_patch import launch_server_cmd\n",
|
||||
"from sglang.utils import wait_for_server, print_highlight, terminate_process\n",
|
||||
"\n",
|
||||
"vision_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"vision_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path Qwen/Qwen2.5-VL-7B-Instruct --log-level warning\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=vision_process)"
|
||||
]
|
||||
|
||||
@@ -31,12 +31,10 @@
|
||||
"# This is equivalent to running the following command in your terminal\n",
|
||||
"# python3 -m sglang.launch_server --model-path qwen/qwen2.5-0.5b-instruct --host 0.0.0.0\n",
|
||||
"\n",
|
||||
"server_process, port = launch_server_cmd(\n",
|
||||
" \"\"\"\n",
|
||||
"server_process, port = launch_server_cmd(\"\"\"\n",
|
||||
"python3 -m sglang.launch_server --model-path qwen/qwen2.5-0.5b-instruct \\\n",
|
||||
" --host 0.0.0.0 --log-level warning\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"\"\"\")\n",
|
||||
"\n",
|
||||
"wait_for_server(f\"http://localhost:{port}\", process=server_process)"
|
||||
]
|
||||
|
||||
-3
@@ -107,7 +107,6 @@
|
||||
"from sglang.lang.interpreter import ProgramState\n",
|
||||
"from parea import Parea, trace\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"load_dotenv()\n",
|
||||
"\n",
|
||||
"os.environ[\"TOKENIZERS_PARALLELISM\"] = \"false\"\n",
|
||||
@@ -237,7 +236,6 @@
|
||||
" percent_target_supported_by_context_factory,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"context_relevancy_eval = context_query_relevancy_factory()\n",
|
||||
"percent_target_supported_by_context = percent_target_supported_by_context_factory()\n",
|
||||
"\n",
|
||||
@@ -263,7 +261,6 @@
|
||||
"from parea.evals.general import answer_matches_target_llm_grader_factory\n",
|
||||
"from parea.evals.rag import answer_context_faithfulness_statement_level_factory\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"answer_context_faithfulness = answer_context_faithfulness_statement_level_factory()\n",
|
||||
"answer_matches_target_llm_grader = answer_matches_target_llm_grader_factory()\n",
|
||||
"\n",
|
||||
|
||||
@@ -18,6 +18,7 @@ llm = Engine(
|
||||
tensor_parallel_size=8,
|
||||
)
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path
|
||||
|
||||
@@ -21,6 +21,7 @@ llm = Engine(
|
||||
tensor_parallel_size=8,
|
||||
)
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
import os
|
||||
import shutil
|
||||
|
||||
@@ -36,7 +36,8 @@ struct dtype_trait {};
|
||||
} \
|
||||
static_assert(true)
|
||||
|
||||
SGL_REGISTER_DTYPE_TRAIT(fp32_t, fp32x2_t, SGL_REGISTER_TYPE_END; //
|
||||
SGL_REGISTER_DTYPE_TRAIT(
|
||||
fp32_t, fp32x2_t, SGL_REGISTER_TYPE_END; //
|
||||
SGL_REGISTER_FROM_FUNCTION(fp16_t, __half2float);
|
||||
SGL_REGISTER_FROM_FUNCTION(bf16_t, __bfloat162float);
|
||||
SGL_REGISTER_UNARY_FUNCTION(abs, fabsf);
|
||||
@@ -48,15 +49,15 @@ SGL_REGISTER_DTYPE_TRAIT(fp16_t, fp16x2_t);
|
||||
SGL_REGISTER_DTYPE_TRAIT(bf16_t, bf16x2_t);
|
||||
|
||||
/// TODO: Add ROCM implementation
|
||||
SGL_REGISTER_DTYPE_TRAIT(fp32x2_t, fp32x4_t, SGL_REGISTER_TYPE_END;
|
||||
SGL_REGISTER_FROM_FUNCTION(fp16x2_t, __half22float2);
|
||||
SGL_REGISTER_DTYPE_TRAIT(
|
||||
fp32x2_t, fp32x4_t, SGL_REGISTER_TYPE_END; SGL_REGISTER_FROM_FUNCTION(fp16x2_t, __half22float2);
|
||||
SGL_REGISTER_FROM_FUNCTION(bf16x2_t, __bfloat1622float2););
|
||||
|
||||
SGL_REGISTER_DTYPE_TRAIT(fp16x2_t, void, SGL_REGISTER_TYPE_END;
|
||||
SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22half2_rn););
|
||||
SGL_REGISTER_DTYPE_TRAIT(
|
||||
fp16x2_t, void, SGL_REGISTER_TYPE_END; SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22half2_rn););
|
||||
|
||||
SGL_REGISTER_DTYPE_TRAIT(bf16x2_t, void, SGL_REGISTER_TYPE_END;
|
||||
SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22bfloat162_rn););
|
||||
SGL_REGISTER_DTYPE_TRAIT(
|
||||
bf16x2_t, void, SGL_REGISTER_TYPE_END; SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22bfloat162_rn););
|
||||
|
||||
#undef SGL_REGISTER_DTYPE_TRAIT
|
||||
#undef SGL_REGISTER_FROM_FUNCTION
|
||||
|
||||
@@ -243,12 +243,10 @@ def run_sgl_diffusion_webui(server_args: ServerArgs):
|
||||
# print banner
|
||||
delimiter = "=" * 80
|
||||
url = local_url or f"http://localhost:{server_args.webui_port}"
|
||||
print(
|
||||
f"""
|
||||
print(f"""
|
||||
{delimiter}
|
||||
\033[1mSGLang Diffusion WebUI available at:\033[0m \033[1;4;92m{url}\033[0m
|
||||
{delimiter}
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
demo.block_thread()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""Qwen3 text encoder configuration for SGLang diffusion models."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from sglang.multimodal_gen.configs.models.encoders.base import (
|
||||
|
||||
@@ -9,6 +9,7 @@ diffusion transformer (DiT) inference:
|
||||
- cache-dit integration: Block-level caching with DBCache and TaylorSeer
|
||||
|
||||
"""
|
||||
|
||||
from sglang.multimodal_gen.runtime.cache.cache_dit_integration import (
|
||||
CacheDitConfig,
|
||||
enable_cache_on_dual_transformer,
|
||||
|
||||
@@ -29,6 +29,7 @@ The typical workflow is:
|
||||
If you only need to use the distributed environment without model parallelism,
|
||||
you can skip the model parallel initialization and destruction steps.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
import datetime
|
||||
import os
|
||||
@@ -71,7 +72,7 @@ TensorMetadata = namedtuple("TensorMetadata", ["device", "dtype", "size"])
|
||||
|
||||
|
||||
def _split_tensor_dict(
|
||||
tensor_dict: dict[str, torch.Tensor | Any]
|
||||
tensor_dict: dict[str, torch.Tensor | Any],
|
||||
) -> tuple[list[tuple[str, Any]], list[torch.Tensor]]:
|
||||
"""Split the tensor dictionary into two parts:
|
||||
1. A list of (key, value) pairs. If the value is a tensor, it is replaced
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/layers/activation.py
|
||||
"""Custom activation functions."""
|
||||
|
||||
import math
|
||||
from typing import Any
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/layers/layernorm.py
|
||||
"""Custom normalization layers."""
|
||||
|
||||
from typing import Optional, Tuple, Union
|
||||
|
||||
import torch
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Rotary Positional Embeddings."""
|
||||
|
||||
import functools
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Optional, Tuple
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/layers/utils.py
|
||||
"""Utility methods for model layers."""
|
||||
|
||||
import inspect
|
||||
from typing import Any, Callable, List, Optional
|
||||
|
||||
|
||||
@@ -12,7 +12,10 @@ from diffusers.models.embeddings import (
|
||||
from diffusers.models.embeddings import (
|
||||
CombinedTimestepTextProjEmbeddings as _CombinedTimestepTextProjEmbeddings,
|
||||
)
|
||||
from diffusers.models.embeddings import PixArtAlphaTextProjection, TimestepEmbedding
|
||||
from diffusers.models.embeddings import (
|
||||
PixArtAlphaTextProjection,
|
||||
TimestepEmbedding,
|
||||
)
|
||||
from diffusers.models.embeddings import Timesteps as _Timesteps
|
||||
from diffusers.models.embeddings import (
|
||||
get_timestep_embedding as timestep_embedding_diffusers,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""Utilities for selecting and loading models."""
|
||||
|
||||
import contextlib
|
||||
import glob
|
||||
import os
|
||||
@@ -30,7 +31,7 @@ def set_default_torch_dtype(dtype: torch.dtype):
|
||||
|
||||
|
||||
def get_param_names_mapping(
|
||||
mapping_dict: dict[str, str]
|
||||
mapping_dict: dict[str, str],
|
||||
) -> Callable[[str], tuple[str, Any, Any]]:
|
||||
"""
|
||||
Creates a mapping function that transforms parameter names using regex patterns.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/model_loader/weight_utils.py
|
||||
"""Utilities for downloading and initializing model weights."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# Adapted from transformers: https://github.com/huggingface/transformers/blob/v4.39.0/src/transformers/models/clip/modeling_clip.py
|
||||
"""Minimal implementation of CLIPVisionModel intended to be only used
|
||||
within a vision language model."""
|
||||
|
||||
from collections.abc import Iterable
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only LLaMA model compatible with HuggingFace weights."""
|
||||
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Adapted from: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/utils.py
|
||||
"""Utils for model executor."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
import torch
|
||||
|
||||
@@ -8,7 +8,6 @@ This module contains an implementation of the Hunyuan video diffusion pipeline
|
||||
using the modular pipeline architecture.
|
||||
"""
|
||||
|
||||
|
||||
from sglang.multimodal_gen.runtime.pipelines_core.composed_pipeline_base import (
|
||||
ComposedPipelineBase,
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"""
|
||||
Synchronous pipeline executor implementation.
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
|
||||
from sglang.multimodal_gen.runtime.pipelines_core.executors.pipeline_executor import (
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ This stage extends LatentPreparationStage to handle device mismatch issues
|
||||
that occur when tensors are pickled and unpickled via broadcast_pyobj in
|
||||
multi-GPU scenarios.
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
|
||||
import torch
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"""
|
||||
Input validation stage for diffusion pipelines.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
import torchvision.transforms.functional as TF
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"""
|
||||
Latent preparation stage for diffusion pipelines.
|
||||
"""
|
||||
|
||||
from diffusers.utils.torch_utils import randn_tensor
|
||||
|
||||
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
This file is a platform abstraction for ROCm GPUs,
|
||||
adjusted to match the structure and interface of `cuda.py`.
|
||||
"""
|
||||
|
||||
from functools import lru_cache
|
||||
from typing import Any
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Inspired by SGLang: https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/server_args.py
|
||||
"""The arguments of sglang-diffusion Inference."""
|
||||
|
||||
import argparse
|
||||
import dataclasses
|
||||
import inspect
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/logger.py
|
||||
"""Logging configuration for sglang.multimodal_gen."""
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
import datetime
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
|
||||
|
||||
"""
|
||||
Common generate cli test, one test for image and video each
|
||||
Common generate cli test, one test for image and video each
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
import os
|
||||
import shlex
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
This file upload the media generated in diffusion-nightly-test to a slack channel of SGLang
|
||||
This file upload the media generated in diffusion-nightly-test to a slack channel of SGLang
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
+2
-2
@@ -4855,7 +4855,7 @@ def nvmlDeviceGetFieldValues(handle, fieldIds):
|
||||
|
||||
for i, fieldId in enumerate(fieldIds):
|
||||
try:
|
||||
(values[i].fieldId, values[i].scopeId) = fieldId
|
||||
values[i].fieldId, values[i].scopeId = fieldId
|
||||
except TypeError:
|
||||
values[i].fieldId = fieldId
|
||||
|
||||
@@ -4871,7 +4871,7 @@ def nvmlDeviceClearFieldValues(handle, fieldIds):
|
||||
|
||||
for i, fieldId in enumerate(fieldIds):
|
||||
try:
|
||||
(values[i].fieldId, values[i].scopeId) = fieldId
|
||||
values[i].fieldId, values[i].scopeId = fieldId
|
||||
except TypeError:
|
||||
values[i].fieldId = fieldId
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
Checkpoint-engine integration for SGLang.
|
||||
This module provides weight update functionality via IPC for checkpoint-engine compatibility.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Callable, Dict, Optional
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ else:
|
||||
|
||||
|
||||
def weak_ref_tensors(
|
||||
tensors: Union[torch.Tensor, list[torch.Tensor], tuple[torch.Tensor]]
|
||||
tensors: Union[torch.Tensor, list[torch.Tensor], tuple[torch.Tensor]],
|
||||
) -> Union[torch.Tensor, list[Any], tuple[Any], Any]:
|
||||
"""
|
||||
Convenience function to create weak references to tensors,
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
""" EXAONE model configuration """
|
||||
"""EXAONE model configuration"""
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
from transformers.configuration_utils import PretrainedConfig
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
# limitations under the License.
|
||||
"""Falcon-H1 model configuration"""
|
||||
|
||||
|
||||
from transformers.configuration_utils import PretrainedConfig
|
||||
from transformers.utils import logging
|
||||
|
||||
|
||||
@@ -970,7 +970,7 @@ class MooncakeKVManager(CommonKVManager):
|
||||
self._handle_aux_data(msg)
|
||||
continue
|
||||
|
||||
(bootstrap_room, status, prefill_rank) = msg
|
||||
bootstrap_room, status, prefill_rank = msg
|
||||
status = int(status.decode("ascii"))
|
||||
bootstrap_room = int(bootstrap_room.decode("ascii"))
|
||||
prefill_rank = int(prefill_rank.decode("ascii"))
|
||||
|
||||
@@ -21,6 +21,7 @@ If you only need to use the distributed environment without model/pipeline
|
||||
parallelism, you can skip the model parallel initialization and destruction
|
||||
steps.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
import gc
|
||||
import logging
|
||||
@@ -79,7 +80,7 @@ class P2PWork:
|
||||
|
||||
|
||||
def _split_tensor_dict(
|
||||
tensor_dict: Dict[str, Union[torch.Tensor, Any]]
|
||||
tensor_dict: Dict[str, Union[torch.Tensor, Any]],
|
||||
) -> Tuple[List[Tuple[str, Any]], List[torch.Tensor]]:
|
||||
"""Split the tensor dictionary into two parts:
|
||||
1. A list of (key, value) pairs. If the value is a tensor, it is replaced
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Adapted from vLLM's OpenAIServingResponses
|
||||
"""Handler for /v1/responses requests"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
@@ -186,7 +186,7 @@ class BaseFormatDetector(ABC):
|
||||
if start_idx >= len(current_text):
|
||||
return StreamingParseResult()
|
||||
|
||||
(obj, end_idx) = _partial_json_loads(current_text[start_idx:], flags)
|
||||
obj, end_idx = _partial_json_loads(current_text[start_idx:], flags)
|
||||
|
||||
is_current_complete = _is_complete_json(
|
||||
current_text[start_idx : start_idx + end_idx]
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
""" Run the model with npu graph and torch.compile """
|
||||
"""Run the model with npu graph and torch.compile"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""Attention layer with Dual chunk flash attention and sparse attention.
|
||||
"""
|
||||
"""Attention layer with Dual chunk flash attention and sparse attention."""
|
||||
|
||||
import functools
|
||||
import logging
|
||||
import math
|
||||
|
||||
@@ -670,9 +670,9 @@ class KimiLinearAttnBackend(MambaAttnBackendBase):
|
||||
**kwargs,
|
||||
):
|
||||
assert isinstance(mixed_qkv, Tuple)
|
||||
(q_proj_states, k_proj_states, v_proj_states) = mixed_qkv
|
||||
(q_conv_weights, k_conv_weights, v_conv_weights) = layer.conv_weights
|
||||
(q_conv_bias, k_conv_bias, v_conv_bias) = layer.bias
|
||||
q_proj_states, k_proj_states, v_proj_states = mixed_qkv
|
||||
q_conv_weights, k_conv_weights, v_conv_weights = layer.conv_weights
|
||||
q_conv_bias, k_conv_bias, v_conv_bias = layer.bias
|
||||
|
||||
layer_cache = self.req_to_token_pool.mamba2_layer_cache(layer.layer_id)
|
||||
q_conv_state, k_conv_state, v_conv_state = layer_cache.conv
|
||||
@@ -744,9 +744,9 @@ class KimiLinearAttnBackend(MambaAttnBackendBase):
|
||||
)
|
||||
|
||||
assert isinstance(mixed_qkv, Tuple)
|
||||
(q_proj_states, k_proj_states, v_proj_states) = mixed_qkv
|
||||
(q_conv_weights, k_conv_weights, v_conv_weights) = layer.conv_weights
|
||||
(q_conv_bias, k_conv_bias, v_conv_bias) = layer.bias
|
||||
q_proj_states, k_proj_states, v_proj_states = mixed_qkv
|
||||
q_conv_weights, k_conv_weights, v_conv_weights = layer.conv_weights
|
||||
q_conv_bias, k_conv_bias, v_conv_bias = layer.bias
|
||||
|
||||
query_start_loc = self.forward_metadata.query_start_loc
|
||||
cache_indices = self.forward_metadata.mamba_cache_indices
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"""
|
||||
Copyright (c) Ant Financial Service Group and its affiliates.
|
||||
"""
|
||||
|
||||
# Copied from https://code.alipay.com/pia/PainlessInferenceAcceleration/blob/v0.0.6/flood/flood/ops/seg_la.py
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
@@ -38,7 +38,7 @@ def prefill_attention_wave(
|
||||
output_shape = (shape.total_seq_len, shape.num_query_heads, shape.head_size_kv)
|
||||
# Run the wave kernel.
|
||||
mfma_variant = (MMAType.F32_16x16x16_F16, MMAType.F32_16x16x16_F16)
|
||||
(prefill, hyperparams) = get_prefill_attention_kernel(
|
||||
prefill, hyperparams = get_prefill_attention_kernel(
|
||||
shape,
|
||||
mfma_variant,
|
||||
q.shape,
|
||||
|
||||
@@ -376,7 +376,7 @@ class LogitsProcessor(nn.Module):
|
||||
|
||||
logprobs_result = self.process_input_logprobs(input_logits, logits_metadata)
|
||||
else:
|
||||
(logprobs_result, sampled_logits) = self.process_input_logprobs_by_chunk(
|
||||
logprobs_result, sampled_logits = self.process_input_logprobs_by_chunk(
|
||||
pruned_states,
|
||||
sample_indices,
|
||||
input_logprob_indices,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""Cutlass W4A8 MoE kernel."""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
import torch
|
||||
|
||||
@@ -63,11 +63,9 @@ class ModelSlimMoEMethod(FusedMoEMethodBase):
|
||||
logger.info_once("Using ModelSlimW8A8Int8MoE")
|
||||
return ModelSlimW8A8Int8MoE(quant_config)
|
||||
else:
|
||||
logger.warning(
|
||||
f"Unsupported FusedMoe modelslim scheme: \
|
||||
logger.warning(f"Unsupported FusedMoe modelslim scheme: \
|
||||
{quant_config.quant_description.get(prefix_in_quant_config.strip())} \
|
||||
in layer: {prefix}"
|
||||
)
|
||||
in layer: {prefix}")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""Radix attention."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""Radix linear attention."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional, Tuple, Union
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/model_executor/layers/rotary_embedding.py
|
||||
"""Rotary Positional Embeddings."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import itertools
|
||||
@@ -2896,7 +2897,7 @@ class DualChunkRotaryEmbedding(MultiPlatformOp):
|
||||
self.local_size = local_size
|
||||
self.dtype = dtype
|
||||
self.device = torch.device(f"cuda:{torch.cuda.current_device()}")
|
||||
(q_cache, qc_cache, k_cache, qc_no_clamp_cache, q_inter_cache) = (
|
||||
q_cache, qc_cache, k_cache, qc_no_clamp_cache, q_inter_cache = (
|
||||
self._compute_cos_sin_cache()
|
||||
)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""A tensor parallel worker."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
@@ -639,7 +639,7 @@ class MambaRadixCache(BasePrefixCache):
|
||||
match_result = self.match_prefix(
|
||||
MatchPrefixParams(key=RadixKey(page_aligned_token_ids, req.extra_key))
|
||||
)
|
||||
(new_indices, new_last_node) = (
|
||||
new_indices, new_last_node = (
|
||||
match_result.device_indices,
|
||||
match_result.last_device_node,
|
||||
)
|
||||
|
||||
@@ -8,7 +8,9 @@ from typing import Optional
|
||||
import psutil
|
||||
import torch
|
||||
|
||||
from sglang.jit_kernel.hicache import can_use_hicache_jit_kernel
|
||||
from sglang.jit_kernel.hicache import (
|
||||
can_use_hicache_jit_kernel,
|
||||
)
|
||||
from sglang.jit_kernel.hicache import (
|
||||
transfer_hicache_all_layer as jit_transfer_hicache_all_layer,
|
||||
)
|
||||
|
||||
@@ -523,7 +523,7 @@ class RadixCache(BasePrefixCache):
|
||||
|
||||
# The prefix indices could be updated, reuse it
|
||||
match_result = self.match_prefix(MatchPrefixParams(key=radix_key))
|
||||
(new_indices, new_last_node) = (
|
||||
new_indices, new_last_node = (
|
||||
match_result.device_indices,
|
||||
match_result.last_device_node,
|
||||
)
|
||||
|
||||
@@ -556,7 +556,7 @@ class SWARadixCache(BasePrefixCache):
|
||||
match_result = self.match_prefix(
|
||||
MatchPrefixParams(key=RadixKey(page_aligned_token_ids, req.extra_key))
|
||||
)
|
||||
(new_indices, new_last_node) = (
|
||||
new_indices, new_last_node = (
|
||||
match_result.device_indices,
|
||||
match_result.last_device_node,
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""Utilities for Prometheus Metrics Collection."""
|
||||
|
||||
import dataclasses
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""Utilities for Prometheus Metrics."""
|
||||
|
||||
import math
|
||||
from typing import List
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/model_loader/utils.py
|
||||
|
||||
"""Utilities for selecting and loading models."""
|
||||
|
||||
import concurrent.futures
|
||||
import contextlib
|
||||
import logging
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/model_loader/weight_utils.py
|
||||
|
||||
"""Utilities for downloading and initializing model weights."""
|
||||
|
||||
import collections
|
||||
import concurrent.futures
|
||||
import fnmatch
|
||||
@@ -140,12 +141,10 @@ def convert_bin_to_safetensor_file(
|
||||
sf_size = os.stat(sf_filename).st_size
|
||||
pt_size = os.stat(pt_filename).st_size
|
||||
if (sf_size - pt_size) / pt_size > 0.01:
|
||||
raise RuntimeError(
|
||||
f"""The file size different is more than 1%:
|
||||
raise RuntimeError(f"""The file size different is more than 1%:
|
||||
- {sf_filename}: {sf_size}
|
||||
- {pt_filename}: {pt_size}
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
# check if the tensors are the same
|
||||
reloaded = safetensors.torch.load_file(sf_filename)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only BaiChuan model compatible with HuggingFace weights."""
|
||||
|
||||
import math
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""SGLang BailingMoE model."""
|
||||
|
||||
import logging
|
||||
from typing import Iterable, List, Optional, Tuple, Union
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""SGLang BailingMoENextN model."""
|
||||
|
||||
import logging
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# ==============================================================================
|
||||
|
||||
"""Inference-only DeepSeek NextN Speculative Decoding."""
|
||||
|
||||
import logging
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# Adapted from
|
||||
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/llama.py#L1
|
||||
"""Inference-only Apertus model compatible with HuggingFace weights."""
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import math
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# Adapted from:
|
||||
# https://github.com/vllm-project/vllm/blob/fb6af8bc086328ca6659e72d11ffd4309ce4de22/vllm/model_executor/models/deepseek_v2.py
|
||||
"""Inference-only DeepseekV2 model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
|
||||
""" Inference-only Ernie4.5 model compatible with baidu/ERNIE-4.5-*-PT weights. """
|
||||
"""Inference-only Ernie4.5 model compatible with baidu/ERNIE-4.5-*-PT weights."""
|
||||
|
||||
from typing import Iterable, List, Optional, Tuple, Union
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
|
||||
""" Inference-only Ernie4.5 VL model compatible with baidu/ERNIE-4.5-VL-*-PT weights. """
|
||||
"""Inference-only Ernie4.5 VL model compatible with baidu/ERNIE-4.5-VL-*-PT weights."""
|
||||
|
||||
import logging
|
||||
from itertools import islice
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only Ernie45-VL model compatible with HuggingFace weights."""
|
||||
|
||||
import logging
|
||||
from functools import lru_cache, partial
|
||||
from typing import Iterable, List, Optional, Tuple, Type
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
|
||||
""" Ernie4.5 MTP model compatible with baidu/ERNIE-4.5-*-PT weights. """
|
||||
"""Ernie4.5 MTP model compatible with baidu/ERNIE-4.5-*-PT weights."""
|
||||
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only GPT-2 model compatible with HuggingFace weights."""
|
||||
|
||||
from typing import Iterable, Optional, Tuple, Type
|
||||
|
||||
import torch
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only HunYuan model compatible with HuggingFace weights."""
|
||||
|
||||
import re
|
||||
from typing import Any, Dict, Iterable, Optional, Tuple
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""SGLang LLaDA2MoeModelLM model."""
|
||||
|
||||
import logging
|
||||
from typing import Iterable, Optional, Tuple, Union
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Adapted from:
|
||||
# https://github.com/vllm-project/vllm/blob/7193774b1ff8603ad5bf4598e5efba0d9a39b436/vllm/model_executor/models/mllama.py
|
||||
"""PyTorch Mllama model."""
|
||||
|
||||
import math
|
||||
from typing import Iterable, List, Optional, Tuple, Union
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/nemotron_nas.py
|
||||
|
||||
"""Inference-only deci model compatible with HuggingFace weights."""
|
||||
|
||||
from typing import Iterable, Optional, Tuple, Type, Union
|
||||
|
||||
import torch
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# Adapted from
|
||||
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/olmo.py#L1
|
||||
"""Inference-only OLMo model compatible with HuggingFace weights."""
|
||||
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
import torch
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# Adapted from
|
||||
# https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/olmo2.py
|
||||
"""Inference-only OLMo2 model compatible with HuggingFace weights."""
|
||||
|
||||
from functools import partial
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# ==============================================================================
|
||||
|
||||
"""Inference-only OPT model compatible with HuggingFace weights."""
|
||||
|
||||
import logging
|
||||
from collections.abc import Iterable
|
||||
from typing import Optional, Union
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# LICENSE: https://huggingface.co/OrionStarAI/Orion-14B-Base/blob/main/LICENSE
|
||||
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/orion.py
|
||||
"""Inference-only Orion-14B model compatible with HuggingFace weights."""
|
||||
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Optional, Tuple
|
||||
|
||||
|
||||
@@ -23,11 +23,15 @@ import torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from transformers import PixtralVisionConfig, PretrainedConfig
|
||||
from transformers.models.pixtral.modeling_pixtral import PixtralRotaryEmbedding
|
||||
from transformers.models.pixtral.modeling_pixtral import (
|
||||
PixtralRotaryEmbedding,
|
||||
)
|
||||
from transformers.models.pixtral.modeling_pixtral import (
|
||||
generate_block_attention_mask as _get_pixtral_attention_mask,
|
||||
)
|
||||
from transformers.models.pixtral.modeling_pixtral import position_ids_in_meshgrid
|
||||
from transformers.models.pixtral.modeling_pixtral import (
|
||||
position_ids_in_meshgrid,
|
||||
)
|
||||
|
||||
from sglang.srt.layers.activation import SiluAndMul
|
||||
from sglang.srt.layers.attention.vision import VisionAttention
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# Adapted from llama2.py
|
||||
# Modify details for the adaptation of Qwen2 model.
|
||||
"""Inference-only Qwen2 model compatible with HuggingFace weights."""
|
||||
|
||||
import logging
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only Qwen2-VL model compatible with HuggingFace weights."""
|
||||
|
||||
import logging
|
||||
import re
|
||||
from functools import partial
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only Qwen2-Audio model compatible with HuggingFace weights."""
|
||||
|
||||
import logging
|
||||
from typing import Any, Iterable, List, Optional, Tuple
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only Qwen2-VL model compatible with HuggingFace weights."""
|
||||
|
||||
import logging
|
||||
from functools import lru_cache, partial
|
||||
from typing import Iterable, List, Optional, Tuple, Type, TypedDict
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""Inference-only Qwen3.5 model and Qwen3.5 MoE model compatible with HuggingFace weights."""
|
||||
|
||||
import logging
|
||||
from functools import lru_cache
|
||||
from typing import Iterable, Optional, Set, Tuple, Union
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# ==============================================================================
|
||||
|
||||
"""Inference-only Qwen3_5 MTP model."""
|
||||
|
||||
import logging
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
|
||||
@@ -366,8 +366,8 @@ class Qwen3GatedDeltaNet(nn.Module):
|
||||
|
||||
# [b, sq, ng, (hn + hn + np/ng * hn + np/ng + np/ng)]
|
||||
# --> [b, sq, ng, hn], [b, sq, ng, hn], [b, sq, ng, np/ng * hn], [b, sq, ng, np/ng * hn], [b, sq, ng, np/ng], [b, sq, ng, np/ng]
|
||||
(query, key, value, z) = torch.split(mixed_qkvz, split_arg_list_qkvz, dim=2)
|
||||
(b, a) = torch.split(mixed_ba, split_arg_list_ba, dim=2)
|
||||
query, key, value, z = torch.split(mixed_qkvz, split_arg_list_qkvz, dim=2)
|
||||
b, a = torch.split(mixed_ba, split_arg_list_ba, dim=2)
|
||||
|
||||
# [b, sq, ng, np/ng * hn] -> [b, sq, np, hn]
|
||||
value = value.reshape(value.size(0), -1, self.head_v_dim)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# ==============================================================================
|
||||
|
||||
"""Inference-only Qwen3Next MTP Speculative Decoding."""
|
||||
|
||||
import logging
|
||||
from typing import Iterable, Optional, Tuple
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user