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