Skip to content

convert: register sibling HF names for architectures the runtime already has - #8

Merged
bong-water-water-bong merged 11 commits into
1bit/hrx-vulkan-patchedfrom
census/register-sibling-hf-names
Sep 26, 2026
Merged

bong-water-water-bong merged 11 commits into
1bit/hrx-vulkan-patchedfrom
census/register-sibling-hf-names

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

The runtime accepts these GGUF architectures (LLM_ARCH_NAMES) but the converter registered only one HF class per family, so a same-family sibling name (a case variant, a base *Model, or the other head spelling) counted as an unmapped architecture in the engine census.

This registers the siblings on the existing classes. Each name is the same family/head as the registered class, so the arch the backend accepts is unchanged; no look-alike is aliased.

With it, tools/registry_build.py maps 48 more HF architectures: vulkan 266->314, hrx 247->295, zinc 44->62.

…ady has

The runtime accepts these GGUF architectures (LLM_ARCH_NAMES) but the
converter registered only one HF class per family, so a same-family sibling
name (a case variant, a base *Model, or the other head spelling) converted to
an unmapped architecture in the census.

Register the siblings on the existing classes: gpt2 (GPT2Model, GPT2),
gptneox (GPTNeoXModel), bert (BertLMHeadModel, BertForCausalLM,
RobertaForMaskedLM), mpt (MptForCausalLM, case), llama (MistralModel,
MixtralModel, LLaMA/LLAMA/LLaMAModel/LlaMAForCausalLM/llamaForCausalLM,
LlamaForConditionalGeneration), phi (Phi2Model, Phi3Model, PhimoeForCausalLM),
t5 (T5Model, MT5Model), qwen (QwenForCausalLM, QwenLMHeadModel, QWenForCausalLM,
Qwen2MoEForCausalLM, Qwen3MoeModel, Qwen3_5MoEForCausalLM, Qwen3_5Model,
Qwen35ForCausalLM), gemma (GemmaModel, Gemma2Model, Gemma3Model,
Gemma4UnifiedForCausalLM), olmo (OLMo3ForCausalLM, OlmoeModel), lfm2
(Lfm2MoEForCausalLM, Lfm2BidirectionalForMaskedLM), stablelm, gpt-oss,
starcoder (GPTBigCodeModel, GPTBigCodeLMHeadModel, Starcoder2Model), rwkv6,
falcon (RWModel), mamba (MambaModel), chatglm, command-r (Cohere2Model),
deepseek (DeepSeekV4, DeepseekOcrForConditionalGeneration), llada.

Each name is the same family/head as the registered class, so the arch the
backend accepts is unchanged; no look-alike is aliased. tools/registry_build.py
maps 48 more HF architectures (vulkan 266->314, hrx 247->295, zinc 44->62).
@bong-water-water-bong

Copy link
Copy Markdown
Author

Review from the commit poll. Most of these are spelling variants or the *Model base class of a family that's already registered; if one of those is wrong, it fails loudly at load time. Two could instead convert into a model that runs the wrong computation silently, which is the zarya → zaya failure mode in docs/arch-gaps.md:

  • BertLMHeadModel, BertForCausalLM → BertModel. These are BERT used as a causal decoder (is_decoder=True). llama.cpp's bert arch is a bidirectional encoder, so a converted checkpoint would load and run with the wrong attention mask. I'd drop both.
  • Gemma4UnifiedForCausalLM → Gemma4Model. The unified variant has its own converter class here (Gemma4UnifiedModel, for Gemma4UnifiedForConditionalGeneration). Is its CausalLM form really plain Gemma 4? If not, it belongs on Gemma4UnifiedModel or should be left unmapped.

The rest look right to me, including MistralModel/MixtralModel on LlamaModel, which is where upstream registers those families. I'm not merging until the two points above are settled.

GPU arch gptj was listed in LLM_ARCH_NAMES but had no model class, no graph and
no converter, so GPTJForCausalLM counted as unmapped and could not be served.

- src/models/gptj.cpp: hparams (layernorm eps, parallel residual), tensors
  (separate bias-free q/k/v/out, biased fc_in/fc_out, single attn_norm) and the
  graph: x = x + attn(ln_1(x)) + mlp(ln_1(x)), partial RoPE on q/k.
- src/models/models.h: declare llama_model_gptj.
- src/llama-model.cpp: dispatch LLM_ARCH_GPTJ to it; GPT-J uses normal
  (consecutive-pair) RoPE, so move it out of the no-RoPE group.
- conversion/gptj.py: GPTJForCausalLM -> gguf.MODEL_ARCH.GPTJ, partial
  rotary_dim, GPT-2 BPE vocab; registered in TEXT_MODEL_MAP.

Builds (cmake+ninja, libllama). tools/registry_build.py now maps
GPTJForCausalLM (vulkan+hrx).
@github-actions github-actions Bot added the model label Sep 26, 2026
bong-water-water-bong and others added 8 commits September 26, 2026 03:13
Add ARCH.OPT (gguf constants + tensor names for model.decoder.*), LLM_ARCH_OPT,
llama_model_opt + src/models/opt.cpp (pre-norm: x=x+attn(LN(x));
x=x+fc2(relu(fc1(LN(x)))), learned positions, biased q/k/v/out and fc1/fc2),
dispatch, no-RoPE, and conversion/opt.py (drops the two padding rows OPT's
learned positions carry). Builds (cmake+ninja, libllama).
GPT-Neo is a GPT-2-style decoder with separate bias-free q/k/v, a biased
out_proj and biased c_fc/c_proj, learned positions, and alternating global/local
attention. Add MODEL_ARCH.GPTNEO (+names/tensors), LLM_ARCH_GPTNEO, a
llama_model_gptneo graph that drives the iswa cache with set_swa_pattern(2) and
window 256, and conversion/gptneo.py. Builds (cmake+ninja, libllama).
CodeGen is GPT-J-shaped: parallel attention/MLP off one norm, partial RoPE,
bias-free projections, but a single fused qkv_proj and a biased MLP. Add
MODEL_ARCH.CODEGEN (+names/tensors), LLM_ARCH_CODEGEN, llama_model_codegen
(fused-QKV via build_qkv, NORM rope), and conversion/codegen.py. Builds.
pico-lm's PicoDecoder is an ordinary Llama (RMSNorm, GQA, RoPE, SwiGLU) under
its own module names (embedding_proj, layers.*.attention.{q,k,v,o}_proj,
swiglu.w_{0,1,2}, de_embedding_proj). Add those names to the tensor map and a
converter that strips the pico_decoder. wrapper and emits the llama arch — the
runtime already serves it, so no new kernels. Registry maps PicoDecoderHF
(vulkan+hrx+zinc).
Cambrian's Qwen text tower declares model_type qwen2 with Qwen2's shapes and
tensor names. Register the class name against the existing qwen2 architecture —
the runtime already serves it.
… the unified class

BertLMHeadModel and BertForCausalLM are BERT as a causal decoder (is_decoder=True); the bert
arch is a bidirectional encoder, so a converted checkpoint would run with the wrong mask.
Gemma4UnifiedForCausalLM goes on Gemma4UnifiedModel, which adds the unified variant's
suppress tokens, rather than on plain Gemma4Model.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mers

Each new port was checked against transformers in FP32: teacher-forced top-1 over 3 prompts x
32 greedy tokens, one prompt of 340 tokens (past GPT-Neo's 256-token local window), F32 GGUFs
from this converter, Vulkan.

- gptneo: no attention scaling (GPTNeoSelfAttention multiplies q.k^T unscaled; its flash
  path passes softmax_scale=1.0). Was 1/sqrt(head_dim).
- codegen: qkv_proj is 4 model-parallel blocks, each (query, value, key)
  (CodeGenAttention.forward); the converter now writes q, then k, then v. lm_head has a bias:
  the loader reads output.bias and the graph adds it. Mask buffer attn.causal_mask skipped.
- gptj: lm_head bias, as for codegen. The attn.bias / attn.masked_bias buffers are skipped
  (they were passed on to the tensor map and failed).
- opt, gptj: their tokenizer is GPT-2's byte-level BPE; its checksum was not recognised.
- test-llama-archs: GPT-J has an implementation now, so it is no longer skipped.

| model | top-1 agreement |
|---|---|
| facebook/opt-125m | 96/96 |
| EleutherAI/gpt-neo-125m | 96/96 |
| Salesforce/codegen-350M-mono | 96/96 (0/96 before the qkv reorder and output bias) |
| hf-internal-testing/tiny-random-GPTJForCausalLM | 89/89 (7 positions the server could not format) |

test-llama-archs passes for all four (Vulkan and CPU, save/reload) and the full suite has 0 FAIL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Author

Pushed two commits here.

  1. Aliases. Dropped BertLMHeadModel/BertForCausalLM, and registered Gemma4UnifiedForCausalLM on Gemma4UnifiedModel instead of plain Gemma 4.
  2. The four new ports. Fixed after checking each against transformers FP32 (teacher-forced top-1, 3 prompts × 32 tokens, one of 340 tokens):
    • OPT: 96/96;
    • GPT-Neo: 96/96, with no attention scaling, as transformers does;
    • CodeGen: 96/96, after reordering the (query, value, key) blocks of qkv_proj and adding the lm_head bias; it was 0/96;
    • GPT-J: 89/89 on the tiny test model, after the lm_head bias, skipping the mask buffers, and the tokenizer checksum fix it shares with OPT.

test-llama-archs passes for all four, and GPT-J is no longer skipped. The full suite shows 0 FAIL. Details are in the commit message. I'll merge once the hosted Ubuntu jobs pass.

@bong-water-water-bong
bong-water-water-bong merged commit 83e1c41 into 1bit/hrx-vulkan-patched Sep 26, 2026
10 of 27 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the census/register-sibling-hf-names branch October 12, 2026 01:32
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