Skip to content

armgit / janas

Public Imported from GitHub
0

37 tok/s from Qwen3-Next-80B (48 GB) on a 32 GB laptop, 24 without drafts vs 2.8 for llama.cpp; reading 62 vs 16 tok/s. Faster than llama.cpp on all 13 models compared in Q4_K_M. LLMs bigger than your RAM, pure C, CPU or GPU.

1.9 KB
Raw Blame
/* SPDX-License-Identifier: GPL-3.0-or-later
   Copyright (C) 2026 Maurizio Cammalleri */
/*
 * arch.c - the architectures Janas-LLM runs (see arch.h).
 */
#include "arch.h"

#include <string.h>

static const struct janas_arch archs[] = {
    {.name = "qwen3", .rec = JANAS_REC_NONE},
    /* Llama 3: Qwen3's dense layers without the heads' norms; its RoPE
       factors (rope_freqs, rope_scaling of type llama3) as Gemma 4's */
    {.name = "llama", .rec = JANAS_REC_NONE, .no_qk_norm = 1},
    {.name = "qwen3moe", .rec = JANAS_REC_NONE},
    {.name = "qwen3next",
     .rec = JANAS_REC_NEXT,
     .attn_gate = 1,
     .shared_expert = 1,
     .post_attn_norm = 1},
    {.name = "qwen35moe",
     .rec = JANAS_REC_Q35,
     .attn_gate = 1,
     .shared_expert = 1,
     .post_attn_norm = 1,
     .vmap_mod = 1,
     .nextn_in_file = 1},
    /* Qwen3.5, 3.6 and 3.8 dense: qwen35moe with a dense feed-forward */
    {.name = "qwen35",
     .rec = JANAS_REC_Q35,
     .attn_gate = 1,
     .post_attn_norm = 1,
     .vmap_mod = 1,
     .nextn_in_file = 1},
    /* Qwen3.8-Flash-Next: qwen35moe's layers inside hyper-connections */
    {.name = "qwen4exp",
     .rec = JANAS_REC_Q35,
     .attn_gate = 1,
     .shared_expert = 1,
     .vmap_mod = 1,
     .hc = 1},
    /* NVIDIA's Nemotron-H with LatentMoE (Nemotron 3.5 Bolt) */
    {.name = "nemotron_h_moe",
     .rec = JANAS_REC_MAMBA2,
     .no_qk_norm = 1,
     .nh = 1},
    /* its scores are not scaled down, and an eight-bit key moves them: at
       eight bits llama.cpp agrees with its own f16 cache at 169 of 200 most
       likely tokens */
    {.name = "gemma4",
     .rec = JANAS_REC_NONE,
     .gelu = 1,
     .sandwich = 1,
     .swa = 1,
     .kv16 = 1},
};

const struct janas_arch *janas_arch_find(const char *name, unsigned len)
{
    for (size_t i = 0; i < sizeof(archs) / sizeof(archs[0]); i++)
        if (strncmp(name, archs[i].name, len) == 0)
            return &archs[i];
    return NULL;
}