Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
default_language_version:
python: python3

# The vendored upstream module stays byte-diffable against its source; keep
# formatters and linters away so upstream-tracking diffs remain minimal.
exclude: '^miles/utils/chat_template_utils/templates/encoding_dsv32\.py$'

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
Expand Down
12 changes: 9 additions & 3 deletions miles/backends/sglang_utils/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,15 @@ def new_add_argument_wrapper(*name_or_flags, **kwargs):
# Avoid double prefixing if dest somehow already starts with sglang_
if not original_dest.startswith("sglang_"):
final_kwargs["dest"] = f"sglang_{original_dest}"
# If 'dest' is not explicitly provided (or is None/not a string),
# argparse will derive 'dest' from the (now prefixed) flag names.
# E.g., if the first flag is "--sglang-foo-bar", argparse sets dest to "sglang_foo_bar".
elif "dest" not in final_kwargs:
# argparse derives dest from the first alias, so store parallel sizes under SGLang's short field names.
for item_flag in name_or_flags:
if not isinstance(item_flag, str) or not item_flag.startswith("--"):
continue
canonical_dest = item_flag[2:].replace("-", "_")
if canonical_dest in ("tp_size", "dp_size", "pp_size", "ep_size"):
final_kwargs["dest"] = f"sglang_{canonical_dest}"
break

old_add_argument(*new_name_or_flags_list, **final_kwargs)

Expand Down
16 changes: 9 additions & 7 deletions miles/utils/chat_template_utils/deepseek.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Shared bridge for the DeepSeek official-encoder families (V3.2, V4).

Neither family ships a jinja chat_template: sglang renders their prompts
through per-family ``encoding_dsv*`` modules that share one calling
convention, and miles' ``apply_chat_template`` routes any matching tokenizer
here so training-side renders stay byte-aligned with what the runtime
serves. Each family is one ``DeepSeekFamily`` instance wrapping its encoder
module; everything else is shared.
Neither family ships a jinja chat_template: V4 renders through sglang's
``encoding_dsv4``, while V3.2 uses miles' vendored
``templates.encoding_dsv32``. Both modules share one calling convention,
and miles' ``apply_chat_template`` routes any matching tokenizer here. Each
family is one ``DeepSeekFamily`` instance wrapping its encoder module;
everything else is shared.
"""

from __future__ import annotations
Expand All @@ -16,9 +16,11 @@
import os
from typing import Any

from sglang.srt.entrypoints.openai import encoding_dsv4, encoding_dsv32
from sglang.srt.entrypoints.openai import encoding_dsv4
from sglang.srt.entrypoints.openai.protocol import Tool

from miles.utils.chat_template_utils.templates import encoding_dsv32

_ASSISTANT_SP_TOKEN = "<|Assistant|>"


Expand Down
1 change: 1 addition & 0 deletions miles/utils/chat_template_utils/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Bundled fixed chat templates and the vendored official DeepSeek V3.2 encoder."""
Loading
Loading