I was looking up how large models like DeepSeek answer questions using several graphics cards. Computing an answer from an input with a trained model is inference. The fastllm introduction promised “single-card inference with the full DeepSeek R1 671B model,” and I saw an account of deploying DeepSeek with KTransformers and one 24 GB 4090. My actual search was “why can fastllm run full-strength on one card.” 671B means the model has about 671 billion trained numbers. A 4090 has only 24 GB of memory dedicated to the graphics card, or VRAM. It cannot hold the entire model. The single-card setups here also use the host's central processing unit (CPU) and system memory. During generation the CPU can read model weights directly from system memory, multiply with them and return results to the graphics processor (GPU). As the model continues writing, which step runs where? 123
From pressing Send to seeing “blue,” what does the model do?
Suppose you type an unfinished sentence, “我把盒子涂成” (I painted the box…), and the model completes it with “蓝色” (blue). The text you give it is a prompt. A model reads text in small units called tokens. Each may be a character, word or word fragment. To follow the diagrams, suppose the input is five tokens “我 / 把 / 盒子 / 涂 / 成” and the two generated tokens are “蓝” then “色.”
- How does it produce the first “蓝”? The five input tokens are known, so the model can process several in the same computation. At the end it computes probabilities for possible next tokens, and the system selects “蓝” as the first output. Reading the input and preparing the first output is prefill. The same model generally takes longer to start answering a page of text than this one sentence. 4
- How does it then write “色”? The just-selected “蓝” is now part of the preceding text. It becomes the new input for this step, and the model uses it together with the unfinished sentence to select “色.” If generation continues, “色” becomes the next input. Extending the previous result like this is decoding. Once the answer begins, this stage largely determines how quickly more text appears. 45
sequenceDiagram
participant U as 聊天窗口
participant M as 模型
U->>M: 发送“我把盒子涂成”
Note over M: 预填充:读完五个词元,选出“蓝”
M-->>U: 显示“蓝”
Note over M: 解码:接着“蓝”,选出“色”
M-->>U: 追加“色”,屏幕上成为“蓝色”
Figure 1. Read down the diagram for two waits. After Send you wait for the first token. From “蓝” to “蓝色” you wait for the model to generate the next token.4
When writing “色,” does the model compute all the earlier words again? Imagine each earlier position has an index card with a key and retrievable content. When processing a new word, compare its query against each card's key, then take a different proportion of each card's content according to the match. This computation, looking back and using information in proportion, is attention. The query (Q), index key (K) and content value (V) are each a sequence of numbers produced by the model, called a vector. Retaining K and V at each position for later steps gives the key-value cache (KV cache). 56
Back to “我把盒子涂成蓝.” When processing “蓝,” the model sees six positions. In one layer, it can use several sets of queries, keys and values, each looking back over the sentence. Each set is an attention head. Two heads are drawn here. Follow the two thickest arrows from “蓝” and see which word each targets.
Figure 2. Each set of arrows sums to 100%. Thicker lines mean larger weights for that position. “蓝” can attend to itself. In the lower half, each new token adds one cache slot. The figure uses ordinary multi-head attention with illustrative tokenization, proportions and vectors.56
How does K decide where to look? Follow head 1's arrow from “蓝” to “盒子.” It compares the Q for “蓝” against K at all six positions, including the cached K [0.2, 0.8] for “盒子.” Converting all six match scores to proportions gives “盒子” 56% in this example. Head 2 has its own Q and K. Its largest weight, 42%, goes to “涂.” 6
What does V contribute? Follow the same arrow for head 1. Given the 56% share, it reads the V [0.6, 0.4] for “盒子,” multiplying each entry by 0.56 to get [0.336, 0.224]. Each of the five other positions similarly scales its V by its own proportion. Add the six resulting vectors elementwise to get the information head 1 draws from this sentence. The model combines the heads' results and continues computing the next token. 6
Which work does caching save? Compare “processing 蓝” and “processing 色.” At “蓝,” heads read K and V directly for the five earlier positions and compute and store only one new pair for “蓝.” When “色” becomes the input, the yellow “蓝” slot has become a gray-green directly readable slot. With the new query for “色,” each head recalculates percentages across seven positions including “色” itself. The previous 56% is finished, but the K and V for “盒子” remain reusable. 5
Prefill and decode are consecutive phases. The KV cache is data left by the first phase and read and extended by the second. Longer conversations generally require more retained positions. DeepSeek can also store each position's record in compressed form and use it to attend to the preceding text in the next generation step. 5
Of 671 billion parameters, how many does one token use?
The KV cache we just computed belongs to this particular conversation. With another user and question, a different set of numbers is still needed: parameters learned during training, commonly called weights. At four bits per parameter and eight bits per byte, weights alone need 671 billion × 4 ÷ 8 = 335.5 billion bytes, about 336 GB. Approximating weights with fewer bits is quantization. Real files also record how to reconstruct groups of values and may preserve more precision for some weights. The 336 GB figure is an estimate. Runtime also needs cache and temporary workspace. “Full-strength” here means the 671B-scale R1. It can use quantized weights. Officially released 7B, 32B and other distilled models were trained on the bigger model's answers and have far fewer parameters of their own. 71
Which weights a card must hold depends on its responsibilities. Consider the step after “蓝,” predicting “色.” A sequence of numbers represents “蓝” and its preceding context and passes through many computation layers. In a mixture-of-experts (MoE) layer, many modules can transform those numbers, each with its own weights. Each module is an expert. A small module first scores the candidates and selects a few for this step, called routing. The next layer selects again, and the next token may choose another set. 78
DeepSeek reports 671B total parameters and about 37B active per token for R1. The 37B includes experts and other modules used along that token's path. A deployment needs somewhere for all selectable experts to live, but computing the current token reads only some of them. 7
Searching for “why mixture of experts is sparse,” I read an article about model compression. It gave two examples: setting many weights to zero directly is pruning. Here experts can each keep complete weights, with a token skipping just the unselected experts. The next token might use an expert that was just skipped. 9
Suppose this layer has four candidate experts A, B, C and D. After the GPU selects B and D for “蓝,” the CPU multiplies directly using their weights in system memory. The two arrows in Figure 3 show what crosses between graphics card and host in this step. 103
sequenceDiagram
participant G as 4090 与显存
participant C as CPU 与系统内存
Note over G: 路由器权重在显存
Note over C: 专家 A、B、C、D 的权重在内存
Note over G: 为“蓝”选中 B 和 D
G->>C: “蓝”的数字表示、专家编号、混合比例
Note over C: 读 B、D 的权重,计算并加权合并
C-->>G: 合成后的词元表示
Note over G: 继续算下一层
Figure 3. The decode-stage division of labor in one DeepSeek KTransformers configuration. Only four candidates are drawn for clarity. B's and D's weights stay in system memory throughout the step.103
Do fastllm, KTransformers, llama.cpp and vLLM need to run together?
Searching fastllm turned up a guide comparing it with llama.cpp and vLLM. The single-card R1 write-up mentioned KTransformers too. First distinguish the model from the tools. DeepSeek-R1 is a trained model. All four projects provide ways to run models, and a deployment typically starts with one. Then prepare weights in a format it reads and specify how CPU and GPU participate. 1112
| Project | What does it manage in this deployment? |
|---|---|
| llama.cpp | Reads GGUF directly, a format holding weights and model metadata. On a machine with CPU and discrete GPU, a common split is by layer: compute some on the CPU and give as many as fit to the GPU. 13 |
| fastllm | Has its own C++ inference engine, started with ftllm run. Besides the normal device, it can separately select a compute device for experts. The July 2025 DeepSeek guide listed supported weight formats. Direct GGUF loading was not available then. 112 |
| KTransformers | Reuses model structures from Hugging Face Transformers and replaces selected modules with optimized implementations at load time. The R1 local tutorial at the time read GGUF weights and could send the same experts to different devices during prompt reading and token-by-token generation. 141012 |
| vLLM | Also starts an inference service directly. With several users it can reform the batch each round: when A finishes, C can join the next batch still generating for B. It stores each conversation's KV cache in blocks and allocates new VRAM blocks as the conversation grows. 15 |
There is some actual code reuse. KTransformers includes llama.cpp as a submodule and builds it when compiling its own computational extensions. The user starts KTransformers, which selects modules and devices. No separate llama.cpp service is needed. In this investigation fastllm and KTransformers are two solutions to the same deployment problem. Both can run experts on the CPU where their weights reside, using their own launch interfaces and work allocation. 1612
Where do fastllm and KTransformers send the same token?
Keep B and D, the experts chosen for “蓝” in Figure 3. This model also has shared experts that every token passes through. We'll follow only B and D, the experts chosen by routing. 8
In 2023 BBuf published a fastllm walkthrough using ChatGLM-6B to demonstrate two steps: export model configuration, vocabulary and weights into a file, then have fastllm load it and call compute code suitable for the CPU or GPU. Applied to R1, the question becomes concrete: B and D are in the model file. Who reads them at runtime? 17
How does fastllm specify where experts compute?
The July 2025 version has two complementary parameters, --device cuda --moe_device cpu. The first puts regular computation on the NVIDIA GPU (cuda), the second specifies CPU for expert computation. The DeepSeek implementation scores experts on the regular device, switches to the expert device, passes layer input and routing scores to the expert calculation, then switches back to incorporate results. For “蓝,” the CPU can multiply with B's and D's weights directly in system memory while the GPU waits for that layer's result. If CPU weight reads are slow, the same 4090 can generate at different speeds in two hosts. 118
How does KTransformers decide which computations to offload to the CPU?
After reading how KTransformers places attention and experts separately, I searched “how does ktransformer determine its memory offloading policy.” If the same host swaps its 24 GB card for a larger one, does the program automatically move more experts to it? 1920
The July 2025 local chat program accepts a rules file via --optimize_config_path. Without it, the program looks up a default by model architecture. For example, DeepSeek-V3 maps to DeepSeek-V3-Chat.yaml. If no entry exists, it asks for a path. With defaults, the same model still selects the same rules after a card swap. 14
In the default file, find the entry for the routed experts. Three fields connect the steps in Figure 3. 10
| Setting in the expert entry | When does it apply in “我把盒子涂成蓝”? |
|---|---|
prefill_device: "cuda" | When reading “我把盒子涂成” and preparing “蓝,” the GPU computes the chosen experts. |
generate_device: "cpu" | When processing “蓝” to predict “色,” the CPU reads B's and D's weights and performs the expert multiplications. |
out_device: "cuda" | The CPU combines B's and D's results in proportion and sends them back to the GPU for subsequent work. |
The router scores a token when it arrives to choose experts. The rules decide where those experts compute when the model loads. In these rules the GPU computes both attention, which consults earlier text, and the router, which selects experts, in both phases. 103
Another technique also called “offload” transfers weights instead. Optimizing LLM inference with limited VRAM: Offload techniques describes DeepSpeed's ZeRO-Inference: keep all weights in host memory or on SSD, stream one layer's weights to the GPU when its turn comes, then keep the output and free VRAM for later layers. When reading “offload to CPU,” ask whether the CPU stores data for the GPU or actually takes over multiplication as with B and D above. 21 Worked transfer examples for both offload methods
| Reading a deployment configuration | fastllm single-card plus CPU example | This KTransformers DeepSeek rule |
|---|---|---|
| Where is the work split defined? | Launch options --device and --moe_device | prefill_device, generate_device, out_device in the expert entry |
| Who computes routed experts while reading the prompt? | CPU according to the example's expert device setting | GPU |
| During token-by-token generation? | CPU computes experts and returns results to the regular device | CPU computes experts and returns results to the GPU |
Each column describes one particular configuration. Changing fastllm's expert device, for example, changes the first column's answers. 110
What should get priority in a 4090's VRAM?
Suppose the goal is one person chatting with R1, keeping the whole conversation readable and reducing the wait for each new token. With the KTransformers configuration above, budget for three things:
| VRAM allocation | Why keep it on the card? |
|---|---|
| Attention, router and other GPU-resident weights | At every layer the GPU reads attention weights to consult earlier text. At expert layers it also scores candidates. This configuration puts the final output layer that scores next tokens on the GPU too. Weights at the compute location can be read repeatedly across rounds. 22 |
| KV cache for the current conversation | A different user shares the weights but needs their own preceding-text record. A long chat accumulates more records, and simultaneous users each need space. This configuration runs attention on the GPU, so keeping active conversation records in VRAM permits local reads. 2215 |
| Temporary compute and transfer space | During prefill the GPU holds intermediate results for the batch. During decoding it receives expert outputs from the CPU. Allow headroom for peak runtime use. Space can be reused afterward. 213 |
Whether remaining VRAM is worth using for experts depends on how much waiting that saves per token. In this configuration the CPU reads routed expert weights in RAM. Even if B is selected again in Figure 3, only token representation, expert IDs, mixing proportions and results must travel. If the engine can pin some experts to the GPU, inspect how often experts are selected by your requests and how long the GPU actually waits while the CPU computes them. Then consider trading VRAM for that time. Shared experts participate every step and are worth evaluating. Being used every step alone doesn't settle it: this configuration keeps the input vocabulary table on the CPU. Each input token needs just one corresponding row from that large table. 822
For instance, if 1 GB VRAM is free and the next long conversation needs exactly another 1 GB of cache, reserve that space for cache. If you normally run short conversations with plenty of cache and workspace, then try a different split. Fix model, quantization, input and output lengths and measure time to first token separately from time between subsequent tokens. The first more readily reveals prefill changes. The second tells whether generation actually sped up. 23
What if weights are INT8? At one byte each, 671 billion parameters need roughly 671 GB (625 GiB) for raw weights, before quantization scales and other overhead. Even dedicating all 24 GB VRAM to weights fits only about 3.6%. Reserve space first for target context length, concurrent request caches and prefill peak. Compare two uses for the rest: putting frequently selected, GPU-computable experts there, or increasing prompt batch size. Measure per-step decode waiting saved for the former and time to read the same prompt for the latter.
A transfer calculation explains why CPU multiplication sometimes pays off. Suppose an expert needs 100 MB of weights and effective CPU-to-GPU bandwidth is 20 GB/s. Transferring the weights costs 5 ms by itself. Keep them in RAM and compute on the CPU instead. With 4,096 two-byte elements each for input and output, total payload is 16 KiB round trip, or about 0.82 microseconds at that bandwidth. Small messages also have fixed startup costs, and the CPU needs time to read weights and multiply. Compare total waits: “5 ms plus GPU computation” versus “two transfers plus CPU computation.” If another batch can overlap, count only time blocking the next step. With 5 ms of transfer and only 2 ms of overlapping work per batch, even ideal overlap leaves at least 3 ms exposed. These figures illustrate scale. Actual expert size, batch reuse and machine bandwidth require measurement.
📓 Note Can experts be offloaded to an NVMe SSD? In the July 2025 local chat path, GGUF weights can reside on an SSD. The loader maps the file into the process address space with
np.memmap, and CPU experts receive the memory addresses of their weights. The OS can page missing data in from disk. If active pages do not fit, computations may repeatedly wait for disk. These DeepSeek rules list CPU and GPU execution devices, and the source offers no per-expert SSD capacity, prefetch order or eviction policy for this path. To estimate interactive generation speed, still size system RAM for the active weights.2410
Which numbers belong together in a “single 4090” result?
The KTransformers tutorial used Q4_K_M, a mostly four-bit format keeping some weights at higher precision. The project lists “14GB VRAM and 382GB DRAM” for this 671B version. The first is graphics memory, the second system memory. The 0.2.1 benchmark table describes a 24 GB 4090 and two Xeon Gold 6454S processors with 32 cores each, a dual-socket machine. The docs list 382 GB system RAM for single socket and 1 TB for dual socket. 23
ToTensor's 14 GB VRAM write-up starts by inspecting the host with Linux lscpu. Its Socket(s) counts physical CPU sockets and NUMA node(s) counts memory access regions. Why distinguish them? On the project's dual-socket machine, each CPU has easier access to nearby memory. To reduce cross-region reads the project kept a copy of key matrices on each side, trading more memory for faster local access. When comparing two hosts, record CPU count and memory layout alongside the graphics card. 25
Back to the on-screen experience: the table contains two “tokens per second” figures. The project warmed up DeepSeek-V3 quantized to Q4_K_M and timed it once the service was ready. It supplied 969 input tokens and requested 300 output tokens, selecting eight routed experts per token. Read the columns separately. 23
| Benchmark metric | What it counts | What you see in the answer |
|---|---|---|
| Prefill, 88.2 tokens/s | Input tokens read per second. | At that average, 969 input tokens take about 11 seconds. Actual time to first output can include queueing and other overhead. |
| Decode, 13.5 tokens/s | Subsequent output tokens generated per second once the answer begins. | About one new token every 74 milliseconds on average. Tokens and Chinese characters need not match one-to-one. |
Another easily misread entry in the same column is 15.9 tokens/s. The project labels that row a six-expert preview. Each token uses six routed experts and does less work than the eight-expert run. To estimate the original split's speed, read 13.5 from the eight-expert row. Both measurements used V3. 23
While investigating fastllm I opened an 爱吱声 thread titled “Running DeepSeek R1 671B Q5 for a thousand dollars.” For fastllm speed go to post 46, where the author 孟词宗 switched to DeepSeek-R1-0528-INT4, the four-bit version of the May 28 R1 update. They reported a maximum of 5–6 tokens/s on the thousand-dollar workstation, adding: “不过Context稍微长点就降到只有 2t/s 左右了。” With a slightly longer context, it dropped to about 2 t/s. Context is the preceding text processed in that round, so that's roughly two generated tokens per second. The report gives the peak and a slowdown condition without specifying the corresponding context length. 26
The same post described a Core Ultra 9 285K, 256 GB RAM and a 16 GB RTX 5060 Ti. The author reported about 2 tokens/s for the same INT4 model on fastllm and added in post 48 that context was only 4K, roughly four thousand tokens. The stated model file was 331 GB, larger than the machine's combined 256 GB RAM and 16 GB VRAM. The author mentioned an SSD but did not record how much weight data generation read from disk. Read the 2 tokens/s alongside the full machine configuration and context length. 26
If experts are split between two GPUs, where does one token go?
Consider a different deployment. Suppose A and B in this layer reside on card one, C and D on card two. “蓝” is on card one and again selects B and D. The first card computes B directly and sends the token representation to card two. Card two computes D with its resident weights and returns the result. The results are combined in proportion. If the next selection is A and B, both computations can remain on card one in this example. Distributing whole experts across devices is expert parallelism (EP). Two cards illustrate communication within this layer. The full 671B weights still need sufficient capacity. 8
sequenceDiagram
participant G0 as GPU 0(专家 A、B)
participant G1 as GPU 1(专家 C、D)
Note over G0: 为“蓝”选中 B 和 D
par 本卡路径
G0->>G0: 用 B 的权重计算,保留结果
and 跨卡路径
G0->>G1: 发出“蓝”的数字表示
G1->>G1: 用 D 的权重计算
G1-->>G0: 返回 D 的结果
end
Note over G0: 两份结果到齐,按路由比例合并
Figure 4. The same two-of-four selection using two-card expert parallelism. Follow the arrows crossing the lanes: the token representation goes out and D's result returns. The two results meet on GPU 0.8
D itself needs many multiplications. Its weights form a table of numbers called a matrix. Suppose D computes four outputs. Have each of two cards compute two outputs from the required weights, then assemble all four. This way of splitting a single matrix multiplication across cards is tensor parallelism (TP). The previous question was “which card holds D, and how do we send it the input?” This one asks “which part of D's multiplication does each card compute?” Worked example of tensor-parallel multiplication
If expert D itself spans two cards, who receives “蓝”? In a discussion of Figure 7 of the DeepSpeed-MoE paper, marsggbo used 16 GPUs. Start with the experts: eight experts each occupy a pair of cards. If “蓝” selects D, send its input to D's pair. Each holds part of D's weights, and together they compute D's result for “蓝.” There are two levels of work sharing: eight groups across experts and two cards cooperating within each. 27 DeepSpeed's official inference tutorial calls splitting one expert's weights expert-slicing. In its example, when GPUs outnumber experts the engine uses this to share one expert across several GPUs. 28
For nonexpert modules the same 16 cards can regroup: four cards cooperate on a copy, with four groups handling different inputs. This is the DeepSpeed-MoE example layout. DeepSeek-V3 also combines strategies. Its report describes four-way tensor parallelism for attention and 32-way expert parallelism for experts during prefill. 278
Back to Figure 4. For one chat, the current token waits for both B and D before entering the next layer. Even if card two has spare capacity, a slow return from D still delays this person. With many users, suppose 16 tokens reach the step and six select D. Card two can batch those six inputs and multiply using the same D weights. That can increase throughput, the total tokens processed per second across the service. If most inputs concentrate on one card, the others still wait. 8
Multiple requests also create opportunities to overlap waiting and computation. A Huxiu series on Huawei technology describes computing experts for one token group while scoring experts for another and transferring a third between cards. For example, once card two starts D for user A, card one can send data for user B. A still waits for their result, but there is less time when everyone waits for transfer. DeepSeek-V3's prefill deployment likewise schedules attention and expert computation for one batch while another distributes inputs and gathers results. 298
Why can one person's long prompt pause someone else's answer?
Suppose A's answer is halfway generated when B sends a long document. A is waiting for the next token, while B must first read its entire input. If both share a set of cards, processing B's prompt can delay A's next step. An Ascend deployment article describes dedicating one server group to new prompts (P) and another to generating tokens for existing requests (D). P is prefill, D decode. Assigning servers by phase is prefill/decode disaggregation. Its 16-server example groups eight servers into four P instances, and the other eight into one D instance. An instance here is a group of servers cooperating on a phase. Each instance can still place different experts on different cards internally. 4
At handoff, telling the next server “the first character is 蓝” isn't enough. To use “蓝” to predict “色,” it needs the preceding half-sentence too. The P server has already computed its KV cache. Transfer the cache to the D server and it can continue from the “蓝” step. 30
sequenceDiagram
participant P as P 服务器(读输入)
participant D as D 服务器(续写)
par 乙的预填充
Note over P: 读乙的长文,建立乙的缓存
and 甲的解码
Note over D: 甲的回答继续出字
end
P->>D: 交接乙的前文缓存和首个词元
Note over D: 用乙的缓存,为乙续写
Figure 5. Handoff between the two server groups. While A reads an answer, P can begin processing B's input. The arrow crosses machines and B's cache travels over the network.430
The longer B's document is, the more data the handoff usually transfers. Separation can reduce A's wait for its next token, but the time for B's cache to cross the network also counts. 430
Later I searched “building a parallel inference workstation” and read a thread on multi-GPU motherboards. The poster initially wanted three 3060s and one 3090 in one machine, using small models to screen documents and a large model to answer. They later bought two used workstations and intended them to take tasks from one queue. In that arrangement each card can do a separate job. Splitting one model's experts across two cards, as above, instead requires exchanges for the same token. 31
In the same search, UltraLAB listed a four-card workstation with 24 GB per 4090. The advertised 96 GB was the sum. A Juejin proposal listed eight 24 GB 4090D cards, totaling 192 GB, plus 512 GB system RAM. Compared with the roughly 336 GB four-bit weights above, even eight cards dedicated to weights still leave some outside the cards. The article also mentioned using Ray to allocate compute to multiple tasks. For training on the same cards, see how two training processes each use a GPU and synchronize gradients. For a single answer, which experts compute in RAM still depends on the engine's work allocation. 3233
How do several machines answer the same request together?
Alpa's official inference tutorial gives an example. OPT-175B is a dense language model with 175 billion parameters. Every token passes through the feedforward network in each layer without selecting experts. At the tutorial's two bytes per parameter, the weights alone are about 350 GB. It uses four machines with eight 16 GB cards each, totaling 512 GB VRAM. A single card still has only 16 GB, so the model must be split and each card computes part of it. 34
First convert the weights so each machine can read them from a shared directory or local disk. Ray registers all GPUs into one cluster, and Alpa plans parallel work using the model and devices. The web service can batch several prompts and send them to the model process, where multiple cards cooperate on the next token and continue generation. Every machine having access to the full weight files tells us where it reads weights. Which part each card computes for one answer follows the partition plan. 34 For how to choose that split, the tensor-parallelism article uses Alpa's original training experiments to explain cross-machine transfer costs. 35
PCIe can also support multi-GPU inference. How far it trails NVLink depends on the deployment. Both are interconnects inside a machine. Himesh Prasad fixed each RTX 3090 at 220 W on one workstation, ran Qwen2.5-7B tensor-parallel with vLLM and sent 200 random requests. In the tables comparing configurations with and without NVLink, dual-card generation rose from 483 to 715 tokens/s, around 48%. Four cards went from 490 to 535, around 9%. The four cards formed two pairs with cross-pair traffic still on PCIe 4.0 ×8. The commands also changed NCCL peer-to-peer settings. These figures measure the whole communication path and service throughput. The 48% cannot directly predict per-token latency for a 4090 plus CPU. 36
To estimate network saturation across machines, first calculate bytes sent per second. Suppose node A handles 20,000 tokens/s. Each crosses eight layers needing remote experts, each layer sends two inputs to B, and each input contains 4,096 two-byte elements. Counting only A-to-B input gives 20,000 × 8 × 2 × 4,096 × 2 ≈ 2.62 GB/s, or about 21 Gbit/s. If return vectors are equally long, the reverse link carries the same traffic. Check each direction separately on full-duplex interfaces. Under these assumptions even average outbound traffic exceeds 10 Gbit/s. Even with sufficient average bandwidth, several batches hitting one node simultaneously can queue. If the engine combines copies headed to the same node into one transfer, recalculate using copies actually crossing the interface. 8
When placing work, count communication events first. Tensor parallelism requiring partial sums to combine every layer is usually first tried on fast intra-node links. Pipelining consecutive layers can limit network crossings to stage boundaries, but needs enough batches to keep stages busy. If each node fits the full model, nodes can also serve requests independently. For expert parallelism, measure how many tokens routing actually sends off the machine. Compare layouts with fixed model, lengths and concurrency, recording traffic in both directions, first-token wait and subsequent token intervals to see where a faster link is worthwhile. 358
For one local chat, first check that the whole machine fits expert weights, then measure tokens/s for its particular CPU and GPU. For a multi-user service, also see whether aggregate throughput increases with requests. When selecting a multi-card motherboard, ask which interconnect carries the input to expert D and its returned result in the two-card example. Memory capacity, one person's waiting time and the speed of answers for the whole batch are three distinct questions the same deployment should answer. 8
References
Footnotes
-
ztxz16 & fastllm contributors. (2025, July 9). fastllm [源代码与文档]. GitHub. 引文见 README 简介第一条。另见设备参数与混合推理示例及推荐的 R1 权重版本。 ↩ ↩2 ↩3 ↩4 ↩5
-
Kevin改变世界的点滴. (2025, March 20). 聊下我们4090 单卡24GB 部署DEEPSEEK 满血版的Ktransformer. 53AI. 标题及对 CPU 和内存分工的说明。 ↩
-
KTransformers contributors. (2025, July 1). Experts operators [源代码]. GitHub. 单步解码向 CPU 提交哪些数据,以及怎样取回输出。 ↩ ↩2 ↩3 ↩4 ↩5
-
昇腾社区. (2025, April 23). 【昇腾大规模专家并行技术解码】PD分离,让推理性能再提速30%! [技术文章]. “昇腾PD实例分离方案”及“环境准备”中的 16 台服务器示例。 ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
Hugging Face. (2025). Caching (Transformers v4.50.0). Hugging Face documentation. 前文的键值怎样保存和复用,以及同页的逐词生成示例。图 2 为本文自绘。按词元观察键和值的图解另见 Alammar, J. (2019), The Illustrated GPT-2, Evaluation Time: Processing One Token at a Time。本文的“蓝 / 色”是说明顺序的简化分词,键和值按回看前文时的用途解释。DeepSeek 的具体压缩存法见 DeepSeek-V3 技术报告第 2.1.1 节。 ↩ ↩2 ↩3 ↩4 ↩5
-
Vaswani, A., et al. (2017). Attention is all you need. NeurIPS. 第 3.2.1–3.2.2 节,查询与键的打分、值的加权以及多头输出的合并。 ↩ ↩2 ↩3 ↩4
-
DeepSeek-AI. (2025, January). DeepSeek-R1. Hugging Face. Model Downloads 中的总参数、激活参数及蒸馏模型表。 ↩ ↩2 ↩3
-
DeepSeek-AI. (2024, December 27). DeepSeek-V3 technical report (v1). arXiv. 第 2.1.2 节,专家选择与加权及第 3.4 节,推理部署、跨节点分发与回收、解码批量和专家负载。 ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11
-
不归牛顿管的熊猫. (2024, April 24). 全面认识模型压缩技术之稀疏,motivated by混合专家模型MoE LLM的稀疏特性. 知乎专栏. “稀疏模型的样貌”及“混合专家模型的sparse matmul”。 ↩
-
KTransformers contributors. (2025, July 1). DeepSeek-V3-Chat.yaml [设备与算子配置]. GitHub. 路由器、专家与注意力的设备规则。 ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7
-
Sicchasia. (2024, March 26). LLM大模型推理加速实战:vllm、fastllm与llama.cpp使用指南. 稀土掘金. 第三节第 3 步,llama.cpp 的批处理参数示例。 ↩
-
fastllm contributors. (2025, July 9). DeepSeek 模型部署. GitHub. 本地模型入口与当时支持的格式。对照 KTransformers contributors (2025, July 1), 模板替换原理和项目定位及本地聊天启动示例。 ↩ ↩2 ↩3 ↩4
-
llama.cpp contributors. (2025, January). llama.cpp (b4514). GitHub. 模型层在 CPU、GPU 间的分配。另见 GGUF 文件格式的引入说明。 ↩
-
KTransformers contributors. (2025, July 1). Local chat and model optimization [源代码]. GitHub. 默认规则表、选择和加载规则的入口及替换匹配模块的实现。 ↩ ↩2
-
vLLM Project. (2025). vLLM (v0.9.1). vLLM documentation. 服务引擎的连续批处理和缓存管理。可对照本地部署教程中的多请求算例。 ↩ ↩2
-
KTransformers contributors. (2025, July 1). KTransformers extension build configuration. GitHub. llama.cpp 子模块地址及扩展构建时加入源码目录的位置。 ↩
-
BBuf. (2023, July 19). 大模型部署框架 FastLLM 简要解析. 知乎专栏. 第 0x2 节,ChatGLM-6B 的模型导出及第 0x4 节,按硬件实现计算。 ↩
-
fastllm contributors. (2025, July 9). DeepSeek model implementation. GitHub. 给专家打分、切换专家设备并计算及回到常规设备合并输出。 ↩
-
WilsonShiiii. (n.d.). 一文看懂KTransformers:大模型推理的革新利器. CSDN. “异构计算,巧妙分工”中注意力与专家的例子。 ↩
-
CaiBorui. (2025, July). ktransformer如何决定内存 offloading策略 [检索词]. Google. 当时输入的问题。 ↩
-
吃果冻不吐果冻皮. (2024, September 22). 大模型低显存推理优化-Offload技术. 知乎专栏. “DeepSpeed ZeRO-Inference”一节,“第一种方案:卸载所有模型权重”。另见 DeepSpeed (2022, September 9), ZeRO-Inference, Offload all model weights。 ↩ ↩2
-
KTransformers contributors. (2025, July 1). DeepSeek-V3-Chat.yaml 与 DeepSeek-R1/V3 tutorial. GitHub. 输出层和常规线性层的设备、路由、专家、注意力和输入词表的设备及教程对 CPU 专家计算与 GPU 注意力、缓存分工的说明。 ↩ ↩2 ↩3
-
KTransformers contributors. (2025, July 1). DeepSeek-R1/V3 tutorial. GitHub. 引文见 Show Cases 的 671B Q4_K_M 条目。测试条件与数字见 Bench Result,V0.2.1 配置与 8 experts 行。 ↩ ↩2 ↩3 ↩4
-
KTransformers contributors. (2025, July 1). GGUF loader and CPU experts. GitHub. GGUF 文件映射 · CPU 专家的设备检查和权重指针。 ↩
-
ToTensor. (n.d.). Ktransformers实践-仅用14G显存就能跑Deepseek-R1 671B. CSDN. “一、如何使用”开头的主机检查。双路机器复制关键矩阵的取舍见 KTransformers contributors (2025, July 1), DeepSeek-R1/V3 tutorial,Some Explanations 第 1 条。 ↩
-
孟词宗. (2025, July 8–9). 叒说 AI 本地部署 - 一千美刀跑 DeepSeek R1 671B Q5版 [论坛回帖]. 爱吱声. 引文见第 3 页第 46 楼第 3 点。5060 Ti 配置见同楼末段,上下文长度见第 48 楼。 ↩ ↩2
-
marsggbo. (2023, December 7). LLM 学习笔记-Deepspeed-MoE 论文. 博客园。第 5.1 节的 16 卡分组示例。参见 Rajbhandari, S., et al. (2022). DeepSpeed-MoE: Advancing mixture-of-experts inference and training to power next-generation AI scale. 图 7,专家与非专家部分的并行布局。 ↩ ↩2
-
DeepSpeed. (n.d.). Getting started with DeepSpeed-MoE for inferencing large-scale MoE models. “Various configuration options”中关于 GPU 多于专家时如何切分专家的说明。 ↩
-
Business Wind Vane. (2025, May 22). 大模型推理,不再是“一根筋”. 虎嗅. 华为技术披露集第 4 期,“多流并行”中三组数据如何同时推进。 ↩
-
Zhong, Y., et al. (2024, July). DistServe: Disaggregating prefill and decoding for goodput-optimized large language model serving. USENIX OSDI. 论文,检索“KV cache transfer”可定位阶段交接与带宽分析。 ↩ ↩2 ↩3
-
aarongough. (n.d.). What mobos do folks recommend for multi-gpu builds? Reddit, r/LocalLLaMA. 主帖的四卡设想和 UPDATE 中的双工作站方案。 ↩
-
管理员. (2023, April 21). 2024年人工智能训练与推理工作站、服务器、集群硬件配置推荐. UltraLAB 图形工作站方案网站. 2024 年 2 月更新。配置 2.4A,四张 RTX 4090 的显存合计。 ↩
-
路人与大师. (2024, August 19). 构建一台适用于AIGC(人工智能生成内容)的服务器及分布式软件解决方案. 掘金. “4090D”配置中的显卡与系统内存,“监控与管理”中的任务调度。 ↩
-
Alpa contributors. (n.d.). Serving OPT-175B, BLOOM-176B and CodeGen-16B using Alpa. Alpa 0.2.3.dev17. Overview 中的容量与服务分工;让多个节点读取权重、运行生成和启动 Web 服务。 ↩ ↩2
-
Zheng, L., et al. (2022). Alpa: Automating inter- and intra-operator parallelism for distributed deep learning. OSDI 2022. 图 1 与第 3 节,怎样把算子和流水线阶段分配到设备。 ↩ ↩2
-
Prasad, H. (2025, March 10). vLLM performance benchmarks 4x RTX 3090 (power limits, and NVLINK). Himesh's Blog. 实验 2 的拓扑、启动参数与吞吐表。 ↩