"""Plugin's vendored processor (no trust_remote_code) vs Liquid's remote processor: same ids + pixels. python3 check_processor.py mine|ref OUT.pt (run each in its own process; 'ref' does not import the plugin)""" import sys, torch, numpy as np from PIL import Image from transformers import AutoProcessor which, out = sys.argv[1], sys.argv[2] if which == "mine": import vllm_lfm3 vllm_lfm3.register() proc = AutoProcessor.from_pretrained("/vl", trust_remote_code=(which == "ref")) print(which, type(proc).__module__, type(proc.image_processor).__module__) rng = np.random.default_rng(0) res = {} for (w, h) in [(640, 480), (100, 60), (2400, 400), (1024, 1024), (1920, 1080)]: img = Image.fromarray(rng.integers(0, 255, (h, w, 3), dtype=np.uint8)) msgs = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "hi"}]}] text = proc.apply_chat_template(msgs, add_generation_prompt=True, tokenize=False) res[(w, h)] = dict(proc(text=text, images=[img], return_tensors="pt")) torch.save(res, out) if which == "mine": ref = torch.load(out.replace("mine", "ref")) for k, a in res.items(): b = ref[k] print(k, "grid", a["image_grid_thw"].tolist(), "image tokens", int((a["input_ids"] == 125030).sum()), "ids equal", torch.equal(a["input_ids"], b["input_ids"]), "pixels equal", torch.equal(a["pixel_values"], b["pixel_values"]))