jangq

jjang-ai活跃维护

面向 Apple Silicon 的自适应混合精度量化与推理运行时,把 GGUF 模型转成 MLX 可用格式,让 Mac 上跑大模型更省显存。

JANG — GGUF for MLX. YOU MUST USE JANG_Q RUNTIME. Adaptive Mixed-Precision Quantization + Runtime for Apple Silicon

v2.5.52发布于 2026-10-27 19:01 UTC232star27fork同步于 2026-11-11 05:59 UTC

怎么上手

由 README 提炼,执行前请确认
pip install "jang[mlx]>=2.5.18"
硬件要求按 README 说明

仅支持 Apple Silicon(Metal),按统一内存估算:10 GB 模型需 16 GB Mac,112 GB 模型需 128 GB Mac;README 未提及 CPU 或其他 GPU 厂商支持。

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

面向 Apple Silicon 的 MLX 混合精度量化格式与运行时,让超大 MoE 模型在 Mac 统一内存里以低位宽跑起来

面向 Apple Silicon 的自适应混合精度量化与推理运行时,把 GGUF 模型转成 MLX 可用格式,让 Mac 上跑大模型更省显存。

核心能力

  • 按张量分配不同位宽,注意力 8-bit、专家 2-bit
  • 用 bfloat16 自动检测避免大专家模型 float16 溢出
  • 提供 JANG_1L/2L/4K/4M 等多档量化 profile
  • 自带 jang convert 转换与 jang_tools 加载推理
  • 附 MMLU 基准脚本,支持先无思考再推理重试

容易踩的坑

LM Studio、Ollama、Inferencer 目前不支持 JANG,需用 MLX Studio 或 jang 自带运行时;视觉模型要另装 pip install "jang[vlm]";需 Python 3.11+,且模型要单独从 HuggingFace 下载或自行 convert。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.5.52
  1. v2.5.52JANG 2.5.52最新正式版2026-10-27 · 2026-10-27 19:01 UTC

    Fresh installs of vMLX should receive the DeepSeek-V4.1 governor correction already merged in #41 and selected by vMLX #347. Publish that runtime as JANG2.5.52 so the registry package matches the app/source pin. No runtime code changes in this PR.

    Validation: retained #41 governor tests and live JANGHT/affine measurements; rebuilt wheel/sdist and Twine checks pass. No models loaded or downloaded for this metadata release.

  2. v2.5.51JANG 2.5.512026-10-27 · 2026-10-27 10:15 UTC
    查看更新说明

    Fresh vMLX installations need the DeepSeek-V4.1-Flash-1017 runtime that is absent from JANG 2.5.50. Release the merged affine/JANGHT runtime as 2.5.51 and document its image, DSML, adaptive DSpark and compact cache support.

    Validation: wheel and sdist build; twine metadata checks; focused model-free Engram and sampled-decoding checks. No full-model qualification is claimed.

  3. v2.5.50JANG 2.5.502026-10-18 · 2026-10-18 16:14 UTC
    查看更新说明

    JANG 2.5.50

    Include the Nemotron-3.5 Bolt and Super-VL vision runtime modules in the Python distribution so clean installations can load their supported image inputs.

    This packaging correction preserves the existing quantization formats and numerical runtime behavior.

  4. v2.5.49JANG 2.5.492026-10-01 · 2026-10-01 00:36 UTC
    查看更新说明

    JANG 2.5.49

    • Package JANGH modules for GLM-5.3-Flash and Naive-N0.5: capture, calibration, conversion, evaluation and finalization.
    • Include shared JANGH packing, Metal kernels, SwitchGLU integration and the runtime installation hook.
    • Add the jangh dependency extra and document module entry points, required producer inputs and runtime integration boundaries.
    • Use the packaged GLM reference import in the evaluation path.
    • Close JSON and text handles deterministically in JANGH verification, evaluation and scale-report utilities.

    Install with pip install "jang[jangh]==2.5.49" on supported Apple Silicon systems. Pipeline commands are invoked with python -m jang_tools.jangh.<family>.<module> --help.

    Wheel and source distribution validation, installed-package kernel/module checks and installation-hook checks passed. Package availability does not independently qualify a converted model or guarantee compatibility with every serving runtime; this release makes no new end-to-end speed claim.

  5. v2.5.48JANG 2.5.482026-09-24 · 2026-09-24 19:57 UTC
    查看更新说明

    JANG 2.5.48 adds MiMo-V2.6 runtime and calibrated conversion support, alongside fixes for bundle metadata and quantization validation.

    • MiMo-V2.6 text, image, video, and audio-input runtime modules, per-rank FP8 decoding, and native MXFP4 handling.
    • Mixed-precision allocation, held-out KL evaluation, calibration, and quantization-method provenance.
    • Metadata repair for string-form source identifiers and Inkling capability registration.
    • Exact power-of-two activation-quantization scales across Metal versions, safer converter error handling, and closed JSON file handles.

    Install from PyPI:

    python -m pip install --upgrade "jang[mlx]==2.5.48"
    

    Multimodal applications also need their matching runtime integration. Model quality depends on the bundle and quantization; this release does not establish source-model parity, audio generation, native MTP, or a 1M-token validation.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译


    App Support: MLX Studio has full native JANG support. LM Studio, Ollama, and Inferencer do not support JANG yet — ask your favorite app's creators to add support, or use pip install "jang[mlx]".


    Highlights

    • 397B on 128 GB Mac — JANG_1L: 112 GB, 36 tok/s, 86.5% MMLU with reasoning
    • DeepSeek-V4-Flash runtime — first MLX runtime for DSV4's hybrid SWA + CSA + HSA attention (sliding-window + compressor-pool + hash-sparse) with mHC residuals and 1M-context pool quant cache
    • JangPress for routed-MoE — load 167 GB Kimi-K2.6 on a 128 GB Mac via mmap + madvise cold-tier eviction (see docs/JANGPRESS.md)
    • Nemotron-Cascade-2 in 10 GB — IMO Gold Medal reasoning model at 130 tok/s on 16 GB MacBooks
    • MiniMax: only JANG works — MLX scores 25% (random), JANG scores 74%
    • Nemotron-3-Super-120B in 43 GB — first working Nemotron-H quantization for Apple Silicon
    • Mistral Small 4 (119B) — first on Apple Silicon — 82 tok/s, 5x faster prefill than MLX Community 4-bit, code/math/reasoning/VLM all working
    • bfloat16 auto-detection — fixes float16 overflow on 512-expert models
    • Reasoning mode — <think>...</think> / [THINK]...[/THINK] with configurable thinking on/off

    Results (200-question MMLU)

    Qwen3.5-397B-A17B — JANG runs where MLX can't

    ModelNo-ThinkReasoningSizeSpeed
    JANG_1L81.0%86.5%112 GB36 tok/s
    JANG_2L79.5%92.0%187 GB36 tok/s
    MLX 4-bit81.5%94.0%209 GB~36 tok/s
    MLX 2/3-bitNaNNaN——

    MLX cannot quantize 397B below 4-bit (float16 overflow). JANG solves this with bfloat16.

    Nemotron-Cascade-2-30B — IMO Gold Medal in 10 GB

    ModelNo-ThinkReasoningSizeSpeed
    JANG_2L59.0%88.0%10.3 GB130 tok/s
    JANG_4M69.0%93.0%17 GB55 tok/s
    MLX 4-bit69.0%92.5%16.6 GB—
    MLX 6-bit71.0%94.5%23.9 GB—

    JANG_4M beats MLX 4-bit (93.0% vs 92.5%) at the same size.

    Mistral Small 4 (119B-A6B) — First on Apple Silicon, fastest inference

    ModelSizeGen tok/sPrefill tok/sRAMFeatures
    JANG_2L30 GB8221640 GBCode, math, [THINK] reasoning, VLM
    JANG_4M57 GB8020268 GBCode, math, [THINK] reasoning, VLM
    JANG_6M84 GB7416095 GBCode, math, [THINK] reasoning, VLM
    MLX Community 4-bit63 GB844368 GBVLM

    94.0% MMLU at 2-bit (JANG_2L) — five subjects at 100%. 5x faster prefill than MLX Community. JANG_2L fits on 48 GB Macs at half the size.

    119B total parameters, 6B active per token. MLA attention + 128 MoE experts + Pixtral vision. First model to support MLA + MoE quantization on Apple Silicon.

    JANG_2L MMLU Results (200 Questions, Reasoning Mode)
    SubjectScore
    Abstract Algebra13/20 (65%)
    Anatomy20/20 (100%)
    Astronomy20/20 (100%)
    College CS20/20 (100%)
    College Physics19/20 (95%)
    HS Biology19/20 (95%)
    HS Chemistry20/20 (100%)
    HS Mathematics18/20 (90%)
    Logical Fallacies19/20 (95%)
    World Religions20/20 (100%)
    Total188/200 (94.0%)

    Nemotron-3-Super-120B — Only JANG can go below 4-bit

    ModelNo-ThinkReasoningSizeSpeed
    JANG_2L75.0%86.0%43 GB52 tok/s
    JANG_4M72.5%93.0%63 GB55 tok/s
    MLX 4-bit71.0%93.5%63 GB60 tok/s
    MLX 3-bitCrashes———

    MLX mlx_lm.convert crashes on Nemotron's mtp.* weights. Only JANG can produce sub-4-bit.

    MiniMax-M2.5 — JANG is the ONLY working option

    ModelMMLUSize
    JANG_2L74%63 GB
    JANG_3M74.5%82 GB
    MLX 4-bit26.5%120 GB
    MLX 3-bit24.5%93 GB
    MLX 2-bit25%—

    MLX is broken on MiniMax at ALL bit levels (~25% = random). MiniMax has 256 experts — MLX compresses attention to the same bits as expert MLP, destroying coherence.

    Qwen3.5 MoE (122B, 35B)

    ModelJANGMLX 4-bitJANG SizeMLX Size
    122B JANG_4K86%85%69 GB64 GB
    122B JANG_2S79%56.5% (2-bit)38 GB36 GB
    35B JANG_4K77.5%77.0%16.7 GB18 GB
    35B JANG_2S65.5%~20% (2-bit)12 GB10 GB

    The Full Picture: JANG vs MLX Across All Models

    ModelJANG BestMLX BestJANG SizeMLX SizeMLX Broken?
    Qwen3.5-397B92.0%94.0%187 GB209 GBNaN below 4-bit
    Qwen3.5-397B (128 GB Mac)86.5%—112 GBCan't fit—
    Nemotron-Cascade-293.0%92.5%17 GB16.6 GB—
    Nemotron-Cascade-2 (16 GB Mac)88.0%—10.3 GBCan't fit—
    Nemotron-Super-120B93.0%93.5%63 GB63 GBCrashes below 4-bit
    Nemotron-Super-120B (64 GB Mac)86.0%—43 GBCan't fit—
    MiniMax-M2.574.5%26.5%82 GB120 GBBroken at ALL bits
    Qwen3.5-122B86%85%69 GB64 GB56.5% at 2-bit
    Qwen3.5-35B77.5%77.0%16.7 GB18 GB~20% at 2-bit

    JANG wins at every size point. At equivalent sizes, JANG matches or beats MLX. At smaller sizes, JANG runs where MLX literally cannot (NaN, crashes, or random output).

    Why MLX Fails on MoE Models

    On MoE models, attention is only 1-5% of total parameters but controls 100% of coherence. MLX compresses everything equally:

    MLX 4-bit: attention at 4-bit, experts at 4-bit → works but wastes bits on experts
    MLX 2-bit: attention at 2-bit, experts at 2-bit → attention breaks → model breaks
    
    JANG 2-bit: attention at 8-bit, experts at 2-bit → attention preserved → model works
    

    The more experts a model has, the worse MLX performs at low bits:

    • 128 experts (Cascade-2): MLX 4-bit still works, JANG slightly better
    • 256 experts (122B, MiniMax): MLX 2-bit breaks badly, JANG dominates
    • 512 experts (397B, Super-120B): MLX NaN/crash below 4-bit, only JANG works

    DeepSeek-V4-Flash runtime — Hybrid SWA + CSA + HSA attention

    DSV4-Flash is the first DeepSeek-class model whose attention is not plain MLA. JANG ships the only Apple-Silicon runtime that handles all three layer types correctly:

    Layer typeDescriptionJANG path
    SWA (Sliding-Window Attention)local windowed attention; cheap fast layersjang_tools.dsv4.mlx_model.DSV4SlidingWindow
    CSA (Compressor / Compressed-State Attention)per-layer compressor pool + windowed buffer; carries pooled-K/V across the whole contextDeepseekV4Cache + accumulate_windows + update_pool
    HSA (Hash-Sparse Attention via Indexer)indexer chooses top-K hash buckets per-token; sparse attention over the global compressed poolIndexer module + DSV4LayerCache indexer state
    mHC residualsmulti-Head-Compressed residual stream stabilises 43-layer 284B modelresidual-axis fix in mlx_model.py
    Pool quant cachequantized streaming KV pool with proportional trim() (mirrors llama.cpp dsv4_clear_rows)DeepseekV4Cache.trim(n)

    End-to-end verified: 1M-context pool accumulation, multi-turn /v1/chat/completions with prefix-cache reuse, dual-mode reasoning, 20.5 tok/s decode on M3 Ultra @ JANGTQ2 (79.5 GB), 24.5 tok/s on Swift.

    JangPress — fit routed-MoE bundles bigger than RAM

    JangPress is the load-time memory policy in osaurus-ai/vmlx-swift-lm that combines mmap-backed safetensors, per-token router-aware MADV_DONTNEED over canonical routed-expert pages, and an optional prestack overlay. It lets routed-MoE bundles bigger than RAM serve from a single Mac:

    BundleSizeHost RAMPost-load RSS
    Kimi-K2.6-Small-JANGTQ153 GB128 GB~0.7 GB
    Kimi-K2.6-Med-JANGTQ167 GB128 GB~1 GB
    DSV4-Flash JANG_2L96.6 GB128 GB+varies

    Python serve + bench scripts: scripts/jangpress/. Full guide: docs/JANGPRESS.md.

    Install

    pip install "jang[mlx]>=2.5.18"
    

    For Vision-Language models:

    pip install "jang[vlm]>=2.5.18"
    

    Quick Start

    Convert any model

    # K-quant 4-bit (same size as MLX, smarter allocation)
    jang convert Qwen/Qwen3.5-35B-A3B -p 4
    
    # 2-bit for extreme compression
    jang convert Qwen/Qwen3.5-122B-A10B -p 2
    
    # Specific profile
    jang convert model -p JANG_2L
    

    Run inference

    from jang_tools.loader import load_jang_model
    from mlx_lm import generate
    
    model, tokenizer = load_jang_model("JANGQ-AI/Qwen3.5-397B-A17B-JANG_1L")
    
    # With reasoning (recommended for hard questions)
    messages = [{"role": "user", "content": "Prove that sqrt(2) is irrational."}]
    prompt = tokenizer.apply_chat_template(messages, tokenize=False,
        add_generation_prompt=True, enable_thinking=True)
    result = generate(model, tokenizer, prompt=prompt, max_tokens=2048)
    
    # Without reasoning (faster)
    prompt = tokenizer.apply_chat_template(messages, tokenize=False,
        add_generation_prompt=True, enable_thinking=False)
    result = generate(model, tokenizer, prompt=prompt, max_tokens=100)
    

    VLM (Vision-Language) inference

    from jang_tools.loader import load_jang_vlm_model
    from mlx_vlm import generate as vlm_generate
    
    model, processor = load_jang_vlm_model("JANGQ-AI/Qwen3.5-397B-A17B-JANG_2L")
    messages = [{"role": "user", "content": [
        {"type": "image"},
        {"type": "text", "text": "Describe this image."},
    ]}]
    prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
    result = vlm_generate(model, processor, prompt=prompt, image=["photo.jpg"], max_tokens=200)
    

    MMLU Benchmark

    python -m jang_tools.benchmark /path/to/model --max-thinking 1024
    

    Smart two-pass: no-thinking first, then reasoning retry on wrong answers. Checkpointing, forced answers, full output logging.

    Pre-quantized Models

    ModelProfileMMLUSizeFits
    Qwen3.5-397B JANG_1L2.1-bit86.5%*112 GB128 GB Mac
    Qwen3.5-397B JANG_2L3.7-bit92.0%*187 GB256 GB Mac
    Nemotron-Cascade-2 JANG_2L2.3-bit88.0%*10 GB16 GB Mac
    Nemotron-Cascade-2 JANG_4M4.1-bit93.0%*17 GB24 GB Mac
    Nemotron-Super-120B JANG_2L2.8-bit86.0%*43 GB64 GB Mac
    Nemotron-Super-120B JANG_4M4.1-bit93.0%*63 GB64 GB Mac
    Qwen3.5-122B JANG_4K4.0-bit86%69 GB192 GB Mac
    Qwen3.5-122B JANG_2S2.1-bit79%38 GB64 GB Mac
    Qwen3.5-35B JANG_4K4.0-bit77.5%17 GB36 GB Mac
    MiniMax-M2.5 JANG_2L2.3-bit74%63 GB128 GB Mac
    Qwen3.5-27B JANG_4S4.1-bit84.5%16 GB24 GB Mac

    * with reasoning mode

    Full collection

    Profiles

    ProfileTypeBitsBest for
    JANG_4KK-quant4.0Same size as MLX 4-bit, smarter
    JANG_4MProfile4.08-bit attention, 4-bit experts
    JANG_4SProfile4.0Dense models (27B)
    JANG_3KK-quant3.0Same size as MLX 3-bit, smarter
    JANG_2LProfile~2.3Quality 2-bit, best for MoE
    JANG_1LProfile~2.1Maximum quality 2-bit

    App Developers: Add JANG Support

    JANG models are standard MLX safetensors. If your app loads MLX quantized models, adding JANG is minimal work.

    Quickest Integration (5 lines)

    # Detect JANG model
    from pathlib import Path
    is_jang = (Path(model_path) / "jang_config.json").exists()
    
    # Load with jang-tools
    if is_jang:
        from jang_tools.loader import load_jang_model
        model, tokenizer = load_jang_model(model_path)
        # model is a standard mlx_lm model — use like any MLX model
    

    What's Different from Standard MLX

    1. Mixed bit widths — different tensors have different bits (attention at 8-bit, experts at 2-bit). Each QuantizedLinear needs its bits and group_size set from tensor shapes.
    2. bfloat16 for large models — 512+ expert models need model.set_dtype(mx.bfloat16) to prevent float16 overflow.
    3. Nemotron-H weight renaming — switch_mlp.up_proj→fc1, down_proj→fc2, gate dequantization.

    Full Integration Guide

    See INTEGRATION.md for complete step-by-step with code for:

    • Loading without jang-tools dependency
    • Per-tensor bit inference from shapes
    • bfloat16 auto-detection
    • Nemotron-H special handling
    • Chat template with thinking on/off
    • VLM support
    • Edge cases and gotchas

    Supported Architectures

    • Qwen3.5 (hybrid SSM + MoE + VLM) — 4B, 9B, 27B, 35B, 122B, 397B
    • Nemotron-H (Mamba-2 + Latent MoE + Attention) — Cascade-2 30B, Super-120B
    • MiniMax-M2.5 (256-expert MoE, FP8 source)
    • DeepSeek-V2/V3 (MLA + MoE)
    • Mixtral / Qwen2-MoE (standard MoE)
    • Dense Transformers (Llama, Mistral, Gemma, Phi)
    • Vision-Language (Qwen3.5-VL, Pixtral)
    • Mamba / Hybrid SSM (Jamba, Nemotron-H)
    • FP8 source models (auto-dequantization)
    • Mistral Small 4 (119B MoE + MLA + Pixtral VL) — 94% MMLU, 82 tok/s, 30-84 GB

    Changelog

    v2.1.5 (2026-03-21)

    • Nemotron-H loader: fc1/fc2 rename, gate weight dequantization, mtp.* key filtering
    • bfloat16 auto-detection for 512+ expert models (prevents float16 overflow)
    • MLP asymmetry floors: gate_proj=4-bit, down_proj=3-bit for 512+ expert models
    • Benchmark script: smart two-pass MMLU with reasoning, checkpointing, forced answers
    • eos_token_id auto-fix for Qwen3.5 (248044→248046)
    • Auto-copy all .py files for trust_remote_code models
    • Nemotron-3-Super-120B: 86% MMLU at 43 GB
    • Qwen3.5-397B: 92% MMLU at 187 GB, 86.5% at 112 GB

    v2.1.4 (2026-03-19)

    • MLP asymmetry fix for 512-expert models
    • eos_token_id auto-fix for Qwen3.5
    • Auto-copy custom .py files

    v2.1.3 (2026-03-18)

    • Per-tensor group_size (router=64, experts=128 for 150+ expert models)
    • Precision floor rules for shared expert
    • VLM support for all Qwen3.5 models

    How It Works

    JANG redistributes bits based on tensor sensitivity — same total size, smarter allocation:

    CRITICAL  (attention, MoE routers, MLA latent)  →  6-8 bit  →  Controls coherence
    IMPORTANT (embeddings, linear attention)         →  4-6 bit  →  Moderate sensitivity
    COMPRESS  (MLP, MoE experts)                     →  2-4 bit  →  95%+ of parameters
    

    On MoE models, attention is only 1-5% of parameters. Boosting it to 8-bit costs ~2% overhead but dramatically improves quality. MLX compresses everything equally — that's why it breaks on MoE models at low bits.

    Technical Features

    • bfloat16 compute: Auto-detected for 512+ expert models. Prevents float16 overflow at shared expert down_proj.
    • MLP asymmetry: gate_proj gets 4-bit floor (SiLU amplifier), down_proj gets 3-bit floor for 512+ expert models.
    • FP8 dequantization: Handles FP8 source models (MiniMax, Nemotron) automatically.
    • Latent MoE: Supports Nemotron-H's fc1/fc2_latent_proj compression.
    • v2 format: MLX-native safetensors, instant mmap loading, no repack needed.

    Requirements

    • Python: 3.11+
    • Conversion: any platform (numpy + safetensors)
    • Inference: Apple Silicon Mac (M1/M2/M3/M4) with MLX
    • Dependencies: safetensors>=0.4, numpy>=1.24, tqdm>=4.60, huggingface_hub>=0.20
    • Optional: mlx>=0.22, mlx-lm>=0.20 (inference), mlx-vlm>=0.1 (VLM)

    Links


    한국어

    JANG은 Apple Silicon을 위한 혼합정밀도 양자화 포맷입니다. MLX를 위한 GGUF.

    모델MMLU크기최소 Mac
    Qwen3.5-397B JANG_1L86.5%*112 GB128 GB
    Nemotron-Cascade-2 JANG_2L88.0%*10 GB16 GB
    Nemotron-Super-120B JANG_2L86.0%*43 GB64 GB
    MiniMax-M2.5 JANG_2L74%63 GB128 GB

    * 추론 모드 사용

    pip install "jang[mlx]>=2.1.5"
    

    GitHub · HuggingFace · MLX Studio · PyPI