{"id":53774,"date":"2025-08-12T16:39:44","date_gmt":"2025-08-12T08:39:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/53774.html"},"modified":"2025-08-12T16:39:44","modified_gmt":"2025-08-12T08:39:44","slug":"%e5%a4%a7%e6%a8%a1%e5%9e%8b%e6%8e%a8%e7%90%86%e6%a1%86%e6%9e%b6%e5%af%b9%e6%af%94%ef%bc%9asglang-%e4%b8%8e-vllm-%e7%9a%84%e6%a0%b8%e5%bf%83%e5%b7%ae%e5%bc%82","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/53774.html","title":{"rendered":"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02"},"content":{"rendered":"<h2 style=\"margin-left:0pt;text-align:left\"><\/h2>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u5728\u5927\u6a21\u578b\u5e94\u7528\u843d\u5730\u8fc7\u7a0b\u4e2d&#xff0c;\u63a8\u7406\u6548\u7387\u76f4\u63a5\u51b3\u5b9a\u4e86\u670d\u52a1\u7684\u54cd\u5e94\u901f\u5ea6\u3001\u6210\u672c\u4e0e\u7528\u6237\u4f53\u9a8c\u3002\u8fd1\u5e74\u6765&#xff0c;\u4ee5\u00a0SGLang\u00a0\u548c\u00a0vLLM\u00a0\u4e3a\u4ee3\u8868\u7684\u65b0\u4e00\u4ee3\u63a8\u7406\u6846\u67b6\u51ed\u501f\u663e\u8457\u7684\u6027\u80fd\u4f18\u52bf&#xff0c;\u9010\u6e10\u6210\u4e3a\u5de5\u4e1a\u754c\u90e8\u7f72\u5927\u6a21\u578b\u7684\u9996\u9009\u5de5\u5177\u3002\u672c\u6587\u5c06\u4ece\u67b6\u6784\u8bbe\u8ba1\u3001\u6838\u5fc3\u7279\u6027\u3001\u6027\u80fd\u8868\u73b0\u5230\u9002\u7528\u573a\u666f&#xff0c;\u5168\u65b9\u4f4d\u89e3\u6790\u4e24\u8005\u7684\u6280\u672f\u5dee\u5f02&#xff0c;\u4e3a\u5f00\u53d1\u8005\u9009\u62e9\u5408\u9002\u7684\u63a8\u7406\u6846\u67b6\u63d0\u4f9b\u53c2\u8003\u3002<\/span><\/p>\n<p style=\"text-align:start\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"343\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812083943-689afdcf13744.png\" width=\"343\" \/><\/p>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u4e00\u3001\u67b6\u6784\u8bbe\u8ba1&#xff1a;\u5e95\u5c42\u6280\u672f\u8def\u5f84\u7684\u5206\u91ce<\/span><\/h3>\n<p style=\"text-align:start\"><span style=\"color:#000000\">SGLang\u00a0\u548c\u00a0vLLM\u00a0\u867d\u7136\u90fd\u4ee5\u63d0\u5347\u5927\u6a21\u578b\u63a8\u7406\u6548\u7387\u4e3a\u76ee\u6807&#xff0c;\u4f46\u5728\u5e95\u5c42\u67b6\u6784\u8bbe\u8ba1\u4e0a\u91c7\u7528\u4e86\u622a\u7136\u4e0d\u540c\u7684\u6280\u672f\u8def\u5f84&#xff0c;\u8fd9\u79cd\u5dee\u5f02\u76f4\u63a5\u5f71\u54cd\u4e86\u5b83\u4eec\u7684\u6027\u80fd\u7279\u6027\u548c\u9002\u7528\u573a\u666f\u3002<\/span><\/p>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">1.1 vLLM\u00a0\u7684\u6838\u5fc3\u67b6\u6784&#xff1a;\u57fa\u4e8e\u00a0PagedAttention\u00a0\u7684\u4f18\u5316<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">vLLM\u00a0\u7684\u6838\u5fc3\u521b\u65b0\u662fPagedAttention\u673a\u5236&#xff0c;\u501f\u9274\u4e86\u64cd\u4f5c\u7cfb\u7edf\u7684\u865a\u62df\u5185\u5b58\u5206\u9875\u601d\u60f3&#xff0c;\u5c06\u00a0KV\u00a0\u7f13\u5b58&#xff08;Key-Value Cache&#xff09;\u5212\u5206\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u5757&#xff08;Block&#xff09;&#xff0c;\u901a\u8fc7\u5757\u7ba1\u7406\u5668\u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u5206\u914d\u4e0e\u590d\u7528\u3002<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u5176\u67b6\u6784\u5305\u542b\u4e09\u4e2a\u5173\u952e\u7ec4\u4ef6&#xff1a;<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">PagedAttention\u00a0\u6a21\u5757&#xff1a;\u5b9e\u73b0\u00a0KV\u00a0\u7f13\u5b58\u7684\u5206\u9875\u7ba1\u7406&#xff0c;\u89e3\u51b3\u4f20\u7edf\u63a8\u7406\u4e2d\u5185\u5b58\u788e\u7247\u5316\u95ee\u9898<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u8fde\u7eed\u6279\u5904\u7406&#xff08;Continuous Batching&#xff09;\u8c03\u5ea6\u5668&#xff1a;\u52a8\u6001\u63a5\u6536\u65b0\u8bf7\u6c42&#xff0c;\u7075\u6d3b\u5206\u914d\u8ba1\u7b97\u8d44\u6e90&#xff0c;\u907f\u514d\u9759\u6001\u6279\u5904\u7406\u7684\u8d44\u6e90\u6d6a\u8d39<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">CUDA\u00a0\u6838\u4f18\u5316&#xff1a;\u9488\u5bf9\u00a0Transformer\u00a0\u5c42\u7684\u81ea\u5b9a\u4e49\u00a0CUDA\u00a0\u5b9e\u73b0&#xff0c;\u51cf\u5c11\u5185\u5b58\u8bbf\u95ee\u5ef6\u8fdf<\/span><\/p>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">1.2 SGLang\u00a0\u7684\u6838\u5fc3\u67b6\u6784&#xff1a;\u57fa\u4e8e\u6307\u4ee4\u6d41\u7684\u6267\u884c\u6a21\u578b<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">SGLang\u00a0\u5219\u91c7\u7528\u6307\u4ee4\u6d41&#xff08;Instruction Flow&#xff09;\u00a0\u67b6\u6784&#xff0c;\u5c06\u590d\u6742\u7684\u63a8\u7406\u4efb\u52a1\u5206\u89e3\u4e3a\u6807\u51c6\u5316\u7684\u6307\u4ee4\u5e8f\u5217&#xff0c;\u901a\u8fc7\u4e13\u7528\u6267\u884c\u5f15\u64ce\u4f18\u5316\u8c03\u5ea6\u903b\u8f91\u3002<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u5176\u6838\u5fc3\u7ec4\u4ef6\u5305\u62ec&#xff1a;<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u6307\u4ee4\u7f16\u8bd1\u5668&#xff1a;\u5c06\u7528\u6237\u8f93\u5165\u7684\u63d0\u793a\u8bcd&#xff08;Prompt&#xff09;\u8f6c\u6362\u4e3a\u7ed3\u6784\u5316\u6307\u4ee4\u6d41<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u63a8\u7406\u6267\u884c\u5f15\u64ce&#xff1a;\u6309\u6307\u4ee4\u4f9d\u8d56\u5173\u7cfb\u8c03\u5ea6\u8ba1\u7b97&#xff0c;\u652f\u6301\u6761\u4ef6\u5206\u652f\u3001\u5faa\u73af\u7b49\u590d\u6742\u903b\u8f91<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u5f20\u91cf\u5e76\u884c\u6a21\u5757&#xff1a;\u4f18\u5316\u591a\u00a0GPU\u00a0\u95f4\u7684\u901a\u4fe1\u6548\u7387&#xff0c;\u652f\u6301\u8d85\u5927\u89c4\u6a21\u6a21\u578b\u90e8\u7f72<\/span><\/p>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u4e8c\u3001\u6838\u5fc3\u7279\u6027\u5bf9\u6bd4&#xff1a;\u529f\u80fd\u4e0e\u6027\u80fd\u7684\u6743\u8861<\/span><\/h3>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">2.1\u00a0\u5173\u952e\u7279\u6027\u5bf9\u7167\u8868<\/span><\/h4>\n<p style=\"text-align:start\">\n<table border=\"1\" cellspacing=\"0\" style=\"margin-left:-0.6pt\">\n<tbody>\n<tr>\n<td style=\"border-color:#dee0e3;vertical-align:top;width:138pt\">\n<p>\u7279\u6027<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>vLLM<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>SGLang<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u6280\u672f\u672c\u8d28<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u5185\u5b58\u7ba1\u7406<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>PagedAttention\u00a0\u5206\u9875\u673a\u5236<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u9759\u6001\u9884\u5206\u914d\u00a0&#043;\u00a0\u52a8\u6001\u590d\u7528<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>vLLM\u00a0\u66f4\u64c5\u957f\u5904\u7406\u957f\u5e8f\u5217\u52a8\u6001\u8bf7\u6c42&#xff0c;SGLang\u00a0\u5728\u56fa\u5b9a\u573a\u666f\u4e0b\u5185\u5b58\u5f00\u9500\u66f4\u4f4e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u6279\u5904\u7406\u65b9\u5f0f<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u8fde\u7eed\u6279\u5904\u7406&#xff08;Continuous Batching&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u6307\u4ee4\u6d41\u8c03\u5ea6\u6279\u5904\u7406<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>vLLM\u00a0\u9002\u5408\u9ad8\u5e76\u53d1\u52a8\u6001\u8bf7\u6c42&#xff0c;SGLang\u00a0\u5728\u590d\u6742\u4ea4\u4e92\u573a\u666f\u66f4\u9ad8\u6548<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u52a8\u6001\u63a7\u5236\u6d41<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u6709\u9650\u652f\u6301&#xff08;\u901a\u8fc7\u00a0Prompt\u00a0\u6a21\u677f&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u539f\u751f\u652f\u6301&#xff08;if\/loop\u00a0\u7b49\u6307\u4ee4&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>SGLang\u00a0\u66f4\u9002\u5408\u591a\u8f6e\u5bf9\u8bdd\u3001\u5de5\u5177\u8c03\u7528\u7b49\u590d\u6742\u573a\u666f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u6a21\u578b\u517c\u5bb9\u6027<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u652f\u6301\u4e3b\u6d41\u5f00\u6e90\u6a21\u578b&#xff08;LLaMA\/OPT\u00a0\u7b49&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u4e13\u6ce8\u4f18\u5316\u00a0LLaMA\u00a0\u7cfb\u5217\u53ca\u884d\u751f\u6a21\u578b<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>vLLM\u00a0\u517c\u5bb9\u6027\u66f4\u5e7f&#xff0c;SGLang\u00a0\u5728\u7279\u5b9a\u6a21\u578b\u4e0a\u6027\u80fd\u66f4\u4f18<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u90e8\u7f72\u590d\u6742\u5ea6<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u7b80\u5355&#xff08;\u5355\u6587\u4ef6\u90e8\u7f72&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u4e2d\u7b49&#xff08;\u9700\u914d\u7f6e\u6307\u4ee4\u6d41\u6a21\u677f&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>vLLM\u00a0\u5f00\u7bb1\u5373\u7528\u6027\u66f4\u597d<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u6269\u5c55\u80fd\u529b<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u652f\u6301\u5206\u5e03\u5f0f\u63a8\u7406\u3001\u91cf\u5316\u7b49<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u652f\u6301\u591a\u6a21\u6001\u6269\u5c55\u3001\u63d2\u4ef6\u7cfb\u7edf<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>SGLang\u00a0\u6269\u5c55\u751f\u6001\u66f4\u6d3b\u8dc3<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">2.2\u00a0\u6027\u80fd\u5173\u952e\u6307\u6807\u5bf9\u6bd4<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u5728\u00a0A100 GPU\u30017B\u00a0\u6a21\u578b\u3001\u8f93\u5165\u957f\u5ea6\u00a02048\u3001\u8f93\u51fa\u957f\u5ea6\u00a0512\u00a0\u7684\u6807\u51c6\u6d4b\u8bd5\u573a\u666f\u4e0b&#xff1a;<\/span><\/p>\n<p style=\"text-align:start\">\n<table border=\"1\" cellspacing=\"0\" style=\"margin-left:-0.6pt\">\n<tbody>\n<tr>\n<td style=\"border-color:#dee0e3;vertical-align:top;width:138pt\">\n<p>\u6307\u6807<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>vLLM<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>SGLang<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u63d0\u5347\u5e45\u5ea6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u541e\u5410\u91cf&#xff08;tokens\/sec&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>1280<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>1450<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>&#043;13.3%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u9996\u5b57\u7b26\u5ef6\u8fdf&#xff08;ms&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>85<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>62<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>-27.1%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u7aef\u5230\u7aef\u5ef6\u8fdf&#xff08;ms&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>680<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>590<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>-13.2%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138pt\">\n<p>\u5185\u5b58\u5360\u7528&#xff08;GB&#xff09;<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>14.2<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>12.8<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138pt\">\n<p>-9.8%<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u6ce8&#xff1a;SGLang\u00a0\u5728\u957f\u5e8f\u5217\u573a\u666f\u4e0b\u4f18\u52bf\u66f4\u660e\u663e&#xff0c;\u5f53\u8f93\u5165\u957f\u5ea6\u8fbe\u00a08192\u00a0\u65f6\u541e\u5410\u91cf\u9886\u5148\u00a0vLLM\u00a0\u7ea6\u00a022%<\/span><\/p>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u4e09\u3001\u4ee3\u7801\u5b9e\u6218&#xff1a;\u6838\u5fc3\u529f\u80fd\u5b9e\u73b0\u5bf9\u6bd4<\/span><\/h3>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">3.1\u00a0\u57fa\u7840\u6587\u672c\u751f\u6210<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">vLLM\u00a0\u5b9e\u73b0&#xff1a;<\/span><\/p>\n<p style=\"text-align:start\">\n<table border=\"1\" cellspacing=\"0\" style=\"margin-left:-0.6pt\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;vertical-align:top;width:493.171875px\">\n<p>from vllm import LLM, SamplingParams<\/p>\n<p>#\u00a0\u521d\u59cb\u5316\u6a21\u578b<\/p>\n<p>sampling_params &#061; SamplingParams(temperature&#061;0.7, max_tokens&#061;512)<\/p>\n<p>llm &#061; LLM(model&#061;&#034;lmsys\/vicuna-7b-v1.5&#034;, tensor_parallel_size&#061;1)<\/p>\n<p>#\u00a0\u751f\u6210\u6587\u672c<\/p>\n<p>prompts &#061; [&#034;\u63a8\u8350\u4e00\u672c\u673a\u5668\u5b66\u4e60\u5165\u95e8\u4e66\u7c4d&#xff1a;&#034;]<\/p>\n<p>outputs &#061; llm.generate(prompts, sampling_params)<\/p>\n<p>#\u00a0\u8f93\u51fa\u7ed3\u679c<\/p>\n<p>for output in outputs:<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0prompt &#061; output.prompt<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0generated_text &#061; output.outputs[0].text<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0print(f&#034;Prompt: {prompt!r}, Generated text: {generated_text!r}&#034;)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align:start\"><span style=\"color:#000000\">SGLang\u00a0\u5b9e\u73b0&#xff1a;<\/span><\/p>\n<p style=\"text-align:start\">\n<table border=\"1\" cellspacing=\"0\" style=\"margin-left:-0.6pt\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;vertical-align:top;width:481.125px\">\n<p>from sglang import SGLModel, instruct<\/p>\n<p>#\u00a0\u521d\u59cb\u5316\u6a21\u578b<\/p>\n<p>model &#061; SGLModel(model_path&#061;&#034;lmsys\/vicuna-7b-v1.5&#034;, device&#061;&#034;cuda&#034;)<\/p>\n<p>#\u00a0\u5b9a\u4e49\u6307\u4ee4\u6d41<\/p>\n<p>&#064;instruct<\/p>\n<p>def generate_book_recommendation(s):<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0s &#043;&#061; &#034;\u63a8\u8350\u4e00\u672c\u673a\u5668\u5b66\u4e60\u5165\u95e8\u4e66\u7c4d&#xff1a;&#034;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0s.generate(max_tokens&#061;512, temperature&#061;0.7)<\/p>\n<p>#\u00a0\u6267\u884c\u751f\u6210<\/p>\n<p>result &#061; generate_book_recommendation.run()<\/p>\n<p>print(f&#034;Generated text: {result.text}&#034;)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">3.2\u00a0\u590d\u6742\u4ea4\u4e92\u573a\u666f&#xff08;\u5e26\u6761\u4ef6\u5224\u65ad&#xff09;<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">vLLM\u00a0\u5b9e\u73b0&#xff08;\u9700\u624b\u52a8\u5904\u7406\u6761\u4ef6\u903b\u8f91&#xff09;&#xff1a;<\/span><\/p>\n<p style=\"text-align:start\">\n<table border=\"1\" cellspacing=\"0\" style=\"margin-left:-0.6pt\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;vertical-align:top;width:429.5625px\">\n<p>def complex_dialog(prompt):<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0#\u00a0\u7b2c\u4e00\u6b21\u751f\u6210<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0outputs &#061; llm.generate([prompt], sampling_params)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0response &#061; outputs[0].outputs[0].text<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0#\u00a0\u624b\u52a8\u5224\u65ad\u662f\u5426\u9700\u8981\u8ffd\u95ee<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0if &#034;\u4e0d\u77e5\u9053&#034; in response or &#034;\u4e0d\u786e\u5b9a&#034; in response:<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0follow_up &#061; prompt &#043; response &#043; &#034;\\\\n\u8bf7\u63d0\u4f9b\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f&#xff1a;&#034;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0outputs &#061; llm.generate([follow_up], sampling_params)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return outputs[0].outputs[0].text<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0return response<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align:start\"><span style=\"color:#000000\">SGLang\u00a0\u5b9e\u73b0&#xff08;\u539f\u751f\u652f\u6301\u6761\u4ef6\u63a7\u5236\u6d41&#xff09;&#xff1a;<\/span><\/p>\n<p style=\"text-align:start\">\n<table border=\"1\" cellspacing=\"0\" style=\"margin-left:-0.6pt\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;vertical-align:top;width:412.5625px\">\n<p>&#064;instruct<\/p>\n<p>def complex_dialog(s):<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0s &#043;&#061; &#034;\u8bf7\u89e3\u91ca\u91cf\u5b50\u8ba1\u7b97\u7684\u57fa\u672c\u539f\u7406&#xff1a;&#034;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0s.generate(name&#061;&#034;first_response&#034;, max_tokens&#061;300)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0#\u00a0\u6761\u4ef6\u5224\u65ad\u662f\u5426\u9700\u8981\u8ffd\u95ee<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0s.if_(s[&#034;first_response&#034;].contains(&#034;\u4e0d\u77e5\u9053&#034;) |\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0s[&#034;first_response&#034;].contains(&#034;\u4e0d\u786e\u5b9a&#034;)):<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0s &#043;&#061; &#034;\\\\n\u8bf7\u63d0\u4f9b\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f&#xff1a;&#034;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0s.generate(name&#061;&#034;second_response&#034;, max_tokens&#061;300)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0s.return_(s[&#034;second_response&#034;])<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0s.else_():<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0s.return_(s[&#034;first_response&#034;])<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u56db\u3001\u9002\u7528\u573a\u666f\u5206\u6790&#xff1a;\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u6846\u67b6<\/span><\/h3>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">4.1\u00a0\u4f18\u5148\u9009\u62e9\u00a0vLLM\u00a0\u7684\u573a\u666f<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u901a\u7528\u5927\u6a21\u578b\u670d\u52a1&#xff1a;\u9700\u8981\u652f\u6301\u591a\u79cd\u6a21\u578b&#xff0c;\u8ffd\u6c42\u90e8\u7f72\u7b80\u4fbf\u6027<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u9ad8\u5e76\u53d1\u00a0API\u00a0\u670d\u52a1&#xff1a;\u5982\u804a\u5929\u673a\u5668\u4eba\u540e\u7aef&#xff0c;\u4fa7\u91cd\u63d0\u5347\u541e\u5410\u91cf<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u8d44\u6e90\u53d7\u9650\u73af\u5883&#xff1a;\u9700\u8981\u5728\u6709\u9650\u00a0GPU\u00a0\u5185\u5b58\u4e0b\u8fd0\u884c\u8f83\u5927\u6a21\u578b<\/span><\/p>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">4.2\u00a0\u4f18\u5148\u9009\u62e9\u00a0SGLang\u00a0\u7684\u573a\u666f<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u590d\u6742\u4ea4\u4e92\u7cfb\u7edf&#xff1a;\u5982\u591a\u8f6e\u5bf9\u8bdd\u3001\u5de5\u5177\u8c03\u7528\u3001\u667a\u80fd\u4ee3\u7406&#xff08;Agent&#xff09;<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u957f\u4e0a\u4e0b\u6587\u63a8\u7406&#xff1a;\u5904\u7406\u8f93\u5165\u957f\u5ea6\u8d85\u8fc7\u00a04096\u00a0\u7684\u573a\u666f&#xff08;\u5982\u6587\u6863\u5206\u6790&#xff09;<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u5b9a\u5236\u5316\u5de5\u4f5c\u6d41&#xff1a;\u9700\u8981\u5d4c\u5165\u4e1a\u52a1\u903b\u8f91\u7684\u63a8\u7406\u6d41\u7a0b<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u591a\u6a21\u6001\u6269\u5c55&#xff1a;\u8ba1\u5212\u96c6\u6210\u56fe\u50cf\u3001\u8bed\u97f3\u7b49\u591a\u6a21\u6001\u80fd\u529b<\/span><\/p>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u4e94\u3001\u6df1\u5ea6\u6280\u672f\u5dee\u5f02&#xff1a;\u6027\u80fd\u4f18\u5316\u539f\u7406<\/span><\/h3>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">5.1 KV\u00a0\u7f13\u5b58\u7ba1\u7406\u673a\u5236<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">vLLM\u00a0\u7684\u00a0PagedAttention\u00a0\u901a\u8fc7\u5c06\u00a0KV\u00a0\u7f13\u5b58\u5212\u5206\u4e3a\u00a064KB\u00a0\u7684\u5757&#xff0c;\u5b9e\u73b0\u4e86\u975e\u8fde\u7eed\u5185\u5b58\u7684\u9ad8\u6548\u7ba1\u7406&#xff0c;\u5185\u5b58\u5229\u7528\u7387\u6bd4\u4f20\u7edf\u65b9\u6cd5\u63d0\u5347\u00a030-50%\u3002\u5f53\u5904\u7406\u52a8\u6001\u957f\u5ea6\u8f93\u5165\u65f6&#xff0c;\u53ef\u907f\u514d\u56e0\u5e8f\u5217\u957f\u5ea6\u53d8\u5316\u5bfc\u81f4\u7684\u5185\u5b58\u91cd\u5206\u914d\u5f00\u9500\u3002<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">SGLang\u00a0\u5219\u91c7\u7528\u9759\u6001\u9884\u5206\u914d\u00a0&#043;\u00a0\u6307\u4ee4\u6d41\u590d\u7528\u7b56\u7565&#xff0c;\u5728\u542f\u52a8\u65f6\u6839\u636e\u6700\u5927\u5e8f\u5217\u957f\u5ea6\u9884\u5206\u914d\u00a0KV\u00a0\u7f13\u5b58&#xff0c;\u901a\u8fc7\u6307\u4ee4\u6d41\u89c4\u5212\u5b9e\u73b0\u7f13\u5b58\u5757\u7684\u9ad8\u6548\u590d\u7528&#xff0c;\u5728\u56fa\u5b9a\u573a\u666f\u4e0b\u5185\u5b58\u8bbf\u95ee\u5ef6\u8fdf\u6bd4\u00a0vLLM\u00a0\u4f4e\u00a015-20%\u3002<\/span><\/p>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">5.2\u00a0\u6279\u5904\u7406\u8c03\u5ea6\u7b56\u7565<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">vLLM\u00a0\u7684\u8fde\u7eed\u6279\u5904\u7406&#xff08;Continuous Batching&#xff09;\u5141\u8bb8\u65b0\u8bf7\u6c42\u63d2\u5165\u5230\u6b63\u5728\u5904\u7406\u7684\u6279\u6b21\u4e2d&#xff0c;\u5f53\u67d0\u4e2a\u8bf7\u6c42\u5b8c\u6210\u540e\u7acb\u5373\u91ca\u653e\u8d44\u6e90&#xff0c;\u89e3\u51b3\u4e86\u4f20\u7edf\u9759\u6001\u6279\u5904\u7406\u4e2d\u00a0&#034;\u6700\u6162\u8bf7\u6c42\u51b3\u5b9a\u6279\u6b21\u901f\u5ea6&#034;\u00a0\u7684\u95ee\u9898&#xff0c;\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u541e\u5410\u91cf\u63d0\u5347\u00a02-3\u00a0\u500d\u3002<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">SGLang\u00a0\u91c7\u7528\u6307\u4ee4\u6d41\u4f18\u5148\u7ea7\u8c03\u5ea6&#xff0c;\u6839\u636e\u6307\u4ee4\u7c7b\u578b&#xff08;\u751f\u6210\u00a0\/\u00a0\u63a8\u7406\u00a0\/\u00a0\u5de5\u5177\u8c03\u7528&#xff09;\u52a8\u6001\u8c03\u6574\u8ba1\u7b97\u8d44\u6e90\u5206\u914d&#xff0c;\u5728\u6df7\u5408\u5de5\u4f5c\u8d1f\u8f7d\u573a\u666f\u4e0b&#xff08;\u5982\u540c\u65f6\u5904\u7406\u751f\u6210\u548c\u5de5\u5177\u8c03\u7528&#xff09;&#xff0c;\u54cd\u5e94\u5ef6\u8fdf\u6bd4\u00a0vLLM\u00a0\u964d\u4f4e\u00a020-30%\u3002<\/span><\/p>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u516d\u3001\u603b\u7ed3\u4e0e\u672a\u6765\u5c55\u671b<\/span><\/h3>\n<p style=\"text-align:start\"><span style=\"color:#000000\">vLLM\u00a0\u51ed\u501f\u00a0PagedAttention\u00a0\u548c\u8fde\u7eed\u6279\u5904\u7406\u6280\u672f&#xff0c;\u5728\u901a\u7528\u573a\u666f\u4e0b\u63d0\u4f9b\u4e86\u4f18\u5f02\u7684\u6027\u80fd\u548c\u90e8\u7f72\u4fbf\u6377\u6027&#xff0c;\u9002\u5408\u4f5c\u4e3a\u9ad8\u6027\u80fd\u00a0API\u00a0\u670d\u52a1\u7684\u57fa\u7840\u6846\u67b6\u3002SGLang\u00a0\u5219\u901a\u8fc7\u6307\u4ee4\u6d41\u67b6\u6784&#xff0c;\u5728\u590d\u6742\u4ea4\u4e92\u573a\u666f\u4e2d\u5c55\u73b0\u51fa\u72ec\u7279\u4f18\u52bf&#xff0c;\u66f4\u9002\u5408\u6784\u5efa\u667a\u80fd\u5316\u3001\u5b9a\u5236\u5316\u7684\u5927\u6a21\u578b\u5e94\u7528\u3002<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u672a\u6765&#xff0c;\u4e24\u5927\u6846\u67b6\u7684\u6280\u672f\u8def\u7ebf\u53ef\u80fd\u4f1a\u51fa\u73b0\u878d\u5408&#xff1a;vLLM\u00a0\u53ef\u80fd\u589e\u5f3a\u5bf9\u590d\u6742\u63a7\u5236\u6d41\u7684\u652f\u6301&#xff0c;SGLang\u00a0\u53ef\u80fd\u501f\u9274\u00a0PagedAttention\u00a0\u7684\u52a8\u6001\u5185\u5b58\u7ba1\u7406\u673a\u5236\u3002\u5f00\u53d1\u8005\u5728\u9009\u62e9\u65f6&#xff0c;\u4e0d\u4ec5\u8981\u8003\u8651\u5f53\u524d\u7684\u6027\u80fd\u6307\u6807&#xff0c;\u8fd8\u9700\u7ed3\u5408\u5177\u4f53\u4e1a\u52a1\u573a\u666f\u7684\u957f\u671f\u9700\u6c42\u3002<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u5bf9\u4e8e\u8ffd\u6c42\u6781\u81f4\u6027\u80fd\u7684\u573a\u666f&#xff0c;\u5efa\u8bae\u901a\u8fc7\u5b9e\u9645\u8d1f\u8f7d\u8fdb\u884c\u57fa\u51c6\u6d4b\u8bd5&#xff08;Benchmark&#xff09;&#xff0c;\u91cd\u70b9\u5173\u6ce8\u4e0e\u4e1a\u52a1\u76f8\u5173\u7684\u6307\u6807&#xff08;\u5982\u957f\u4e0a\u4e0b\u6587\u5904\u7406\u80fd\u529b\u3001\u7279\u5b9a\u6a21\u578b\u7684\u517c\u5bb9\u6027\u7b49&#xff09;\u3002\u968f\u7740\u5927\u6a21\u578b\u63a8\u7406\u6280\u672f\u7684\u5feb\u901f\u6f14\u8fdb&#xff0c;\u5b9a\u671f\u8bc4\u4f30\u6700\u65b0\u7248\u672c\u7684\u6027\u80fd\u7279\u6027\u4e5f\u662f\u4fdd\u6301\u7cfb\u7edf\u7ade\u4e89\u529b\u7684\u5173\u952e\u3002<\/span><\/p>\n<p style=\"text-align:start\">ps&#xff0c;\u627e\u4e91\u670d\u52a1\u5668&#xff0c;8\u20e3\ufe0f\u6708\u4efd\u6709\u7f8a\u6bdb\u53ef\u4ee5\u8585yijiacloud.com.cn&#xff0c;\u6ce8\u518c\u5c31\u670950\u7b97\u529b\u91d1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb127\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u8fd1\u5e74\u6765\uff0c\u4ee5 SGLang \u548c vLLM \u4e3a\u4ee3\u8868\u7684\u65b0\u4e00\u4ee3\u63a8\u7406\u6846\u67b6\u51ed\u501f\u663e\u8457\u7684\u6027\u80fd\u4f18\u52bf\uff0c\u9010\u6e10\u6210\u4e3a\u5de5\u4e1a\u754c\u90e8\u7f72\u5927\u6a21\u578b\u7684\u9996\u9009\u5de5\u5177\u3002vLLM \u7684\u8fde\u7eed\u6279\u5904\u7406\uff08Continuous Batching\uff09\u5141\u8bb8\u65b0\u8bf7\u6c42\u63d2\u5165\u5230\u6b63\u5728\u5904\u7406\u7684\u6279\u6b21\u4e2d\uff0c\u5f53\u67d0\u4e2a\u8bf7\u6c42\u5b8c\u6210\u540e\u7acb\u5373\u91ca\u653e\u8d44\u6e90\uff0c\u89e3\u51b3\u4e86\u4f20\u7edf\u9759\u6001\u6279\u5904\u7406\u4e2d &quot;\u6700\u6162\u8bf7\u6c42\u51b3\u5b9a\u6279\u6b21\u901f\u5ea6&quot; \u7684\u95ee\u9898\uff0c\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u541e\u5410\u91cf\u63d0\u5347 2-3 \u500d\u3002\u673a\u5236\uff0c\u501f\u9274\u4e86\u64cd\u4f5c\u7cfb\u7edf\u7684\u865a\u62df\u5185\u5b58\u5206\u9875\u601d\u60f3\uff0c\u5c06 KV \u7f13\u5b58\uff08Key-Value Cache\uff09\u5212\u5206\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u5757\uff08Block\uff09\uff0c\u901a\u8fc7\u5757\u7ba1\u7406\u5668\u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u5206\u914d\u4e0e\u590d\u7528\u3002<\/p>\n","protected":false},"author":2,"featured_media":53773,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1646,208,50,227,86],"topic":[],"class_list":["post-53774","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-gpt","tag-gpu","tag-50","tag-227","tag-86"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/53774.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb127\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u8fd1\u5e74\u6765\uff0c\u4ee5 SGLang \u548c vLLM \u4e3a\u4ee3\u8868\u7684\u65b0\u4e00\u4ee3\u63a8\u7406\u6846\u67b6\u51ed\u501f\u663e\u8457\u7684\u6027\u80fd\u4f18\u52bf\uff0c\u9010\u6e10\u6210\u4e3a\u5de5\u4e1a\u754c\u90e8\u7f72\u5927\u6a21\u578b\u7684\u9996\u9009\u5de5\u5177\u3002vLLM \u7684\u8fde\u7eed\u6279\u5904\u7406\uff08Continuous Batching\uff09\u5141\u8bb8\u65b0\u8bf7\u6c42\u63d2\u5165\u5230\u6b63\u5728\u5904\u7406\u7684\u6279\u6b21\u4e2d\uff0c\u5f53\u67d0\u4e2a\u8bf7\u6c42\u5b8c\u6210\u540e\u7acb\u5373\u91ca\u653e\u8d44\u6e90\uff0c\u89e3\u51b3\u4e86\u4f20\u7edf\u9759\u6001\u6279\u5904\u7406\u4e2d &quot;\u6700\u6162\u8bf7\u6c42\u51b3\u5b9a\u6279\u6b21\u901f\u5ea6&quot; \u7684\u95ee\u9898\uff0c\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u541e\u5410\u91cf\u63d0\u5347 2-3 \u500d\u3002\u673a\u5236\uff0c\u501f\u9274\u4e86\u64cd\u4f5c\u7cfb\u7edf\u7684\u865a\u62df\u5185\u5b58\u5206\u9875\u601d\u60f3\uff0c\u5c06 KV \u7f13\u5b58\uff08Key-Value Cache\uff09\u5212\u5206\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u5757\uff08Block\uff09\uff0c\u901a\u8fc7\u5757\u7ba1\u7406\u5668\u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u5206\u914d\u4e0e\u590d\u7528\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/53774.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-12T08:39:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812083943-689afdcf13744.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/53774.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/53774.html\",\"name\":\"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-12T08:39:44+00:00\",\"dateModified\":\"2025-08-12T08:39:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/53774.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/53774.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/53774.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/53774.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb127\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u8fd1\u5e74\u6765\uff0c\u4ee5 SGLang \u548c vLLM \u4e3a\u4ee3\u8868\u7684\u65b0\u4e00\u4ee3\u63a8\u7406\u6846\u67b6\u51ed\u501f\u663e\u8457\u7684\u6027\u80fd\u4f18\u52bf\uff0c\u9010\u6e10\u6210\u4e3a\u5de5\u4e1a\u754c\u90e8\u7f72\u5927\u6a21\u578b\u7684\u9996\u9009\u5de5\u5177\u3002vLLM \u7684\u8fde\u7eed\u6279\u5904\u7406\uff08Continuous Batching\uff09\u5141\u8bb8\u65b0\u8bf7\u6c42\u63d2\u5165\u5230\u6b63\u5728\u5904\u7406\u7684\u6279\u6b21\u4e2d\uff0c\u5f53\u67d0\u4e2a\u8bf7\u6c42\u5b8c\u6210\u540e\u7acb\u5373\u91ca\u653e\u8d44\u6e90\uff0c\u89e3\u51b3\u4e86\u4f20\u7edf\u9759\u6001\u6279\u5904\u7406\u4e2d &quot;\u6700\u6162\u8bf7\u6c42\u51b3\u5b9a\u6279\u6b21\u901f\u5ea6&quot; \u7684\u95ee\u9898\uff0c\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u541e\u5410\u91cf\u63d0\u5347 2-3 \u500d\u3002\u673a\u5236\uff0c\u501f\u9274\u4e86\u64cd\u4f5c\u7cfb\u7edf\u7684\u865a\u62df\u5185\u5b58\u5206\u9875\u601d\u60f3\uff0c\u5c06 KV \u7f13\u5b58\uff08Key-Value Cache\uff09\u5212\u5206\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u5757\uff08Block\uff09\uff0c\u901a\u8fc7\u5757\u7ba1\u7406\u5668\u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u5206\u914d\u4e0e\u590d\u7528\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/53774.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-12T08:39:44+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812083943-689afdcf13744.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/53774.html","url":"https:\/\/www.wsisp.com\/helps\/53774.html","name":"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-12T08:39:44+00:00","dateModified":"2025-08-12T08:39:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/53774.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/53774.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/53774.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5927\u6a21\u578b\u63a8\u7406\u6846\u67b6\u5bf9\u6bd4\uff1aSGLang \u4e0e vLLM \u7684\u6838\u5fc3\u5dee\u5f02"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/53774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=53774"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/53774\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/53773"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=53774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=53774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=53774"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=53774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}