CUDA: batch gate/up/down uploads for selected expert cache misses - #460
CUDA: batch gate/up/down uploads for selected expert cache misses#460fmolara wants to merge 1 commit into
Conversation
When a selected expert cache miss occurs in the direct-I/O CUDA path, gate/up/down tensors are currently uploaded independently, synchronizing the selected upload stream after each tensor. Batch the three uploads for one expert and synchronize the upload stream once after all three have been enqueued. Layouts, cache policy and kernels are unchanged. Unsupported cases transparently fall back to the existing path.
770feb8 to
6ece876
Compare
|
Rebased onto current The change remains narrowly scoped:
Both the current baseline ( All validation runs produced identical deterministic output and the same normalized output SHA-256, with no CUDA staging, upload, or synchronization errors. A targeted Nsight Systems comparison confirmed the intended effect:
This removes exactly 72,184 stream synchronizations in the profiled workload while preserving the upload count and output correctness. End-to-end throughput remained within run-to-run noise, so the validation notes no longer claim a measurable overall throughput improvement on the current |
…ez#524) server: when thinking mode is on and the model never emits </think> (typically truncated at max_tokens mid-thought), surface the whole text as unfinished reasoning with empty content instead of letting it leak into content — applied to both the DSML and GLM tool-call parse paths (upstream antirez#524, adapted to the split parser). Verified live: /v1/messages now returns a thinking block plus empty text for the truncated case; closed-thinking responses are unchanged. cuda: treat every model range as accessible when the HMM direct path is active (upstream antirez#158, the is_cached hunk only). The PR's full-model prefetch half is deliberately not ported: prefetching a model larger than RAM would thrash the page cache on the SSD-streaming Spark boxes. Dormant in current configs; single-token identity exact. Reviewed against the queue: antirez#497 already fixed here (b715001), antirez#472 superseded by the newer bounded-reserve design, antirez#513 not reachable (expert tiles ship disabled for iq2-down), antirez#460/antirez#528/antirez#504 deferred as future work. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port of upstream antirez#460, reviewed and adapted: the helper stages one expert's three tensors through distinct stage slots with a single trailing upload-stream sync, replacing three sequential streamed copies that each paid a full drain. Applied to both miss-fill sites in cuda_stream_selected_cache_begin_load — the expert-pool fill branch (which postdates the PR) and the scratch fallback it originally targeted — with the general streamed-copy path kept as the -1 fallback for oversized tensors or unregistered-fd maps. Safety contract verified against this tree: every streamed-copy entry point drains the upload stream before returning, so stage slots are always idle on entry; per-chunk page-cache hygiene is mirrored exactly. 45k-deep TP steady decode 3.20 -> 3.25 t/s, cold TP 2.95 -> 3.00, output byte-exact vs the reference in all tiers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Motivation
In the CUDA direct-I/O path, a selected expert cache miss uploads the gate/up/down tensors independently, synchronizing the selected upload stream after each tensor.
This patch batches the three uploads belonging to the same expert and synchronizes the selected upload stream once after all three have been enqueued.
Properties
Validation
Tested after rebasing onto
efdadd4, which was the currentmainat the time, on an NVIDIA A100 80GB PCIe with CUDA 12.4 (sm_80).efdadd46ece876Targeted miss-heavy Nsight Systems validation
cudaStreamSynchronizecallscudaStreamSynchronizeAPI timecudaStreamSynchronizecallscudaStreamSynchronizeAPI timeThe number of
cudaMemcpyAsynccalls remained unchanged at 108,276.This confirms that the patch preserves the same gate/up/down uploads while reducing synchronization from once per tensor upload to once per three-upload group.
End-to-end throughput differences were within normal run-to-run noise:
This change should therefore be considered a synchronization-granularity improvement, not a demonstrated overall throughput improvement on the current upstream code.