@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / e6309acdba
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 12, 17:15 UTC

Simplify `from_blob` usage in `get_cuda_view_from_cpu_tensor` (#29027)

Signed-off-by: Jane Xu <janeyx@meta.com>

Jane (Yuan) Xu committed Nov 22, 2025 at 05:35 UTC e6309acdba3a26e803d1ea7f66804f4ad30c2b9a
1 file changed +3 -8
csrc/cuda_view.cu
+3 -8
@@ -22,15 +22,10 @@ torch::Tensor get_cuda_view_from_cpu_tensor(torch::Tensor& cpu_tensor) {
22 auto strides = cpu_tensor.strides();
23 auto options = cpu_tensor.options().device(torch::kCUDA);
24
25 - // from_blob signature: from_blob(void *data, IntArrayRef sizes, ..., Deleter,
26 - // const TensorOptions &) Provide a no-op deleter. The CPU tensor holds the
27 - // memory, so we don't free it here.
28 - auto deleter = [](void*) {
29 - // no-op, since the memory is owned by the original CPU tensor
30 - };
31 -
25 + // use default no-op deleter, since the memory is owned by the original CPU
26 + // tensor
27 torch::Tensor cuda_tensor =
33 - torch::from_blob(device_ptr, sizes, strides, deleter, options);
28 + torch::from_blob(device_ptr, sizes, strides, options);
29
30 TORCH_CHECK(cuda_tensor.device().is_cuda(),
31 "Resulting tensor is not on CUDA device");