refactor : merge max_prompt_len into max_seq_len, replace assert with raise

- Engine/Scheduler/TaskManager: merge max_prompt_len into max_seq_len
- train.py: replace bare assert with ValueError/FileNotFoundError
- server.py: add --max_seq_len CLI option
- engine.py: remove dead page_size param
This commit is contained in:
2026-07-27 08:05:11 +08:00
parent 05c7432964
commit 53c804e233
12 changed files with 27 additions and 21 deletions
-1
View File
@@ -47,7 +47,6 @@ class GenerationBenchmark:
tokenizer=None,
max_batch_size=256,
max_seq_len=config.max_position_embeddings,
max_prompt_len=config.max_position_embeddings,
)
def run_prefill_benchmark(
-1
View File
@@ -38,7 +38,6 @@ def processor(
tokenizer=tokenizer,
max_batch_size=batch_size * num_samples,
max_seq_len=cache_len,
max_prompt_len=cache_len,
)
print(f"Reading {input_json_file} ...")
+10 -1
View File
@@ -31,7 +31,15 @@ _DTYPES = ["bfloat16", "float16", "float32"]
default=16,
help="Maximum batch size for continuous batching.",
)
def server_command(host, port, reload, param_path, device, dtype, max_batch_size):
@click.option(
"--max_seq_len",
type=int,
default=None,
help="Maximum sequence length (KV cache size + prompt truncation). Uses model config if not set.",
)
def server_command(
host, port, reload, param_path, device, dtype, max_batch_size, max_seq_len
):
"""Launch inference server (OpenAI-compatible API)."""
dtype_map = {
"bfloat16": torch.bfloat16,
@@ -51,6 +59,7 @@ def server_command(host, port, reload, param_path, device, dtype, max_batch_size
dtype=dtype_map[dtype],
param_path=Path(param_path),
max_batch_size=max_batch_size,
max_seq_len=max_seq_len,
)
+8 -3
View File
@@ -402,15 +402,20 @@ def train(
decay_steps: int,
**kwargs,
):
assert train_type in [
if train_type not in [
"seq",
"sft",
"dpo",
"grpo",
"online_grpo",
"online_dpo",
]
assert os.path.exists(param_path)
]:
raise ValueError(
f"Invalid train_type '{train_type}'. "
f"Must be one of: seq, sft, dpo, grpo, online_grpo, online_dpo"
)
if not os.path.exists(param_path):
raise FileNotFoundError(f"Model directory not found: {param_path}")
if nprocs > 1 and parallel_mode == "none":
raise ValueError(
"--nprocs > 1 requires --parallel_mode to be 'ddp', 'fsdp', or 'fsdp2'"