Skip to content

model-types: move per-model_type fixes into catalogue/model-types - #60

Merged
DevelopmentCats merged 3 commits into
mainfrom
devcats/model-types
Nov 5, 2026
Merged

DevelopmentCats merged 3 commits into
mainfrom
devcats/model-types

Conversation

@DevelopmentCats

@DevelopmentCats DevelopmentCats commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

The gpt-oss tiktoken vocab and parser flags and the Qwen3.5 chat template patch lived in Go (internal/resolve/tiktoken.go, internal/hf/hf.go). They are now files in catalogue/model-types/, one per HuggingFace model_type:

  • gpt_oss.json: fetch o200k_base.tiktoken and cl100k_base.tiktoken, set TIKTOKEN_ENCODINGS_BASE, add the tool-call and reasoning parsers (first value the installed vLLM registers).
  • qwen3_5.json, qwen3_5_moe.json: the chat template fix for the system-message check.
  • deepseek_v4.json (new, covers V4 Flash, Pro and Flash Vision): --tokenizer-mode deepseek_v4 and the deepseek_v4 tool-call and reasoning parsers. The repos ship no chat template and their cards don't name these flags, so profiles from new couldn't render chat requests.

internal/modeltype loads and validates them. A local file in ~/.config/vllm-helper/model-types.d/ adds a model type, or replaces a shipped one with the same id. Bad local files are skipped with a warning, and doctor lists them.

New commands: model-types list and model-types show <id>, both with --json.

TestNoGoCodeRepeatsAShippedModelType fails if Go code names a shipped model type id.

Behaviour differences

  • The template fix only applies to qwen3_5 and qwen3_5_moe repos. Before, any repo whose template matched the text was patched.
  • gpt-oss profiles carry TIKTOKEN_ENCODINGS_BASE in the profile. Setup no longer creates tiktoken-encodings or writes the variable to config.env. Existing config.env lines still work.
  • Doctor no longer reports harmony_vocab.
  • The notes printed when preparing a gpt-oss profile come from the catalogue file, so the wording changed.

Checks

  • go vet ./... (linux and darwin/arm64), go test -race ./... (skipping TestProbeReportsThisMachine, which fails in this VM on main too)
  • go run ./scripts/gendocs with no diff, prettier --check .
  • tools/recipediff: same 4 undeclared differences as main
  • Manually: a local model-types.d/gpt_oss.json replaced the shipped entry, a broken file was skipped with a warning

The gpt-oss tiktoken vocab and parsers and the Qwen3.5 chat template
patch were Go code in internal/resolve and internal/hf. Changing or adding
one meant editing internals. They are now catalogue files keyed on the
HuggingFace model_type, read by internal/modeltype, and a machine owner
can add or replace one in model-types.d without a rebuild.

The template fix now applies only to qwen3_5 and qwen3_5_moe repos.
gpt-oss profiles carry TIKTOKEN_ENCODINGS_BASE themselves, so setup no
longer writes it to config.env and doctor drops the harmony_vocab check.
Existing config.env lines keep working.

Adds 'model-types list' and 'model-types show'.
Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unquoted catalogue values can break saved-profile argument parsing, and non-vLLM engines silently ignore accepted file and environment rules.

3 open issues
What changed in this PR

Moves architecture-specific behavior from Go into catalogue/model-types/, continuing #59’s separation of catalogue data from runtime logic.

Changes:

  • Adds validated model-type definitions and local overrides for file downloads, parser flags, and chat-template fixes.
  • Integrates rules into profile preparation, moves tokenizer environment settings into profiles, and adds model-types list/show.
  • Updates tests, doctor output, documentation, and contributor guidance.
File Description
internal/​vllm/​validate.go Adds flag and parser-value acceptance checks.
internal/​resolve/​tiktoken.go Removes hardcoded harmony preparation.
internal/​resolve/​tiktoken_internal_test.go Removes tests replaced by catalogue-driven coverage.
internal/​resolve/​resolve.go Applies model-type rules during profile preparation.
internal/​resolve/​resolve_internal_test.go Tests profile environment and architecture-scoped patches.
internal/​resolve/​modeltype.go Implements rule-driven arguments, downloads, and template fixes.
internal/​resolve/​modeltype_internal_test.go Tests downloads and parser selection.
internal/​profile/​profile.go Writes environment settings into profiles.
internal/​modeltype/​modeltype.go Defines and validates the model-type registry.
internal/​modeltype/​modeltype_internal_test.go Tests definitions, validation, overrides, and catalogue boundaries.
internal/​modeltype/​local.go Loads local overrides and records errors.
internal/​hf/​hf.go Separates template fetching from patch logic.
internal/​hf/​hf_internal_test.go Updates coverage for template fetching.
internal/​cli/​setup.go Removes global tokenizer directory setup and configuration.
internal/​cli/​root.go Loads model types and registers their commands.
internal/​cli/​root_internal_test.go Updates the expected command set.
internal/​cli/​modeltypescmd.go Adds list/show commands with JSON output.
internal/​cli/​detectcmds.go Reports local definition errors; removes harmony-vocab reporting.
docs/​reference/​cli/​model-types/​show.md Adds generated show-command reference.
docs/​reference/​cli/​model-types/​list.md Adds generated list-command reference.
docs/​reference/​cli/​model-types.md Adds generated model-types command reference.
docs/​reference/​cli.md Links the new command group.
docs/​model-types.md Documents rules and local overrides.
docs/​manifest.json Routes the new documentation pages.
docs/​install.md Removes the global tokenizer setting from the configuration table.
CHANGELOG.md Records new commands and behavior changes.
catalogue/​model-types/​README.md Explains how to add model-type definitions.
catalogue/​model-types/​qwen3_5.json Defines the Qwen3.5 template fix.
catalogue/​model-types/​qwen3_5_moe.json Defines the Qwen3.5 MoE template fix.
catalogue/​model-types/​gpt_oss.json Defines harmony vocabulary and parser requirements.
catalogue/​catalogue.go Embeds and exposes model-type definitions.
AGENTS.md Documents the package layout and model-type guardrail.

Review effort: Balanced

Comment thread internal/resolve/modeltype.go Resolved
Comment thread internal/resolve/resolve.go Resolved
DeepSeek V4 Flash, Pro and Flash Vision all report model_type
deepseek_v4 and ship no chat template; vLLM encodes their chats through
its deepseek_v4 tokenizer mode. Their cards' vllm serve lines name
neither that nor the deepseek_v4 parsers, so a profile from 'new' could
not render a chat request.
@DevelopmentCats
DevelopmentCats changed the base branch from devcats/rename-internal-packages to main November 5, 2026 19:44
…ests

A catalogue value or a patched template path with a space in it split
into two words when EXTRA_ARGS was read back, so both are quoted now.

Model-type files applied only on engines with vllm_args, so a local
definition giving mlx a file loaded and did nothing. Files now apply on
every engine; args and chat_template_fixes are vLLM flag syntax and are
refused at load for engines without vllm_args. Non-vLLM profiles still
skip the Hub unless some model type has files for that engine.

The bad-file fixtures had ids with spaces, so they all failed at the id
check. They use valid ids now and each asserts its own error.
@DevelopmentCats
DevelopmentCats merged commit 48f4217 into main Nov 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants