Image-Text-to-Text
Transformers
Safetensors
glm5_next
glm
exl3
tr3
vllm
sm120
nvfp4
dflash2
multimodal
shapleymcg
conversational
Eval Results (legacy)
4-bit precision
Instructions to use brandonmusic/GLM-5.3-Flash-tr3-4bpw with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use brandonmusic/GLM-5.3-Flash-tr3-4bpw with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="brandonmusic/GLM-5.3-Flash-tr3-4bpw") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("brandonmusic/GLM-5.3-Flash-tr3-4bpw") model = AutoModelForMultimodalLM.from_pretrained("brandonmusic/GLM-5.3-Flash-tr3-4bpw", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use brandonmusic/GLM-5.3-Flash-tr3-4bpw with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "brandonmusic/GLM-5.3-Flash-tr3-4bpw" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "brandonmusic/GLM-5.3-Flash-tr3-4bpw", "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/brandonmusic/GLM-5.3-Flash-tr3-4bpw
- SGLang
How to use brandonmusic/GLM-5.3-Flash-tr3-4bpw 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 "brandonmusic/GLM-5.3-Flash-tr3-4bpw" \ --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": "brandonmusic/GLM-5.3-Flash-tr3-4bpw", "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 "brandonmusic/GLM-5.3-Flash-tr3-4bpw" \ --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": "brandonmusic/GLM-5.3-Flash-tr3-4bpw", "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 brandonmusic/GLM-5.3-Flash-tr3-4bpw with Docker Model Runner:
docker model run hf.co/brandonmusic/GLM-5.3-Flash-tr3-4bpw
Download scripts/build_glm53_tp2_runtime_kld_receipt.py from brandonmusic/GLM-5.3-Flash-tr3-4bpw: direct link, hf CLI and curl.
- Browser
- Download file 6.66 kB
-
https://huggingface.co/brandonmusic/GLM-5.3-Flash-tr3-4bpw/resolve/1ae6d70430a12d762917786696db06a7b4f9bbae/scripts/build_glm53_tp2_runtime_kld_receipt.py
- Command line
-
hf download hf://brandonmusic/GLM-5.3-Flash-tr3-4bpw@1ae6d70430a12d762917786696db06a7b4f9bbae/scripts/build_glm53_tp2_runtime_kld_receipt.py
-
curl -L -o build_glm53_tp2_runtime_kld_receipt.py https://huggingface.co/brandonmusic/GLM-5.3-Flash-tr3-4bpw/resolve/1ae6d70430a12d762917786696db06a7b4f9bbae/scripts/build_glm53_tp2_runtime_kld_receipt.py
6.66 kB
| #!/usr/bin/env python3 | |
| """Seal fail-closed K4/TP2 qualification from actual-runtime teacher KLD.""" | |
| from __future__ import annotations | |
| import argparse | |
| import copy | |
| import json | |
| from pathlib import Path | |
| from quant_pipeline.core.artifacts import canonical_json, sha256_bytes, write_json | |
| from quant_pipeline.publication.glm53_k4_postmtp import REFERENCE_PANEL_SCHEMA, read_sealed | |
| from quant_pipeline.runtime.glm53_tp2_exl3 import GLM53_TP2_RUNTIME_SCHEMA | |
| SCHEMA = "quant-pipeline.glm53-custom-transformers-exl3-mcg-tp2-runtime-kld-qualified.v1" | |
| KLD_SCHEMA = "quant-pipeline.glm53-custom-tp2-runtime-window-kld.v1" | |
| def _read_sealed(path: Path, schema: str, field: str) -> dict: | |
| value = json.loads(path.read_text(encoding="utf-8")) | |
| body = copy.deepcopy(value) | |
| digest = body.pop(field, None) | |
| if value.get("schema") != schema or digest != sha256_bytes(canonical_json(body)): | |
| raise ValueError(f"sealed {schema} receipt differs: {path}") | |
| return value | |
| def main() -> int: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--runtime-receipt", type=Path, required=True) | |
| parser.add_argument("--runtime-kld-report", type=Path, required=True) | |
| parser.add_argument("--reference-receipt", type=Path, required=True) | |
| parser.add_argument("--materialization-receipt", type=Path, required=True) | |
| parser.add_argument("--output", type=Path, required=True) | |
| args = parser.parse_args() | |
| runtime = _read_sealed(args.runtime_receipt.resolve(), GLM53_TP2_RUNTIME_SCHEMA, "receipt_sha256") | |
| kld = _read_sealed(args.runtime_kld_report.resolve(), KLD_SCHEMA, "report_sha256") | |
| reference = read_sealed( | |
| args.reference_receipt.resolve(), REFERENCE_PANEL_SCHEMA, "receipt_sha256" | |
| ) | |
| materialization = _read_sealed( | |
| args.materialization_receipt.resolve(), | |
| "quant-pipeline.glm53-k4-materialization-receipt.v1", | |
| "receipt_sha256", | |
| ) | |
| parity = runtime.get("reference_logit_parity", {}) | |
| ranks = runtime.get("rank_reports", []) | |
| reasons = [] | |
| if ( | |
| runtime.get("bits") != 4 | |
| or runtime.get("tp_size") != 2 | |
| or runtime.get("generation_verified") is not True | |
| or runtime.get("main_packed_matrix_count") != 36288 | |
| or len(ranks) != 2 | |
| or [row.get("rank") for row in ranks] != [0, 1] | |
| or any(row.get("packed_matrix_count") != 36288 for row in ranks) | |
| or any(row.get("bf16_routed_weight_parameter_count") != 0 for row in ranks) | |
| or any(row.get("generated_token_count", 0) < 2 for row in ranks) | |
| ): | |
| reasons.append("packed TP2 load, generation, or rank census is incomplete") | |
| if ( | |
| parity.get("rank_output_identical") is not True | |
| or len(set(parity.get("rank_output_sha256", []))) != 1 | |
| or not isinstance(parity.get("observed_logits_artifact"), dict) | |
| ): | |
| reasons.append("full runtime logits are not retained and identical across TP ranks") | |
| if ( | |
| parity.get("sha256") != reference.get("sha256") | |
| or parity.get("input_ids_shape") != reference.get("input_shape") | |
| or parity.get("shape") != reference.get("logit_shape") | |
| ): | |
| reasons.append("runtime evaluation is not bound to the sealed decoded reference window") | |
| if ( | |
| kld.get("runtime_receipt_sha256") != runtime["receipt_sha256"] | |
| or kld.get("runtime_logits_sha256") | |
| != parity.get("observed_logits_artifact", {}).get("sha256") | |
| or kld.get("runtime_rank_output_identical") is not True | |
| or kld.get("window_id") != reference.get("window_id") | |
| or kld.get("token_ids_sha256") != reference.get("token_ids_sha256") | |
| or kld.get("prediction_positions") != reference.get("prediction_positions") | |
| or kld.get("max_mean_kld") != 0.06 | |
| or kld.get("mean_kld_gate_passed") is not True | |
| or float(kld.get("summary", {}).get("mean", float("inf"))) >= 0.06 | |
| ): | |
| reasons.append("actual-runtime BF16-teacher KLD gate did not pass below 0.06") | |
| if ( | |
| materialization.get("bits") != 4 | |
| or materialization.get("complete") is not True | |
| or materialization.get("main_and_mtp_complete") is not True | |
| or materialization.get("nonrouted_native_exact") is not True | |
| ): | |
| reasons.append("materialized K4 main/MTP checkpoint is incomplete") | |
| receipt = { | |
| "schema": SCHEMA, | |
| "bits": 4, | |
| "tp_size": 2, | |
| "qualification_basis": "actual_runtime_teacher_kld_plus_cross_rank_identity_and_generation", | |
| "materialization_receipt_sha256": materialization["receipt_sha256"], | |
| "raw_runtime_receipt_sha256": runtime["receipt_sha256"], | |
| "runtime_module_sha256": runtime["runtime_module_sha256"], | |
| "exllamav3_commit": runtime["exllamav3_commit"], | |
| "generation_verified": runtime.get("generation_verified"), | |
| "rank_reports": ranks, | |
| "rank_output_identical": parity.get("rank_output_identical"), | |
| "rank_output_sha256": parity.get("rank_output_sha256"), | |
| "runtime_logits_artifact": parity.get("observed_logits_artifact"), | |
| "decoded_reference": { | |
| "receipt_sha256": reference["receipt_sha256"], | |
| "sha256": reference["sha256"], | |
| "raw_parity_passed": parity.get("passed"), | |
| "max_abs_error": parity.get("max_abs_error"), | |
| "mean_abs_error": parity.get("mean_abs_error"), | |
| "max_abs_tolerance": parity.get("max_abs_tolerance"), | |
| "mean_abs_tolerance": parity.get("mean_abs_tolerance"), | |
| }, | |
| "teacher_runtime_kld": { | |
| "report_sha256": kld["report_sha256"], | |
| "teacher_receipt_sha256": kld["teacher_receipt_sha256"], | |
| "window_id": kld["window_id"], | |
| "prediction_positions": kld["prediction_positions"], | |
| "mean": kld["summary"]["mean"], | |
| "p95": kld["summary"]["p95"], | |
| "max": kld["summary"]["max"], | |
| "top1_agreement": kld["top1_agreement"], | |
| "threshold": 0.06, | |
| "passed": kld["mean_kld_gate_passed"], | |
| }, | |
| "raw_decoded_parity_is_not_the_qualification_basis": True, | |
| "stock_vllm_compatible": False, | |
| "stock_exllamav3_model_compatible": False, | |
| "qualified": not reasons, | |
| "failure_reasons": reasons, | |
| "example_only": False, | |
| } | |
| receipt["receipt_sha256"] = sha256_bytes(canonical_json(receipt)) | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| write_json(args.output, receipt) | |
| print(json.dumps(receipt, indent=2, sort_keys=True)) | |
| return 0 if receipt["qualified"] else 2 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |