|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Use vLLM to speed " |
| 4 | +author: "Yuxuan Zhang" |
| 5 | +image: /assets/logos/vllm-logo-text-light.png |
| 6 | +--- |
| 7 | + |
| 8 | +# Introduction |
| 9 | + |
| 10 | +The GLM-4.5 series models are foundation models designed for intelligent agents. GLM-4.5 has 355 billion total |
| 11 | +parameters with 32 billion active parameters, while GLM-4.5-Air adopts a more compact design with 106 billion total |
| 12 | +parameters and 12 billion active parameters. GLM-4.5 models unify reasoning, coding, and intelligent agent capabilities |
| 13 | +to meet the complex demands of intelligent agent applications. |
| 14 | + |
| 15 | +Both GLM-4.5 and GLM-4.5-Air are hybrid reasoning models that provide two modes: thinking mode for complex reasoning and |
| 16 | +tool usage, and non-thinking mode for immediate responses. |
| 17 | + |
| 18 | +As demonstrated in our comprehensive evaluation across 12 industry-standard benchmarks, GLM-4.5 achieves exceptional |
| 19 | +performance with a score of 63.2, in the 3rd place among all the proprietary and open-source models. Notably, |
| 20 | +GLM-4.5-Air delivers competitive results at 59.8 while maintaining superior efficiency. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +GLM-4.5V is based on GLM-4.5-Air. It continues the technical approach of GLM-4.1V-Thinking, achieving SOTA performance |
| 25 | +among models of the same scale on 42 public vision-language benchmarks. |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +To get more information about GLM-4.5 and GLM-4.5V, please refer to the [GLM-4.5](https://github.com/zai-org/GLM-4.5) |
| 30 | +and [GLM-V](https://github.com/zai-org/GLM-V). |
| 31 | + |
| 32 | +this blog will guide users on how to use vLLM to accelerate inference for the GLM-4.5V and GLM-4.5 model series on |
| 33 | +NVIDIA Blackwell and Hopper GPUs. |
| 34 | + |
| 35 | +## Installation |
| 36 | + |
| 37 | +In the latest vLLM main branch, both the GLM-4.5V and GLM-4.5 model series are supported. |
| 38 | +You can install the nightly version and manually update transformers to enable model support. |
| 39 | + |
| 40 | +```shell |
| 41 | +pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly |
| 42 | +pip install transformers-v4.55.0-GLM-4.5V-preview |
| 43 | +``` |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +GLM-4.5 and GLM-4.5V both offer FP8 and BF16 precision models. |
| 48 | +In vLLM, you can use the same command to run inference for either precision. |
| 49 | + |
| 50 | +For the GLM-4.5 model, you can start the service with the following command: |
| 51 | + |
| 52 | +```shell |
| 53 | +vllm serve zai-org/GLM-4.5-Air \ |
| 54 | + --tensor-parallel-size 4 \ |
| 55 | + --tool-call-parser glm45 \ |
| 56 | + --reasoning-parser glm45 \ |
| 57 | + --enable-auto-tool-choice |
| 58 | +``` |
| 59 | + |
| 60 | +For the GLM-4.5V model, you can start the service with the following command: |
| 61 | + |
| 62 | +```shell |
| 63 | +vllm serve zai-org/GLM-4.5V \ |
| 64 | + --tensor-parallel-size 4 \ |
| 65 | + --tool-call-parser glm45 \ |
| 66 | + --reasoning-parser glm45 \ |
| 67 | + --enable-auto-tool-choice \ |
| 68 | + --allowed-local-media-path / \ |
| 69 | + --media-io-kwargs '{"video": {"num_frames": -1}}' |
| 70 | +``` |
| 71 | + |
| 72 | +## Important Notes |
| 73 | + |
| 74 | ++ The reasoning part of the model output will be wrapped in `reasoning_content`. `content` will only contain the final |
| 75 | + answer. To disable reasoning, add the following parameter: |
| 76 | + `extra_body={"chat_template_kwargs": {"enable_thinking": False}}` |
| 77 | ++ If you're using 8x H100 GPUs and encounter insufficient memory when running the GLM-4.5 model, you'll need |
| 78 | + `--cpu-offload-gb 16`. |
| 79 | ++ If you encounter `flash infer` issues, use `VLLM_ATTENTION_BACKEND=XFORMERS` as a temporary replacement. You can also |
| 80 | + specify `TORCH_CUDA_ARCH_LIST='9.0+PTX'` to use `flash infer`, different GPUs have different TORCH_CUDA_ARCH_LIST |
| 81 | + values, please check accordingly. |
| 82 | ++ vllm v0 is not support our model. |
| 83 | + |
| 84 | +### Grounding in GLM-4.5V |
| 85 | + |
| 86 | +GLM-4.5V equips precise grounding capabilities. Given a prompt that requests the location of a specific object, GLM-4.5V |
| 87 | +is able to reasoning step-by-step and identify the bounding boxes of the target object. The query prompt supports |
| 88 | +complex descriptions of the target object as well as specified output formats, for example: |
| 89 | +> |
| 90 | +> - Help me to locate <expr> in the image and give me its bounding boxes. |
| 91 | +> - Please pinpoint the bounding box [[x1,y1,x2,y2], …] in the image as per the given description. <expr> |
| 92 | +
|
| 93 | +Here, `<expr>` is the description of the target object. The output bounding box is a quadruple $$[x_1,y_1,x_2,y_2]$$ |
| 94 | +composed of the coordinates of the top-left and bottom-right corners, where each value is normalized by the image |
| 95 | +width (for x) or height (for y) and scaled by 1000. |
| 96 | + |
| 97 | +In the response, the special tokens `<|begin_of_box|>` and `<|end_of_box|>` are used to mark the image bounding box in |
| 98 | +the answer. The bracket style may vary ([], [[]], (), <>, etc.), but the meaning is the same: to enclose the coordinates |
| 99 | +of the box. |
| 100 | + |
| 101 | +## Acknowledgement |
| 102 | + |
| 103 | +vLLM team members who contributed to this effort are: Simon Mo, Kaichao You. |
0 commit comments