Image-Text-to-Text
Transformers
Safetensors
qwen3_5
gsq
gumbel-softmax
quantization
ptq
qwen
vllm
humming
conversational
compressed-tensors
Instructions to use ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ") model = AutoModelForMultimodalLM.from_pretrained("ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ
- SGLang
How to use ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ with Docker Model Runner:
docker model run hf.co/ISTA-DASLab/Qwen3.8-27B-3Bit-GSQ
| import importlib.util | |
| import os | |
| import re | |
| import shutil | |
| import sys | |
| import tempfile | |
| from pathlib import Path | |
| PATCH_NAME = "qwen3_5_quantized_embedding" | |
| def find_vllm_root() -> Path: | |
| spec = importlib.util.find_spec("vllm") | |
| if spec is None: | |
| raise RuntimeError( | |
| f"Could not find installed vLLM.\nPython executable: {sys.executable}" | |
| ) | |
| if spec.submodule_search_locations: | |
| return Path(next(iter(spec.submodule_search_locations))).resolve() | |
| if spec.origin: | |
| return Path(spec.origin).resolve().parent | |
| raise RuntimeError("Could not determine the installed vLLM path.") | |
| def find_qwen35_file(vllm_root: Path) -> Path: | |
| path = vllm_root / "model_executor" / "models" / "qwen3_5.py" | |
| if not path.is_file(): | |
| raise RuntimeError(f"Could not find Qwen3.5 implementation at:\n{path}") | |
| return path | |
| def already_patched(text: str) -> bool: | |
| pattern = re.compile( | |
| r"self\.embed_tokens\s*=\s*VocabParallelEmbedding\(\s*" | |
| r"self\.vocab_size\s*,\s*" | |
| r"config\.hidden_size\s*,\s*" | |
| r"quant_config\s*=\s*self\.quant_config\s*,\s*" | |
| r'prefix\s*=\s*f["\']\{prefix\}\.embed_tokens["\']\s*,?\s*\)', | |
| re.DOTALL, | |
| ) | |
| return pattern.search(text) is not None | |
| def patch_source(text: str) -> str: | |
| class_pos = text.find("class Qwen3_5Model") | |
| if class_pos == -1: | |
| raise RuntimeError("Could not find 'class Qwen3_5Model'.") | |
| search_end = min(len(text), class_pos + 20_000) | |
| section = text[class_pos:search_end] | |
| pattern = re.compile( | |
| r"(?P<indent>^[ \t]+)self\.embed_tokens\s*=\s*VocabParallelEmbedding\(\s*\n" | |
| r"(?P=indent)[ \t]+self\.vocab_size\s*,\s*\n" | |
| r"(?P=indent)[ \t]+config\.hidden_size\s*,\s*\n" | |
| r"(?P=indent)\)", | |
| re.MULTILINE, | |
| ) | |
| match = pattern.search(section) | |
| if match is None: | |
| raise RuntimeError( | |
| "Could not find the expected unpatched embedding block. " | |
| "The installed vLLM source may have changed." | |
| ) | |
| indent = match.group("indent") | |
| inner = indent + " " | |
| replacement = ( | |
| f"{indent}self.embed_tokens = VocabParallelEmbedding(\n" | |
| f"{inner}self.vocab_size,\n" | |
| f"{inner}config.hidden_size,\n" | |
| f"{inner}quant_config=self.quant_config,\n" | |
| f'{inner}prefix=f"{{prefix}}.embed_tokens",\n' | |
| f"{indent})" | |
| ) | |
| start = class_pos + match.start() | |
| end = class_pos + match.end() | |
| return text[:start] + replacement + text[end:] | |
| def atomic_write(path: Path, content: str): | |
| fd, tmp_name = tempfile.mkstemp(prefix=path.name + ".", suffix=".tmp", dir=path.parent) | |
| tmp_path = Path(tmp_name) | |
| try: | |
| with os.fdopen(fd, "w", encoding="utf-8") as f: | |
| f.write(content) | |
| shutil.copymode(path, tmp_path) | |
| os.replace(tmp_path, path) | |
| except Exception: | |
| tmp_path.unlink(missing_ok=True) | |
| raise | |
| def main(): | |
| print("=" * 70) | |
| print("vLLM Qwen3.5 quantized embedding patch") | |
| print("=" * 70) | |
| print(f"Python: {sys.executable}") | |
| vllm_root = find_vllm_root() | |
| target = find_qwen35_file(vllm_root) | |
| print(f"vLLM: {vllm_root}") | |
| print(f"Target: {target}") | |
| text = target.read_text(encoding="utf-8") | |
| if already_patched(text): | |
| print("[OK] Patch is already installed.") | |
| return 0 | |
| try: | |
| patched = patch_source(text) | |
| except RuntimeError as exc: | |
| print(f"[ERROR] {exc}", file=sys.stderr) | |
| return 1 | |
| if not already_patched(patched): | |
| print("[ERROR] Generated patch failed verification.", file=sys.stderr) | |
| return 1 | |
| try: | |
| compile(patched, str(target), "exec") | |
| except SyntaxError as exc: | |
| print(f"[ERROR] Patched source has invalid syntax: {exc}", file=sys.stderr) | |
| return 1 | |
| backup = target.with_name(target.name + f".{PATCH_NAME}.bak") | |
| if not backup.exists(): | |
| try: | |
| shutil.copy2(target, backup) | |
| print(f"Backup: {backup}") | |
| except PermissionError: | |
| print(f"[ERROR] Permission denied creating backup: {backup}", file=sys.stderr) | |
| return 1 | |
| else: | |
| print(f"Backup already exists: {backup}") | |
| try: | |
| atomic_write(target, patched) | |
| except PermissionError: | |
| print(f"[ERROR] Permission denied patching: {target}", file=sys.stderr) | |
| return 1 | |
| final_text = target.read_text(encoding="utf-8") | |
| if not already_patched(final_text): | |
| print("[ERROR] Patch verification failed after writing.", file=sys.stderr) | |
| return 1 | |
| print("[OK] Successfully patched Qwen3.5 quantized embeddings.") | |
| print("Restart all vLLM processes before loading the model.") | |
| print(f"Restore with: cp {backup} {target}") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |