Skip to content

Port every supported model onto the Transformers 5.23 ABI; never patch Transformers - #4620

Merged
Qubitium merged 910 commits into
mainfrom
transformers5-local-models
Nov 22, 2026
Merged

Qubitium merged 910 commits into
mainfrom
transformers5-local-models

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

GPT-QModel now quantizes, runs inference and trains only on the Transformers 5.23 ABI, using package-owned model code for every supported model. It requires transformers>=5.23.0,<5.24, Python 3.11+, tokenicer>=0.0.21 and defuser>=0.0.32.

  • Every supported model is ported. All MODEL_MAP definitions (208 model types) load through a definition-owned LocalModelLoader. That includes models Transformers implements natively: GPT-QModel carries its own copy, so a Transformers upgrade cannot change its math, module names or checkpoint keys.
    • 140 Transformers 5.23 families are vendored verbatim into gptqmodel/models/ports/native/<family> (scripts/vendor_transformers_ports.py). A package-local registry (ports/native/auto: NativeConfig, Native<Task>, NativeProcessor, NativeTokenizer) resolves model_type to vendored classes only.
    • Non-native models (ChatGLM, MiniCPM-o, InternVL-Chat, Kimi K3, SenseNova-Loop, DeepSeek V4.1, …) have package-owned ports built from their original sources.
  • Framework infrastructure only. Nothing in gptqmodel/ imports transformers.models.*, including top-level re-exports of model-family classes. Ports use only Transformers' framework layer: PreTrainedModel, configs, cache_utils, masking_utils, the attention registry, RoPE utilities, GradientCheckpointingLayer, GenerationMixin, outputs, initialization and processing/tokenization base classes.
  • No backward compatibility. All Transformers 4.x shims are deleted: the import-time monkeypatches, legacy config rewriting, legacy generation/cache wrappers and the remote-code helpers.
    • Ports use 5.23 conventions: no cache_position, no tuple or legacy caches, no rope_scaling reads, no return_dict tuple plumbing, and real Cache subclasses.
    • Released configs with old field names are converted once, at parse time.
  • GPT-QModel never patches Transformers or the HF ecosystem. It does not monkeypatch Transformers, register with AutoConfig/AutoModel or the quantizer tables, or patch optimum, OpenVINO, huggingface_hub (ModelScope patch_hub), safetensors, torch.nn.init, Accelerate, Defuser or Triton. Weight-init suppression uses Transformers' public no_init_weights(). Checkpoint Python for an unsupported model still requires both trust_remote_code=True and GPTQ_BYPASS_SAFETY_CHECKS=1, and it runs on unmodified Transformers 5.23.
  • Enforced and documented.
    • tests/test_model_port_policy.py checks every definition, every port and the whole package. All of its pending lists are empty.
    • tests/test_transformers_unpatched.py checks that importing and using GPT-QModel leaves Transformers unchanged.
    • The policy is in AGENTS.md, docs/transformers5-model-ports.md and the new .agents/skills/gptqmodel-model-porting skill.

Notable fixes found while porting

  • Transformers treats any class outside transformers.* as custom code, which skips checkpoint conversion mappings. Vendored classes now derive from NativePreTrainedModel, so Transformers-saved checkpoints (e.g. NemotronH, MoE expert fusion) load correctly.
  • Defuser treats vendored classes exactly as it treats native ones, without patching Transformers. replace_fused_blocks, which swapped the global conversion mapping and loaded wrong MoE weights, is no longer used.
  • Restored AWQ scale search for about 60 definitions, each checked with fold-neutrality tests. Only provably non-neutral groups are dropped.
  • Correctness bugs fixed in ports:
    • Bailing YaRN: partial_rotary_factor was applied twice.
    • Original Yi: both decoder norms were left at their initial values.
    • StableLM Epoch: q/k/v biases were dropped.
    • Partially loaded modules were re-initialized (MobileLLM, Nanbeige, InternS1, Brumby, Kimi K3).
    • MiniCPM and Ouro lost the causal mask.
    • XING4 router ignored grouped top-k.
    • MiniCPM-o RoPE theta was wrong.
  • Package bugs fixed:
    • empty buffers were dropped on save;
    • the AWQ all-experts replay passed a bad signature;
    • recovery fill untied shared meta parameters;
    • VLM calibration consumed literal column names;
    • LazyTurtle ignored nested conversion rules;
    • NativeTokenizer ignored the declared tokenizer class.
  • Tokenicer 0.0.21 (ModelCloud/Tokenicer#68) adds register_transformers_equivalent. GPT-QModel registers its vendored tokenizer classes with it, so Tokenicer's normalization still applies and token IDs match Transformers exactly.

Size

Most of the diff is the vendored Transformers 5.23 sources under gptqmodel/models/ports/native/. They are kept byte-reproducible (scripts/vendor_transformers_ports.py) and excluded from ruff. Per-port documentation and test-only inventories were removed from the package; tests use SHA-256 digests or small fixtures under tests/fixtures/ports/.

Validation (CPU: Python 3.14, Torch 2.15.0, Transformers 5.23.0, Tokenicer 0.0.21)

  • tests/test_native_port_parity.py: for every vendored family, built from Transformers' own model-tester configs and inputs, state_dict keys and shapes match, outputs are bit-identical, and a Transformers-saved checkpoint loads into the vendored class with identical outputs. Inkling (needs scipy) and RoBERTa (vendored only as a dependency) skip.

  • tests/test_native_definition_loading_{0..3}.py: each wired definition loads a Transformers-saved checkpoint through its loader. Only vendored classes are instantiated, and logits are bit-equal to Transformers.

  • A full CPU sweep of tests/*.py, tests/module_tree/*.py and tests/kernels/*.py passes, except tests that need hardware or real checkpoints unavailable on the CPU host:

    • CUDA, XPU, MLX or bitblas;
    • /monster checkpoints;
    • real-model runs longer than 600 s;
    • one timing threshold that is sensitive to host load;
    • tests/kernels/test_intel_cpu_xpu.py, whose CPU cases take about 5 minutes each on this host.

    Hardware- and optional-package-dependent tests now skip precisely instead of failing at collection.

  • Not verified here: GPU kernels, real-checkpoint quantization and evaluation runs, and Tenstorrent hardware.

Breaking changes

  • Transformers < 5.23 and Python 3.10 are no longer supported.
  • Checkpoint Python written for Transformers 4 is no longer shimmed; such checkpoints fail unless they work on Transformers 5.23.
  • The Transformers/optimum/OpenVINO load bridges are removed. Plain transformers.from_pretrained of GPT-QModel checkpoints no longer gets GPT-QModel-only features: per-layer dynamic configs, per-expert MoE tensors, refusal of GPT-QModel-only formats, device-map backfill, or the save_pretrained layout guard. Use GPTQModel.load. Transformers' own GPTQ path still uses GPT-QModel kernels through its documented hooks.
  • GGUF: loading without the gguf package (now in the gguf extra), the direct-to-Torch dense GGUF import (KernelConfig.gguf_torch_dequant_loader) and Prism Q1_0_g128 dense import are dropped. GPT-QModel's native quantized GGUF loader is unchanged.
  • Accelerate's clear_device_cache is no longer replaced process-wide: GPT-QModel's offload hooks skip the per-forward cache flush on their own. Defuser 0.0.32 (ModelCloud/Defuser#75) scopes its cache flush to the devices a conversion uses ([MEM] Fused-expert MoE load on cuda:1 (inference load and quantize load with device=("cuda:1",)) creates a 386 MiB CUDA context on cuda:0: defuser's clear_memory() calls torch.cuda.synchronize() on the current device (#4863 class, MoE path) #5105), so the Defuser clear_memory swap is gone too.
  • Model ports for MobileLLM, Instella, LocateAnything and MiniCPM-o's TTS components are clean-room Apache-2.0 reimplementations written from behavioral specifications, verified against golden fixtures.

🤖 Generated with Claude Code

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Devin Review

🟢 Devin Review found nothing to fix · View findings

@Qubitium
Qubitium marked this pull request as draft November 17, 2026 03:08
@devin-ai-integration devin-ai-integration Bot changed the title Define local model loaders and require the security bypass for checkpoint Python Add Transformers 5 local loading policy and InternLM port Nov 17, 2026
@devin-ai-integration devin-ai-integration Bot changed the title Add Transformers 5 local loading policy and InternLM port Add Transformers 5 model ports and secure loading Nov 17, 2026
@Qubitium
Qubitium marked this pull request as ready for review November 17, 2026 09:33
@devin-ai-integration devin-ai-integration Bot changed the title Add Transformers 5 model ports and secure loading Use local Transformers 5 models and gate checkpoint Python behind the security bypass Nov 17, 2026
@Qubitium

Copy link
Copy Markdown
Collaborator Author

Review: #4620 — local Transformers 5 models + checkpoint-Python gating

Reviewed at head fecb3042 (merge-base 8587f0bc, 456 files / ~96k lines). The shared policy layer (load_model_config, resolve_trust_remote_code, LocalModelLoader, require_remote_code_permission) and its call sites in auto.py / loader.py / writer.py / model_dequant.py / base.py / vllm.py / sglang.py / kimi_k3*.py were reviewed in full. Model ports were sample-reviewed: DeepSeek V2/V3/V4, Kimi K2/K2.5/K3, K2-Horizon, and every port that ships a tokenizer or processor. Ports not listed were not reviewed line by line.

Some findings below were reproduced with tiny CPU models or with real Hub tokenizer_config.json/tiktoken.model files, using Transformers 5.23.0, Tokenicer 0.0.17 and Torch 2.15.0+cpu. They are marked (repro). The others come from reading the code.

Verdict: request changes. The security direction is right: requiring both trust_remote_code=True and GPTQ_BYPASS_SAFETY_CHECKS=1, giving definitions ownership of their classes, and dropping the global DeepSeek-VL2 LlamaAttention monkeypatch are all clear improvements. But the tokenizer path has regressions that break, or silently corrupt calibration for, several of the families this PR ports.


🔴 Blocking

1. ChatGLM, Baichuan, InternLM, InternLM2 and InternVL-Chat can no longer load their tokenizer at all (repro)

  • Where: gptqmodel/utils/hf.py:2816-2820. The definitions chatglm.py, baichuan.py, internlm.py, internlm2.py and internvl_chat.py declare a LocalModelLoader without a tokenizer_class.
  • Cause: for any definition with a local loader, load_hf_tokenizer forces trust_remote_code=False. The real checkpoints only ship Python tokenizers, and none of those classes exists in Transformers 5.23:
    • THUDM/chatglm3-6b → ChatGLMTokenizer
    • baichuan-inc/Baichuan2-7B-Chat → BaichuanTokenizer
    • internlm/internlm-chat-7b → InternLMTokenizer
    • internlm/internlm2_5-7b-chat and OpenGVLab/InternVL2_5-8B → InternLM2Tokenizer
    • All except chatglm3 also ship only tokenizer.model, with no tokenizer.json.
  • Failure: GPTQModel.load(...) fails at loader.py:2046 with ValueError: Tokenicer: Checkpoint tokenizer class 'BaichuanTokenizer' is not available natively…. The same happens for InternLM2Tokenizer. Setting trust + bypass does not help.
  • Why the tests miss it: tests/test_local_tokenizer_loading.py and the port tests rewrite the fixture tokenizer to TokenizersBackend or WordLevel, so the real checkpoint metadata is never tested.
  • Fix: either ship package-owned tokenizer ports and set tokenizer_class, or keep the trust+bypass path for tokenizers when the loader declares no tokenizer_class. Add a regression test that uses each family's real tokenizer_config.json (auto_map plus tokenizer.model only).

2. Kimi-Linear (non-K3) silently tokenizes differently from training (repro)

  • Where: gptqmodel/models/ports/kimi_k3/tokenization_kimi.py:428-432 (KimiTokenizerFactory).
  • Cause: MODEL_MAP["kimi_linear"] is KimiLinearQModel. Its tokenizer factory runs even when auto.py:670 sends the model to KimiLinearNativeQModel. For a plain Kimi-Linear config the factory calls AutoTokenizer(..., trust_remote_code=False). Transformers then converts tiktoken.model into a TokenizersBackend with a different pre-tokenizer, instead of the checkpoint's TikTokenTokenizer.
  • Failure: tested with the real moonshotai/Kimi-Linear-48B-A3B-Instruct files.
    • "it's" encodes as ['Ġit', "'s"] instead of ["Ġit's"].
    • "I'm sure we'll see it's fine" gives 9 tokens instead of 6.
    • Every English contraction in calibration data is mis-tokenized, with no error or warning.
  • Fix: route the non-K3 branch to TikTokenTokenizer as well, as the K3 branch already does.

3. Building the Kimi-K2.5 processor wipes the shared tokenizer's special tokens (repro)

  • Where: gptqmodel/models/ports/kimi_k25/processing_kimi_k25.py:36.
  • Cause: tokenizer.add_special_tokens({"additional_special_tokens": [...]}) uses the default replace mode. base.py:1084 passes in the model's own tokenizer, so the model's tokenizer is changed too.
  • Failure:
    • extra_special_tokens goes from 12 entries to only the placeholder.
    • all_special_ids drops from 16 to 5.
    • decode(..., skip_special_tokens=True) now leaks <|im_user|>…<|media_begin|>…<|im_end|>.
    • The saved quantized tokenizer loses its special-token list.
  • Fix: pass replace_extra_special_tokens=False, or register the token on a copy of the tokenizer.

4. DeepSeek-V2: the caller's past_key_values is never updated (repro)

  • Where: gptqmodel/models/ports/deepseek_v2/modeling_deepseek_v2.py:99-112 and :197.
  • Cause: _fork_cache hands the decoder a shallow fork. Native Transformers updates the caller's DynamicCache in place.
  • Failure:
    • In a manual incremental loop (model(x[:, :4], past_key_values=cache) then model(x[:, 4:], past_key_values=cache)), logits diverge by 0.139, compared with 3e-8 on native.
    • cache.get_seq_length() stays at 0 after the first call.
    • generate() only works because it reads outputs.past_key_values. Other consumers that rely on in-place updates break silently.
    • Any non-DynamicCache cache now raises TypeError, for example cache_implementation="static" or offloaded caches.
  • Ask: the docs present this as intentional failure isolation, but it changes the public HF cache contract. Please keep in-place semantics, and handle rollback by recording each layer's length and cropping on exception.

5. Kimi-K3: loading the published checkpoint through the port fails on A_log (repro)

  • Where: gptqmodel/models/ports/kimi_k3/modeling_kimi_linear.py:475.
  • Cause: the parameter is [num_heads] (96 heads), but the checkpoint pads it to 128. The repo already handles this elsewhere: utils/kimi_k3.py:133 documents it and utils/kimi_k31.py:70-75 trims it. The port has no trim or narrowing step.
  • Failure: Transformers reports "Reinit due to size mismatch" and then raises. With ignore_mismatched_sizes=True, A_log would be silently random. Quantization goes through KimiK3Source, so this affects GPTQModel.load / eval of the source model.

🟠 Security / policy

6. Tokenizer trust is silently downgraded instead of rejected

  • Where: hf.py:2811, trust_remote_code = bool(trust_remote_code and safety_checks_bypassed()).
  • Problem: the model path raises RemoteCodeSecurityError when the bypass is missing. The tokenizer path quietly flips to False and lets Tokenicer or AutoTokenizer fall back to whatever native class it can build. That fallback is exactly how Update readme table's style #2 happens.
  • Suggestion: if the checkpoint's tokenizer requires checkpoint Python and the bypass is missing, raise with the same message as the model path. The PR body says the Tokenicer fallback hardening is still pending (Tokenicer#64), so this should be fixed before merge, not afterwards.

7. The remote-only layout guard is dead code, and its error message is misleading

  • bailing_hybrid is now mapped to BailingMoeQModel, which has a LocalModelLoader. So resolve_trust_remote_code returns before the _REMOTE_ONLY_LAYOUT_CONFIG_MARKERS check (hf.py:1064), and that check can never fire for its only entry.
  • _checkpoint_remote_layout_marker, _checkpoint_config_payload (hf.py:950) and _TRUST_REMOTE_CODE_REMOTE_LAYOUT_LOGGED no longer have any callers.
  • The new error text ("requires a GPT-QModel local model port") would be wrong for any future entry that has no port. Either remove the guard, or keep it with an accurate message.

8. Trust resolution now does uncached I/O on every call, even with trust_remote_code=False

  • Change: @lru_cache was removed from _detect_native_transformers_causallm_support, and resolve_trust_remote_code now always calls get_config_dict.

  • Cost: it is called several times per load, from:

    • the public entry point
    • inside load_model_config
    • from_pretrained / from_quantized
    • has_native_transformers_model_support
    • prepare_remote_model_init_compat

    On the remote path that adds up to roughly 10–15 config parses per GPTQModel.load. Each AutoConfig.from_pretrained against a Hub ID also does revision and metadata requests.

  • Behaviour change: previously trust_remote_code=False returned without any I/O. Now non-OSError errors (for example GGUF ValueErrors) are raised from the trust probe before the loader's own diagnostics run.

  • Suggestion: resolve once per (path, selection kwargs) and pass the selected config and decision down, or memoize on a hashable key.

  • Related: writer.py:2589, model_dequant.py:368 and GPTQModel.export (auto.py:1250) call resolve_trust_remote_code without selection kwargs. With a subfolder or revision, they probe a different config than the one they load.

9. The norm-tuning teacher bypasses the definition loader

  • Where: base.py:2762, AutoModelForCausalLM.from_pretrained(teacher, trust_remote_code=self.trust_remote_code).
  • Problem: for local-port families with no native class (InternLM, Baichuan, ChatGLM, Brumby, …), self.trust_remote_code resolves to False, so a teacher given as a path cannot load.
  • Fix: use type(self).loader.from_pretrained(...) when the loader is a LocalModelLoader.

10. "Native first" is not what happens for several types

  • Eight model_types that are native in Transformers 5.23 now go through LocalModelLoader: codegen, deepseek_v2, deepseek_v3, exaone4, kimi_k25, lfm3_vl, ernie4_5_vl_moe and bailing_hybrid.
  • Most are thin bridges that subclass the native classes, which is fine. DeepSeek-V2 (Revert Exllama v1/v2 changes due to regression #4) shows the risk when a bridge overrides behaviour.
  • Please correct the PR description and docs.
  • Dispatch is keyed only on the checkpoint's model_type and wins even over trust+bypass. Derivative checkpoints that reuse a ported model_type with different remote code (reward heads, updated upstream code) have no opt-out. Document this as an intentional limitation, or add an explicit escape hatch.

🟡 Packaging / deps

11. Test-only assets ship in every wheel

  • gptqmodel/models/ports/kimi_k25/qualification_assets/ contains tiktoken.model (2.8 MB), chat_template.jinja and tokenizer_config.json.
  • Only tests/test_kimi_k25_local_port.py uses them, but the new MANIFEST.in patterns (*.model *.jinja *.json) package them.
  • Move them under tests/fixtures. Also confirm that redistributing Moonshot's tokenizer is allowed under its license, and add the notice if so.

12. Dependency cleanup

  • tiktoken>=0.12.0 is now a hard dependency for every install, but it is only needed by the Kimi/InternS1 tokenizers. Consider an extra, or a lazy import with a clear error.
  • With requires-python>=3.11, the python_version < "3.11" lines in requirements.txt (lines 6, 9, 16) are dead and can be removed.

🔵 Minor

  • Kimi-K3, batched image generation (ports/kimi_k3/modeling_kimi_linear.py:1229-1231 with modeling_kimi_k3.py:1105-1150): left-padded batched image+text generate() raises at step 2 with attention_mask must include the cached prefix (mask (2,5) vs expected (2,8)). Image-merge lengthens the sequence, but decode steps reuse the original mask. Single-sample runs pass only because an all-ones mask is dropped.
  • Kimi-K2.5 attribution (ports/kimi_k25/tokenization_kimi.py:24): bytes_to_unicode is copied from Transformers (Apache-2.0, © HuggingFace) without attribution. The DeepSeek-V3 copy keeps it.
  • DeepSeek-V4 MTP helpers (definitions/deepseek_v4.py:31,49-123, pre-existing): they hard-code 3 MTP blocks, but the checkpoint schema pinned here has num_nextn_predict_layers=1, so validate_deepseek_v4_mtp_checkpoint_keys rejects it.
  • DeepSeek-V4 dead tensor entries (definitions/deepseek_v4.py:1430-1432): out_of_model_tensors lists layers.{0,1,2}.ffn.gate.bias, which do not exist in that checkpoint.
  • DeepSeek-V4 test tolerance (tests/test_deepseek_v4_local_port.py:194): it asserts rtol=0, atol=0 on fp32 MoE logits and fails [moe-sliding_attention] with a 7.45e-9 difference. That is rounding noise, so the tolerance should be tiny but non-zero.
  • DeepSeek-V3 layer index (definitions/deepseek_v3.py:33): out_of_model_tensors = model.layers.61 is only right for 61-layer checkpoints. It should come from the config (num_hidden_layers).
  • Kimi-K3 router bias dtype (low confidence): e_score_correction_bias is not in _keep_in_fp32_modules_strict, so it loads in bf16, while native DeepSeek-V3 keeps it in fp32. This matches upstream Kimi-Linear.

Process

  • CI: the AWQ CPU jobs (dense / moe / unit) fail on fecb3042 at import time with RuntimeError: operator torchvision::nms does not exist. The head commit only touches docs and fixtures, and the previous push passed, so this looks environmental. It still needs a green re-run before merge.
  • Scope: the PR checklist still has "combined review and qualification for remaining model ports, LFM3 leaf ownership and tokenizer trust fallback" unchecked, and the description says more models are still being added. At 456 files and about 96k lines, that is very hard to review safely. I'd strongly suggest landing the shared policy layer (security.py, hf.py, local.py, the call-site changes and Cleanup and call correct quantlinear directly #6–Update README.md #9 above) on its own. Then land the ports in family-sized PRs, each with a real-checkpoint tokenizer test (Add perplexity unit test to guard against regressions #1–Add CI Runner #3 all slipped through synthetic tokenizer fixtures).

What looks good

  • LocalModelLoader limits class paths to gptqmodel.*, never reads auto_map, and removes trust_remote_code/code_revision before construction.
  • normalize_hf_config_compat turns off remote-compat field rewrites for definition-owned configs.
  • The gguf_file and subfolder selection now reaches the trust preflight, a real fix.
  • build_shell_model now defaults trust_remote_code to False instead of True.
  • Gating before_model_load hooks and the vLLM/SGLang/Kimi reference loaders is consistent.
  • The DeepSeek-V3 bridge is minimal and keeps native numerics. Kimi-K2's alias canonicalization and the n_group == topk_group guard are correct, and K2-Horizon matches its pinned upstream source.

@devin-ai-integration
devin-ai-integration Bot marked this pull request as draft November 17, 2026 13:11
@Qubitium

Copy link
Copy Markdown
Collaborator Author

Follow-up review: #4620 at 5a0b429d

Re-checked against head 5a0b429d. That is 85 commits after my earlier review at fecb3042, including a merge of main. The PR is now 1087 files and about +365k lines.

What I covered this time:

  • re-verified every earlier finding against the new code;
  • reviewed the shared-layer changes since fecb3042 (hf.py, local.py, loader.py, writer.py, base.py, auto.py, MANIFEST.in, requirements.txt);
  • ran a pattern-based security sweep over all 69 port packages;
  • root-caused the CI failure.

The roughly 35 newly added ports (Ovis, original Qwen, Phi-4 MM, MiniCPM/-V, MiMo, OpenVLA, TeleChat2, Solar-Open2, Raon, Spark2.5, RW/Falcon, Nemotron-H, LLaDA2, …) were not reviewed line by line.

Verdict: still request changes. All five earlier correctness blockers are fixed, thanks. But CI is red because of a dependency this PR adds (below), and the scope has grown about 4× since the first review.

Earlier findings

# Finding Status
1 ChatGLM/Baichuan/InternLM/InternLM2/InternVL tokenizers unloadable ✅ Fixed. All five definitions now declare a package tokenizer_class
2 Kimi-Linear (non-K3) silently mis-tokenized ✅ Fixed, re-verified. Using the real Kimi-Linear-48B-A3B-Instruct files, KimiTokenizerFactory now gives KimiLinearTokenizer, which matches the upstream TikToken reference on every probe string, including the contraction cases that differed before
3 Kimi-K2.5 processor wiped shared special tokens ✅ Fixed with replace_extra_special_tokens=False
4 DeepSeek-V2 did not update the caller's cache ✅ Mostly fixed. _cache_transaction restores in-place semantics and rolls back on failure. Static and offloaded caches still raise TypeError, so please document that limit
5 Kimi-K3 padded A_log failed to load ✅ Fixed with _load_from_state_dict and ActiveKDAHeads
6 Tokenizer trust silently downgraded instead of rejected ⚠️ Unchanged (hf.py:2732). Much lower impact now that ported families own their tokenizers, but unported families with trust and no bypass still fall back to a native tokenizer with no error
7 Dead remote-only layout guard ✅ Fixed (removed)
8 Repeated, uncached trust probes; missing selection kwargs ⚠️ Partly fixed. trust_remote_code=False now returns with no I/O, and the writer forwards _config_load_kwargs. Still open: GPTQModel.export (auto.py:1256) and model_dequant.py:346 call resolve_trust_remote_code without subfolder/revision, and the trust=True path still re-parses config several times per load
9 Norm-tuning teacher bypassed the definition loader ✅ Fixed (base.py:2771-2780)
10 "Native first" wording ➖ PR description unchanged; it's a wording issue, not a blocker
11 Kimi-K2.5 test assets shipped in the wheel ✅ Fixed (qualification_assets/ removed)
12 Dead python_version < "3.11" markers ✅ Fixed. New dependencies were added, though; see below
minor K3 batched-image mask, K2.5 bytes_to_unicode attribution ✅ Fixed
minor V4 MTP helpers hard-code 3 blocks; V4 test rtol=0, atol=0; V3 out_of_model_tensors hard-codes model.layers.61; K3 router bias not fp32 ➖ Unchanged (all low severity)

🔴 New blocking issue: CI failure is caused by this PR's timm dependency

In my first comment I said the AWQ CPU failure "looks environmental". That was wrong.

All three AWQ CPU jobs fail on 5a0b429d during test collection:

E   RuntimeError: operator torchvision::nms does not exist
E   ModuleNotFoundError: Could not import module 'PreTrainedModel'.

Root cause, from the install log:

  • The workflow installs torch==2.15.0 from the CPU index.
  • It then runs pip install -r requirements.txt.
  • This PR adds timm>=1.0.22 to requirements.txt. That pulls an unpinned torchvision-0.29.2 from PyPI (Collecting torchvision (from timm>=1.0.22->-r requirements.txt)), which does not match torch 2.15.0+cpu.
  • Once a broken torchvision is importable, Transformers' lazy PreTrainedModel import fails.

origin/main has no timm, and the same workflow passes on other branches today.

Suggested fix: timm is imported only by five vision ports:

  • deepseek_vl_v2/siglip_vit.py
  • interns1/modeling_interns1.py
  • llava_qwen2/fastvit.py
  • minicpmv/modeling_minicpmv.py
  • openvla/modeling_prismatic.py

These modules are already loaded lazily through LocalModelLoader. Move timm to an optional extra (for example gptqmodel[vision]) and raise a clear error from those ports when it is missing. That also keeps torchvision out of every text-only install. sentencepiece was also added as a hard dependency. It is lighter, but only the Baichuan, TeleChat2 and InternS1 tokenizers need it.

If timm must stay required, the CI install step needs to pin torchvision from the same CPU index as torch. Every downstream user would hit the same mismatch, though, so the extra is the better fix.

Shared-layer changes since the last review

These look correct:

  • local_model_loader_for_config: a present model_type is authoritative, and architecture inference needs a unique, complete match. Only MiniCPMForCausalLM is declared, and conflicting or partial matches fail closed.
  • ensure_qwen_drive_registered is skipped when a package loader owns the type.
  • The return_tokenicer handoff, processor_load_kwargs forwarding, and the teacher path.

🟡 Security sweep of all ports: minor hygiene items only

I found no checkpoint-code execution, no AutoX.register, no global Transformers patching, no pickle, and no hard-coded trust_remote_code=True (apart from docstrings). Small items:

  • ports/deepseek_vl_v2/siglip_vit.py:634: torch.load(ckpt_path, map_location="cpu") without weights_only. It is safe by default on the required torch ≥2.15, but making weights_only=True explicit would match mimo_v2/modeling_mimo_v2.py:1776.
  • ports/locateanything/processing_locateanything.py:
    • :117 calls requests.get(image, stream=True) with no timeout, so a calibration sample URL can hang quantization.
    • :76 still contains an upstream developer path (/home/zhidingy/workspace/...).
  • ports/nemotron_h_puzzle/read_checkpoint_headers.py is a network-fetching maintainer script that ships in the runtime package. Consider moving it to scripts/.

Process

  • The checklist item "Complete combined review and qualification for remaining model ports" is still unchecked, and the PR has grown from 456 to 1087 files since the first review.
  • The earlier bugs were caught by reviewing samples, and every one came from synthetic fixtures. I'd again strongly suggest:
    1. landing the shared policy layer plus the already-qualified ports once CI is green;
    2. moving further ports to family-sized follow-ups, each with a real-checkpoint tokenizer/config test.

Comment thread tests/test_xverse_local_port.py Resolved
@Qubitium

Copy link
Copy Markdown
Collaborator Author

Rebased onto main (e19031750); the PR is conflict-free again (MERGEABLE). Merge commit 717e9de10. Conflicts resolved in favour of main where main is newer:

One pre-existing issue on this branch, unrelated to the merge (it is present at bf9c9b664 too): gptqmodel/models/local.py:89 calls Tokenicer.prepare_load_kwargs(...), which the tokenicer installed here does not provide (AttributeError: type object 'Tokenicer' has no attribute 'prepare_load_kwargs'). That breaks 31 cases in tests/test_qwen3_local_port.py and the other *_local_port suites on this host, and there is no tokenicer pin in pyproject.toml. Either pin the minimum tokenicer version that has prepare_load_kwargs, or guard the call for older releases.

@Qubitium

Copy link
Copy Markdown
Collaborator Author

Rebased/merged origin/main (d8758c4) into the branch as 42f8e9afa. One conflict, in docs/trust-remote-code-isolation.md: kept the branch's normalize_hf_config_compat paragraph and main's new ## Save section. No other conflicts; PR should be mergeable again.

Also re-verified the Tokenicer.prepare_load_kwargs concern raised earlier — it is not a branch bug. prepare_load_kwargs is a published API in tokenicer==0.0.19 (tokenicer/tokenicer.py:119, the version requirements.txt pins as >=0.0.19). The 31 failures in tests/test_qwen3_local_port.py came from the container's stale tokenicer 0.0.14. With 0.0.19 on PYTHONPATH:

tests/test_qwen3_local_port.py  ->  75 passed in 133.15s

@Qubitium

Copy link
Copy Markdown
Collaborator Author

Rebased/merged origin/main (5a13ec241) again as 5ea1bd672; the PR is mergeable.

Conflicts resolved this round:

Also fixed a red-on-main test the merge surfaced: tests/test_local_model_paths.py was failing 11 nodes on unmodified origin/main because #4894 made the loader read cls.require_load_tokenizer, and the nine DummyQModel doubles never declared it (AttributeError: type object 'DummyQModel' has no attribute 'require_load_tokenizer'). They now declare require_load_tokenizer = True, which is BaseQModel's default. File goes from 11 failed / 18 passed to 29 passed.

Post-merge verification (tokenicer 0.0.19 on PYTHONPATH, as requirements.txt pins >=0.0.19):

tests/test_qwen3_local_port.py tests/test_local_model_loading.py tests/test_local_model_paths.py
-> 154 passed

@Qubitium

Copy link
Copy Markdown
Collaborator Author

Conflict status: Hymba is a semantic conflict, not a textual one

git merge origin/main into this branch now conflicts in
gptqmodel/models/definitions/hymba.py and
tests/module_tree/fixtures/registered_module_plans.json. I tried all three
mechanical resolutions in a scratch worktree; none is correct, so I am not
pushing a merge for this PR. Details, so the port author can settle it:

What main now has (#4891, 7744cb898). A sequential tree:

"mamba": ("in_proj:0:nosrc", "out_proj:1", "conv1d:!", "x_proj.0:!", "dt_proj.0:!"),
"pre_moe_layernorm": ("pre_moe_layernorm:!",),
"moe:moe": {"experts": {"0": ("gate_proj:0", "up_proj:0", "down_proj:1")}},

with the router handled by the generic non-quantized-consumer scan
(_scale_consumers == ["moe.gate"]), plus tests/test_hymba_awq_4891.py
(7 nodes) asserting: the tree names only modules the layer owns, the gate/up
group folds into pre_moe_layernorm, the fold is output-preserving (<1e-5), and
moe.gate is a scale consumer.

What this branch has (Hymba port, f06bf6651). A different tree for the
port-owned modeling: moe.router:! instead of relying on the generic scan,
expert tags gate_proj:0:in=x / up_proj:0:in=x, and 9 extra dense leaves
(mamba.A_log, mamba.D, the three mixer layernorms,
pre_avg_layernorm1/2, self_attn.q_norm/k_norm), plus
awq_get_modules_for_scaling -> [] and
tests/module_tree/test_hymba_local_port.py, which requires every
checkpoint-owned weight to carry an explicit :!/:? tag.

Measured, both directions (scratch worktree, CPU):

resolution result
take main's hymba.py + fixtures test_hymba_awq_4891.py 7 passed, but test_hymba_local_port.py 11 failed (test_all_layout_weight_owners_survive_actual_defuser_conversion[options0..8], test_registry_aliases_moe_hooks_and_looper_consumers): the port's A_log/D/layernorms/router are undeclared, violating the port's own weight-ownership contract
take this branch's hymba.py + fixtures test_hymba_local_port.py 11 passed, test_registered_module_plans.py 423 passed, but test_hymba_awq_4891.py 3 failed (test_hymba_tree_declares_the_norm_the_layer_actually_owns, test_hymba_gate_up_group_reads_pre_moe_layernorm, test_hymba_awq_fold_is_output_preserving)
branch tree + drop the awq_get_modules_for_scaling -> [] opt-out test_hymba_awq_4891.py 2 failed: the 9 extra dense leaves are still "modules the layer does not own" for the remote-code replica, and the :in=x expert tags mean no pre_moe_layernorm fold group exists at all, so the gate/up group cannot be the one #4891 fixed

The last row is the real blocker: in=x wiring and a sequential
pre_moe_layernorm -> gate/up fold are two different fold-source models. That
needs a decision from whoever owns the port, not a merge resolution.

Suggested way forward (either is fine by me):

  1. Keep this branch's richer port tree, and re-derive
    tests/test_hymba_awq_4891.py for the port's names (router instead of
    gate, the in=x wiring, the extra dense leaves) in the same PR — the
    assertions that matter (fold is output-preserving, the experts are scaled by
    their own norm) can be kept verbatim.
  2. Drop the port's Hymba tree override and adopt main's sequential tree, then
    extend tests/module_tree/test_hymba_local_port.py's ownership contract to
    accept the router being reached through the generic consumer scan.

Until then this PR will keep showing CONFLICTING after every merge to main.
Everything else on the branch merged cleanly in the same attempt (the last
successful merges are b69059387 / e8741bb47).

@Qubitium

Copy link
Copy Markdown
Collaborator Author

Review of #4620 (head aec267eab, merge-base 468c201d6)

This is a static review of the PR head. I did not run the test suite. Because of the PR's size (1,320 files, about 252k added lines), I reviewed the core loader and trust changes line by line. For the ~75 vendored ports I did targeted sweeps for security, licensing and packaging, and regressions against main, and spot-checked the findings by hand. Most severe first.

The core design looks sound: LocalModelLoader with package-owned class paths, ignoring auto_map, and trust + GPTQ_BYPASS_SAFETY_CHECKS as two separate consents. No port registers anything with AutoConfig/AutoModel globally. Every torch.load I found uses weights_only=True. I found no pickle, yaml, eval or get_class_from_dynamic_module in the ports. The problems below are mostly side effects and distribution issues, not the trust model itself.


🔴 Blocking

1. AWQ scale search is silently turned off for ~66 model families.
66 definitions now override awq_get_modules_for_scaling to return [] unconditionally. Seven more do it conditionally, including Qwen3 (definitions/qwen3.py:29) and the Llama aliases (definitions/llama.py). Affected families include DeepSeek V2/V3/V4 and Kimi-K2, Qwen2-VL, Qwen2.5-VL (text), InternLM/InternLM2, ChatGLM, Phi-4, MiniMax-M2, ERNIE-4.5 MoE, MiniCPM/MiniCPM-V, Baichuan, EXAONE, Yi, and others.

  • For these models, METHOD.AWQ no longer does activation-aware scaling and becomes plain weight quantization. That is a large quality regression for users who select AWQ, and nothing warns them about it.
  • On main, Qwen3 got the generic groups (input_layernorm → q/k/v, v → o, post_attention_layernorm → gate/up, up → down). Those groups are still mathematically valid with per-head q_norm/k_norm after the projections, and the planner is width-aware (_is_gain_norm / _norm_width in base.py), so it does not pick q_norm/k_norm as the fold source for q/k/v.
  • Existing correctness tests were weakened rather than kept. For example, tests/test_awq_mla_scaling.py previously checked that MLA folds include q_a_proj/kv_a_proj_with_mqa and exclude q_b_proj/kv_b_proj. It now only asserts nodes == [].

Suggestion: keep main's AWQ behaviour wherever it was already exercised. Opt out only where a concrete fold is known to be unsafe. At minimum, log a warning that AWQ scale search is disabled for the definition. This also deserves a separate PR rather than being bundled with the loader migration.

2. Research-only / noncommercial / AGPL-lineage code ships in the default Apache-2.0 wheel.
find_packages() plus the new MANIFEST.in:29 rule ship every port. Nothing is gated behind an extra, and pyproject.toml:18 still declares license = "Apache-2.0" with no license-files.

  • ports/instella/LICENSE is "RESEARCH-ONLY RAIL-MS". It licenses the Source Code for academic/research purposes only (line 77). Its own PROVENANCE.md says distribution "requires the maintainer's license decision". Instella is not mentioned in the PR body or the README license section.
  • ports/minicpm_o: the NOTICE says the ChatTTS-derived GFSQ/DVAE code has only AGPL-3.0 / CC-BY-NC-4.0 historical licenses, and that "No permissive historical root grant was found". That code is in tts_26.py and on the 4.5 path in modeling_minicpmo.py.
  • Restrictions disclosed in the PR body: LocateAnything (NVIDIA noncommercial) and MobileLLM (FAIR noncommercial).
  • Other non-Apache terms on shipped code, not in the README license section:
    • dbrx_converted: Databricks Open Model License
    • kimi_k3: Kimi K3 License, with commercial-use conditions
    • hymba: NVIDIA Open Model License
    • qwen: Tongyi Qianwen license
    • lfm3_omni: LFM Open License, if it applies to the code

This needs a maintainer and legal decision before merge. Options: move restricted ports to an opt-in extra or a separate package, or at least correct the package license metadata (SPDX expression plus license-files) and the README.

3. MiniCPM-o TTS hands checkpoint-controlled files to a third-party loader without the trust/bypass gate.
ports/minicpm_o/modeling_minicpmo.py:240-258: init_tts() defaults model_dir to <checkpoint>/assets/token2wav and passes it to stepaudio2.Token2wav. MiniCPMODuplex.from_existing_model calls this automatically (around line 2533).

As far as I know, upstream StepAudio2 builds its flow model from a hyperpyyaml config, and !new:/!apply: tags there can call arbitrary callables. I couldn't verify this in my environment because minicpmo-utils isn't installed. If it holds, a malicious quantized MiniCPM-o upload gets code execution with no trust_remote_code and no bypass. The port already rejects 2.6 Vocos and the Mage-VL DCVC engine for this kind of reason. Please gate this path the same way, or require an explicit non-checkpoint model_dir.

4. Unlimited-OCR checkpoints quantized on main probably no longer load.
definitions/unlimited_ocr.py:49 moves the layer root from model.layers to model.language_model.layers. The port also renames sam_model, vision_model and projector. The explicit identity checkpoint_key_for_load (line 73) takes precedence in _checkpoint_key_converter, so the legacy mapping is applied only to the unquantized LazyTurtle source, not to quantized loads. Tests only cover save→reload within this PR. Please add a back-compat test for a checkpoint quantized with the old key layout, or document the break.


🟠 Should fix

5. sensenova_loop now hard-fails.

  • Where: definitions/sensenova_loop.py:39.
  • Why: it is the only definition that still has require_trust_remote_code = True, with no LocalModelLoader and no native type.
  • Effect: resolve_trust_remote_code now raises RemoteCodeSecurityError unless GPTQ_BYPASS_SAFETY_CHECKS=1 is set. On main it loaded with trust_remote_code=True.
  • Why CI misses it: tests/test_sensenova_loop_support.py:96 monkeypatches resolve_trust_remote_code.

6. Tokenizer trust is silently dropped instead of raising.
utils/hf.py:2805 sets trust_remote_code = bool(trust_remote_code and safety_checks_bypassed()). Everywhere else, the policy raises RemoteCodeSecurityError with an actionable message. Here, a native model whose checkpoint has a custom tokenizer in auto_map gets Transformers' generic "requires trust_remote_code" error, even though the caller passed trust_remote_code=True. Suggest calling require_remote_code_permission() for consistency.

7. DeepSeekV3QModel.out_of_model_tensors hardcodes model.layers.61.
definitions/deepseek_v3.py:33. This is correct only for 61-layer checkpoints with an MTP layer.

  • Moonlight (27 layers) and Kimi-K2 also map to this definition. For them it logs "No tensors matched" on every save.
  • For any deepseek_v3-type checkpoint with more than 61 decoder layers, it would merge the unquantized source tensors of a real decoder layer into the quantized state dict.
  • Fix: derive the prefix(es) from config.num_hidden_layers and num_nextn_predict_layers.

8. About 41 MB of test-only fixtures ship in the runtime wheel.

  • The 166 *.gz files under gptqmodel/models/ports/ are read only by tests/. With them, the gptqmodel package tree grows from ~11 MB to ~61 MB.
  • Several are real third-party tokenizer artifacts under model licenses: qwen/fixtures/qwen.tiktoken.gz, telechat2/fixtures/*tokenizer.model.gz, and the OpenVLA (Llama 2) tokenizer fixtures. That makes them a redistribution question as well as a size one.
  • Suggestion: move fixtures under tests/ or exclude them from the wheel. Also drop ports/lfm3/tests/ (no __init__.py; it imports the repo-root tests) and ports/ovis2_5/verify_released_assets.py.

9. Undeclared optional dependencies.

  • Six ports import torchvision at module level (zdtaichu5, phi4, locateanything, lfm3_omni, apertus, agnes) without declaring require_pkgs. It arrives only transitively through timm in [vision], so users get a raw ModuleNotFoundError.
  • decord, cv2, soundfile, librosa, scipy and qwen_vl_utils are used lazily but declared in no extra.

import gptqmodel itself stays clean on a core install. Only llava_qwen2 and qwen3 import ports eagerly, and neither pulls an optional dependency.


🟡 Minor / nits

  • Duplicate "token" in CONFIG_SELECTION_KWARGS (utils/hf.py:616 and :618).
  • Repeated config reads: removing lru_cache from _detect_native_transformers_causallm_support means one load can reach resolve_trust_remote_code 3–4 times: in the loader, inside load_model_config, in prepare_remote_model_init_compat, and in the writer. Each call does get_config_dict plus AutoConfig.from_pretrained. For hub IDs that aren't snapshotted locally, that is a round trip per call. Consider resolving once and passing the result down.
  • Qwen3 tokenizer: ports/qwen3/native.py forces the generic TokenizersBackend instead of Qwen2Tokenizer. Fine-tunes that ship only vocab.json/merges.txt without tokenizer.json will likely fail to build a tokenizer, and Qwen2Tokenizer defaults now come only from tokenizer_config.json. Worth a test or an explicit error message.
  • Unbounded media fetches: locateanything/processing_locateanything.py:114-116 (same pattern in zdtaichu5/vision_utils.py:118 and minicpm_o/utils.py:2230) uses requests.get(..., stream=True) and then response.content. So stream=True has no effect, there is no size cap, redirects are followed, and the read timeout applies per read. The input comes from caller messages, not the checkpoint, so this is low severity. The PR body's "bounded" holds for time only, not size. minicpm_o/utils.py also leaks its NamedTemporaryFile(delete=False) on decode failure.
  • Mage-VL codec settings from checkpoint: mage_vl/processing_mage_vl.py:127-151 takes cache_root and timeout_seconds from the checkpoint's preprocessor_config.json["codec"]. These drive mkdir/rmtree/rename (only with video_backend="codec"). Suggest accepting only geometry keys from the checkpoint.
  • kimi_k25/native.py:53: AutoModel.from_config(config.text_config) should pass trust_remote_code=False explicitly, as Mage-VL does.
  • Python 3.10 leftovers: dead python_version < "3.11" markers remain in pyproject.toml (lines 68, 72, 77, 92, 124, 126). docs/torch-runtime-safety-gate.md:110-122 still documents the removed 3.10 torch pin.
  • License files:
    • zdtaichu5/NOTICE:18 references LICENSES/MIT-OpenGVLab.txt, which doesn't exist; the actual file is LICENSES/InternVL-LICENSE.
    • Several port LICENSE files (internlm, internlm2, k2_horizon, mage_vl, mimo_v2, …) are the repo's Apache text with a ModelCloud SPDX header added, presented as the upstream license.
  • Unverified, worth a quantized-load test: the new native-FP32 restore (utils/model.py, _keep_in_fp32_modules[_strict] → _restore_checkpoint_buffers) raises "missing from checkpoint" for any matched name not stored under its runtime key, for example tied or init-only buffers. Please run it on a model that defines _keep_in_fp32_modules_strict.

Verified OK

Given the size, I'd strongly suggest splitting this into separate PRs: (a) the loader/trust migration plus the Python/Transformers floor, (b) the AWQ policy changes, and (c) ports in batches, with restricted-license ports held for a licensing decision. That would make each part reviewable and bisectable.

🤖 Generated with Claude Code

@Qubitium
Qubitium marked this pull request as ready for review November 18, 2026 02:50
Qubitium added a commit that referenced this pull request Nov 27, 2026
#4620 removed the PreTrainedModel.save_pretrained wrapper that entered
checkpoint_serialization(), so an HF-loaded Marlin/ExLlamaV2 model wrote its
irreversible runtime layout (tile/shuffled qweight, empty qzeros/g_idx) plus
qzeros_format markers under an ordinary checkpoint_format: gptq config. The
directory could not be reloaded by GPTQModel.load or Transformers.

Attach the guard to the loaded model instance in hf_gptqmodel_post_init, the
bridge Transformers' GPTQ/AWQ quantizers already call. It is instance-scoped,
so no Transformers class is touched. Bridge saves now refuse on runtime-layout
kernels with the #4134 error and drop qzeros_format for checkpoint-layout
kernels; GPTQModel.load/GPTQModel.save and read-only state_dict() callers are
unchanged.
This was referenced Nov 28, 2026
Qubitium added a commit that referenced this pull request Nov 29, 2026
…ding (#6377)

* fix(phi4): drop stale backoff/optimum require_pkgs expectation (#6365)

The phi4mm definition was ported off Microsoft's remote code in #4620.
The removed `speech_conformer_encoder` was the only `backoff` user, and
nothing on the package-owned native path imports `optimum`; `backoff`
is not installed in the CPU test environment, so restoring either
requirement would reject a valid install.

Keep `require_pkgs` empty and make the test assert that, with the
reasoning documented next to the declaration. The port's optional
torchvision/scipy imports already fail with LocalModelLoader's
`gptqmodel[vision]`/`gptqmodel[audio]` install hint, so they do not
need a load-time version check.

* refactor(eval): drop dead GGUF quantization-config hiding (#6366)

`_hide_unsupported_quantization_config_for_eval` and its lm-eval
wrapper had no callers. The only reason to keep them was the assumption
that Transformers cannot evaluate a GGUF quantization config, but
Transformers 5.23 constructs `GgufConfig` from it and
`AutoModelForCausalLM.from_pretrained` now loads and forwards such a
checkpoint through `GgufHfQuantizer`. The hiding branch was therefore
unreachable even if called.

Remove both helpers, their now-unused `contextmanager` import, and the
two tests that only exercised the deleted context managers.

---------

Co-authored-by: agent <agent@local>
Qubitium added a commit that referenced this pull request Nov 29, 2026
…6390)

- test_muse_glimmer/test_solar_open definition-selection tests patched
  `auto.AutoConfig`, which `gptqmodel.models.auto` no longer re-exports;
  `check_and_get_model_definition()` now reads the config through
  `auto.load_model_config` (the same seam test_solar_open2.py uses).

- The Solar Open tiny fixture now builds the vendored
  `gptqmodel.models.ports.native.solar_open` config/model. Since #4620 the
  definition loads through a LocalModelLoader whose
  `NativeForCausalLM._model_class()` rejects a `transformers.SolarOpenConfig`
  by design (`_require_vendored_config`), so `build_shell_model` raised
  "SolarOpenConfig is not a vendored GPT-QModel config".

- TestMuseGlimmer reloads the fast-mode checkpoint with
  `EVAL_SINGLE_GPU = False` so a multi-accelerator host can spread it, and
  skips with a precise reason when the host exposes < 56 GiB of visible
  accelerator memory. Fast mode only quantizes 2 of 52 decoder layers, so
  the saved checkpoint keeps ~58 GB of bf16 weights (29.78 B params minus
  0.97 B quantized); a single 48 GiB RTX 4090 OOMs in
  `accelerate.load_checkpoint_in_model` and cannot hold it. Slow mode
  quantizes every layer (~17 GB) and still runs.

Measured on one pinned RTX 4090 (SM 8.9, 47.45 GiB), torch 2.15+cu132,
transformers 5.23.0:
  models/test_muse_glimmer.py: 5 passed, 1 skipped
  models/test_solar_open.py (excluding the 100B TestSolarOpen): 6 passed

Fixes #6384

Co-authored-by: agent <agent@local>
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.

1 participant