Repository navigation
Description
Summary
Since #4620, every model type that has a LocalModelLoader is loaded through the package port. resolve_trust_remote_code() now returns False for those
types even when the user passes trust_remote_code=True. The writer then applies the #4073/#4084 rule "remote code not copied, so drop auto_map" (writer.py:491-502, :2219-2223).
That rule assumes the model type is native in Transformers (docs/hf-interop.md §4: "drop auto_map from the saved config → AutoConfig loads natively").
For ported model types that Transformers 5.23 does not register, the result is a quantized checkpoint whose config.json has
model_type: "minicpmv" / "minicpmo" / "internvl_chat" / "ovis2_5" / "deepseek_vl_v2", no auto_map, and no configuration_*.py / modeling_*.py. These are the
officially released remote-code VLMs. Their config can't be resolved by AutoConfig.from_pretrained(out, trust_remote_code=True). It also can't be resolved by any downstream tool that reads the config through it, which includes
vLLM for model types it doesn't register itself, such as minicpmv and internvl_chat. Before #4620 these families required trust_remote_code=True. The save kept
auto_map and copied the .py files (copy_py_files), so the quantized output was self-describing.
In addition, MiniCPM-o 2.6 is re-saved with architectures: ["MiniCPMO26"] instead of the released ["MiniCPMO"]. MiniCPMO26 is the package-internal
port subclass (ports/minicpm_o/modeling_minicpmo_26.py:50), written by writer.py:456. It is not an architecture name that any other loader knows.
Introduced by
d2dfb9385 / #4620. resolve_trust_remote_code short-circuits to False for every LocalModelLoader model type, and MiniCPMVQModel and the others no longer
require_trust_remote_code. This combines with the auto_map drop from a247cce2c / #4084, which was only safe for Transformers-native model types.
Location
HEAD d81ad345e (still present on origin/main 73e3d953f):
gptqmodel/utils/hf.py:701-704
if model_id_or_path:
payload, _ = PreTrainedConfig.get_config_dict(model_id_or_path, **config_load_kwargs)
if local_model_loader_for_config(payload) is not None:
return Falsegptqmodel/models/writer.py:491-502(normal save) and:2219-2223(module-replacement save)
if not trust_remote_code:
...
saved_config.pop("auto_map", None)gptqmodel/models/writer.py:456:config.architectures = [model.__class__.__name__.removeprefix("FSDP")](givesMiniCPMO26)
Reproduction
I ran this at HEAD with 2-layer random-weight checkpoints. Each was built from the released config.json (which has auto_map), plus the released tokenizer and processor files, for
openbmb/MiniCPM-V-4_5, openbmb/MiniCPM-o-2_6, OpenGVLab/InternVL3_5-1B-Instruct, AIDC-AI/Ovis2.5-2B and deepseek-ai/deepseek-vl2-tiny. I ran the normal flow on each:
m = GPTQModel.load(path, QuantizeConfig(bits=4, group_size=32))
# trust_remote_code=True does not help: resolve_trust_remote_code(path, trust_remote_code=True) returns False for all five
m.quantize(CalibrationConfig(dataset=calib))
m.save(out)Every save succeeds. Then, on each output:
from transformers import AutoConfig
AutoConfig.from_pretrained(out, trust_remote_code=True)MiniCPM-V-4_5 ValueError: The checkpoint you are trying to load has model type `minicpmv` but Transformers does not recognize this architecture ...
MiniCPM-o-2_6 ValueError: ... model type `minicpmo` ...
InternVL3_5-1B ValueError: ... model type `internvl_chat` ...
Ovis2.5-2B ValueError: ... model type `ovis2_5` ...
deepseek-vl2 ValueError: ... model type `deepseek_vl_v2` ...
Output config.json contents: auto_map is absent for all five, and there are no .py files in the output directory. The released repos ship them, e.g. MiniCPM-V-4_5 ships configuration_minicpm.py,
modeling_minicpmv.py, processing_minicpmv.py and others. MiniCPM-o-2_6 architectures changes from ['MiniCPMO'] to ['MiniCPMO26']. The saved
processor_config.json still names the remote-only MiniCPMVProcessor. GPTQModel.load(out) itself still works. I did not run vLLM.
Expected vs actual
- Expected: a quantized checkpoint of a released remote-code model stays loadable the way the source is. Keep the source
auto_map, and keep or copy the source
.pyfiles, when the model type isn't native to Transformers, as before Port every supported model onto the Transformers 5.23 ABI; never patch Transformers #4620. Keep the sourcearchitecturesvalue. - Actual:
auto_mapand the.pyfiles are dropped, so onlyGPTQModel.loadcan read the result. MiniCPM-o 2.6 also gets an internal class name as its architecture.
Suggested fix
In the writer, drop auto_map only when the saved model_type is registered in Transformers' CONFIG_MAPPING. Otherwise, preserve the source auto_map and copy the
source checkpoint's .py files as data. This doesn't need GPTQModel to import or run them. Preserve the source architectures when the runtime class is a package-internal
subclass (MiniCPMO26), or map it back to the released name. The same applies to other ported remote-code types that Transformers doesn't register
(chatglm, baichuan, internlm2, minicpm, ovis2_6_*, interns1, openvla, ...). Add a save round-trip test that checks AutoConfig.from_pretrained(out, trust_remote_code=True)
for one ported remote-code type.
Activity
fix(loader/save): exempt ported fp32 parameters and keep ported remot…
fix(writer): stop copying remote-code .py files when a native definit…
fix(writer): stop copying remote-code .py files when a native definit…