Skip to content

Model arch fixes - #13960

Closed
danielhanchen wants to merge 6 commits into
mainfrom
studio-model-arch-fixes
Closed

danielhanchen wants to merge 6 commits into
mainfrom
studio-model-arch-fixes

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Adds Studio support for GGUFs of llama.cpp architecture beam: a large MoE with a Harmony-style chat template that calls tools with XML argument bodies. The GGUF repo ships twelve split quant folders (UD-IQ1_S through UD-Q6_K_XL, Q8_0, BF16, 50 GB shards) with no mmproj and no drafter.

Changes

Sampling defaults (inference_defaults.json)

  • The model's generation_config.json has no sampling settings, so every id fell through to default.yaml (temperature 0.7, top_p 0.95, min_p 0.01).
  • New family beam-1: temperature 1.0, top_p 1.0, top_k disabled (-1, sent to llama-server as 0), min_p 0.0. These are the Harmony defaults the GGUFs were evaluated with.
  • The pattern is version-anchored (beam-1), so an unrelated name that only contains the word does not match it.

Reasoning effort (llama_cpp.py)

  • The template accepts an int or minimal / low / medium / high / xhigh / max, and calls raise_exception on any other string. Studio forwarded the OpenAI none sentinel unchanged, so that request failed to render.
  • The model cannot turn reasoning off, so none now maps to minimal, the smallest budget it was trained with. Every other level passes through unchanged.
  • Detection already offers the six levels. The UI default (medium) and the API default (high when thinking is on, low when off) still apply, and with no kwarg the template uses its own default (max).

Tool calls (llama_cpp.py)

  • The template declares tools, and the model calls them with a Harmony header plus XML argument bodies (<|constrain|>xml). llama-server picks its gpt-oss parser for this template, and that parser rejects these calls with an HTTP 500 partway through the stream.
  • For this architecture, supports_tools and supports_tool_passthrough now report False:
    • The chat UI hides the tool controls, so plain chat works.
    • An API request that includes tools gets an immediate 400 ("template does not advertise tools") instead of a 500 after generation.
  • _TOOL_CALLS_UNPARSED_ARCHS is the single switch. Remove the entry once llama.cpp ships a parser for this format.

Verified unchanged, covered by tests

  • Variant listing and resolution for all twelve split folders. The default pick is UD-Q4_K_XL.
  • GGUF header parsing. The per-layer sliding_window_pattern (43 sliding-window layers with a 512-token window, plus 9 full layers) is read, so the KV estimate charges full context only to the full layers.
  • Offload layout. The 3 dense blocks stay resident; the 49 MoE blocks expose only their routed expert stacks, and only those match the -ot spill pattern.
  • Checked against the real UD-IQ1_S GGUF header with layout_from_gguf and _read_gguf_metadata: arch beam, 256 experts / 8 used, 96.3 of 103.1 GB spillable.

Tests

studio/backend/tests/test_harmony_xml_moe_gguf.py, 48 tests, all offline (the HF file listing is mocked):

  • Variant menu, first shard and siblings for each of the 12 quants, and the default pick.
  • Sampling for repo, repo:QUANT, base, HF-cache and local-path ids. Neighbouring families are unchanged.
  • Reasoning kwargs for every level and for enable_thinking on and off, each rendered through the template's own effort block.
  • Tool gating for this architecture, with other architectures unchanged.
  • KV estimate and offload layout from a synthetic header.

Against base main, 12 of these fail (the sampling, none coercion and tool-gating tests) and 36 pass (the verification-only ones). On this branch all 48 pass.

Studio support for llama.cpp arch beam GGUFs: Harmony sampling defaults, map reasoning_effort none to minimal, withhold tools whose XML call bodies llama-server cannot parse, and tests for split variant resolution, KV and offload layout.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T05:28:34.084872Z 7f0c9db PR opened
🔒 Security Review ⚠️ Failed 2026-10-16T05:28:34.660432Z 7f0c9db PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

danielhanchen and others added 3 commits October 15, 2026 22:29
Tools for the arch were withheld outright. Read the llama-server binary and its llama-common library for the XML parameter call parser instead, so builds that carry it get tools and older builds keep plain chat. Fails closed on an unknown or unreadable binary.
danielhanchen added a commit that referenced this pull request Oct 16, 2026
…ice (#13982)

## Summary

`Repo tests (CPU, studio)` fails on every PR based on main since #13882
(for example #13960 and #13962):

```
tests/python/test_accelerator_skip_guards.py::test_no_skip_guard_reads_a_spoofable_accelerator_probe
E   AssertionError: these skip guards read a probe tests/_zoo_aggressive_cuda_spoof.py patches to True process-wide, ...
E   assert not ['test_optimizer_state_offload.py:139: torch.cuda.is_available()', ...]
```

#13882 added `tests/test_optimizer_state_offload.py` with seven
`@pytest.mark.skipif(not torch.cuda.is_available(), ...)` guards. The
CUDA spoof the zoo tests install patches `torch.cuda.is_available` to
True for the whole process. When this file shares a session with them on
a CPU runner, its CUDA cases un-skip and fail. The repo-wide guard
caught this before it could flake. The product change is fine; the
guards are what is wrong.

## Change

Gate those seven cases on `has_real_cuda()` from
`tests/_shared/real_accelerator.py`, the same probe the other CUDA-only
tests use (#13936, #13937). It checks for a real device rather than the
patchable `is_available`. The CPU cases in the file are unchanged.

## Testing

- `tests/python/test_accelerator_skip_guards.py` +
`tests/test_optimizer_state_offload.py` on CPU: 40 passed, 15 skipped.
- With the original file restored, the guard test fails again (1 failed,
23 passed), naming the same seven lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant