Files
wehub-resource-sync 94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:16 +08:00

273 lines
9.8 KiB
Python

# SPDX-License-Identifier: Apache-2.0
import argparse
import dataclasses
import os
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any
from sglang.multimodal_gen.configs.sample.sampling_params import (
DataType,
_sanitize_filename,
)
from sglang.multimodal_gen.utils import StoreBoolean, expand_path_fields
if TYPE_CHECKING:
from sglang.multimodal_gen.runtime.server_args import ServerArgs
@dataclass
class VLASamplingParams:
"""Sampling parameters for VLA/action-generation policies."""
data_type: DataType = DataType.ACTION
request_id: str | None = field(default=None, metadata={"batch_sig_exclude": True})
prompt: str | list[str] | None = field(
default="", metadata={"batch_sig_exclude": True}
)
num_outputs_per_prompt: int = 1
seed: int | list[int] = field(default=42, metadata={"batch_sig_exclude": True})
generator_device: str | None = None
num_inference_steps: int = 10
output_path: str | None = field(default=None, metadata={"batch_sig_exclude": True})
output_file_name: str | None = field(
default=None, metadata={"batch_sig_exclude": True}
)
save_output: bool = False
return_file_paths_only: bool = False
profile: bool = field(default=False, metadata={"batch_sig_exclude": True})
num_profiled_timesteps: int = field(default=5, metadata={"batch_sig_exclude": True})
profile_all_stages: bool = field(
default=False, metadata={"batch_sig_exclude": True}
)
debug: bool = field(default=False, metadata={"batch_sig_exclude": True})
perf_dump_path: str | None = field(
default=None, metadata={"batch_sig_exclude": True}
)
suppress_logs: bool = field(default=False, metadata={"batch_sig_exclude": True})
enable_sequence_shard: bool | None = None
max_sequence_length: int | None = None
no_override_protected_fields: bool = field(
default=False, metadata={"batch_sig_exclude": True}
)
def __post_init__(self) -> None:
self.data_type = DataType.ACTION
self._validate()
env_steps = os.environ.get("SGLANG_TEST_NUM_INFERENCE_STEPS")
if env_steps is not None and self.num_inference_steps is not None:
self.num_inference_steps = int(env_steps)
def build_request_extra(self) -> dict[str, Any]:
extra = {}
diffusers_kwargs = getattr(self, "diffusers_kwargs", None)
if diffusers_kwargs:
extra["diffusers_kwargs"] = diffusers_kwargs
explicit_fields = getattr(self, "_explicit_fields", None)
if explicit_fields is not None:
extra["explicit_fields"] = sorted(explicit_fields)
return extra
def apply_request_extra(self, req: Any) -> None:
req.extra.update(self.build_request_extra())
def _validate(self):
if (
not isinstance(self.num_outputs_per_prompt, int)
or self.num_outputs_per_prompt <= 0
):
raise ValueError(
"num_outputs_per_prompt must be a positive int, "
f"got {self.num_outputs_per_prompt!r}"
)
if isinstance(self.seed, list):
if not self.seed:
raise ValueError("seed list must not be empty")
for seed in self.seed:
if isinstance(seed, bool) or not isinstance(seed, int) or seed < 0:
raise ValueError(
f"seed list must contain non-negative ints, got {self.seed!r}"
)
elif (
isinstance(self.seed, bool)
or not isinstance(self.seed, int)
or self.seed < 0
):
raise ValueError(
f"seed must be a non-negative int or list of ints, got {self.seed!r}"
)
if (
not isinstance(self.num_inference_steps, int)
or self.num_inference_steps <= 0
):
raise ValueError(
"num_inference_steps must be a positive int, "
f"got {self.num_inference_steps!r}"
)
if self.generator_device not in (None, "cuda", "musa", "cpu"):
raise ValueError(
"generator_device must be one of None, 'cuda', 'musa', or 'cpu', "
f"got {self.generator_device!r}"
)
def _validate_with_pipeline_config(self, pipeline_config):
if not pipeline_config.task_type.is_action_gen():
raise ValueError(
f"VLASamplingParams requires an ACTION pipeline, got {pipeline_config.task_type.name}"
)
def _adjust(self, server_args: "ServerArgs"):
expand_path_fields(self)
self.data_type = DataType.ACTION
self.return_file_paths_only = False
if self.output_path is None and server_args.output_path is not None:
self.output_path = server_args.output_path
if self.output_path is None:
self.save_output = False
if self.save_output and not server_args.comfyui_mode:
self._set_output_file_name()
def _set_output_file_ext(self):
if self.output_file_name and not self.output_file_name.endswith(".json"):
self.output_file_name = f"{self.output_file_name}.json"
def _set_output_file_name(self):
if self.output_file_name is None:
self.output_file_name = "vla_action"
self.output_file_name = _sanitize_filename(self.output_file_name)
self._set_output_file_ext()
def output_file_path(self):
if self.output_path is None or self.output_file_name is None:
return None
return os.path.join(self.output_path, self.output_file_name)
def _merge_with_user_params(
self,
user_params: "VLASamplingParams",
explicit_fields: set[str] | None = None,
):
if user_params is None:
return
predefined_fields = set(type(self).__annotations__.keys())
allow_override_protected = not user_params.no_override_protected_fields
for field_info in dataclasses.fields(user_params):
field_name = field_info.name
user_value = getattr(user_params, field_name)
if field_info.default is not dataclasses.MISSING:
default_class_value = field_info.default
elif field_info.default_factory is not dataclasses.MISSING:
default_class_value = field_info.default_factory()
else:
default_class_value = dataclasses.MISSING
if explicit_fields is not None:
is_user_modified = field_name in explicit_fields
else:
is_user_modified = user_value != default_class_value
is_protected_field = field_name in predefined_fields
if is_user_modified and (
allow_override_protected or not is_protected_field
):
setattr(self, field_name, user_value)
if explicit_fields is not None:
self._explicit_fields = set(explicit_fields)
self.__post_init__()
@staticmethod
def add_cli_args(parser: Any) -> Any:
def add_argument(*name_or_flags, **kwargs):
kwargs.setdefault("default", argparse.SUPPRESS)
return parser.add_argument(*name_or_flags, **kwargs)
add_argument(
"--prompt",
type=str,
nargs="+",
help="Language instruction(s) for the VLA policy.",
)
add_argument(
"--num-inference-steps",
type=int,
help="Number of action denoising steps.",
)
add_argument(
"--num-outputs-per-prompt",
type=int,
help="Number of candidate actions to generate per observation.",
)
add_argument(
"--seed",
type=int,
nargs="+",
help="Random seed for action noise generation.",
)
add_argument(
"--generator-device",
type=str,
choices=["cuda", "musa", "cpu"],
help="Device for random generator. Default: use the model-specific setting.",
)
add_argument(
"--profile",
action="store_true",
help="Enable torch profiler for action denoising.",
)
add_argument(
"--num-profiled-timesteps",
type=int,
help="Number of denoising timesteps to profile after warmup.",
)
add_argument(
"--profile-all-stages",
action="store_true",
dest="profile_all_stages",
help="Used with --profile, profile all pipeline stages.",
)
add_argument("--debug", action="store_true")
add_argument(
"--enable-sequence-shard",
action=StoreBoolean,
help="Enable sequence dimension shard with sequence parallelism.",
)
add_argument(
"--max-sequence-length",
type=int,
help="Maximum prefix sequence length.",
)
add_argument(
"--no-override-protected-fields",
action="store_true",
help="If set, disallow user params to override subclass-defined fields.",
)
return parser
@classmethod
def get_cli_args(cls, args: argparse.Namespace):
sampling_params_fields = {attr.name for attr in dataclasses.fields(cls)}
args_attrs = set(vars(args).keys())
attrs = sampling_params_fields & args_attrs
cli_args = {
attr: getattr(args, attr)
for attr in attrs
if hasattr(args, attr) and getattr(args, attr) is not None
}
if isinstance(cli_args.get("seed"), list) and len(cli_args["seed"]) == 1:
cli_args["seed"] = cli_args["seed"][0]
return cli_args
def output_size_str(self) -> str:
return "action"
def seconds(self) -> float:
return 0.0