modify_allocation records new_size on the returned Buffer (slow path: Buffer.from_handle(ptr=new_ptr, size=new_size); fast path: buf._size = new_size), while allocate() records the granularity-aligned size. For a grow to a size that is not a multiple of the granularity (2 MiB on current GPUs), close() calls cuMemUnmap with an end inside the last mapping, which the driver rejects, so the reservation, the mappings, and the physical memory leak and the Buffer deleter reports a CUDAWarning. The equal-size branch hits the same alignment rule in cuMemSetAccess and raises. Reachable today through the slow path. No test grows to an unaligned size. Fix belongs to the ownership redesign (epic #2906).
modify_allocationrecordsnew_sizeon the returned Buffer (slow path:Buffer.from_handle(ptr=new_ptr, size=new_size); fast path:buf._size = new_size), whileallocate()records the granularity-aligned size. For a grow to a size that is not a multiple of the granularity (2 MiB on current GPUs),close()callscuMemUnmapwith an end inside the last mapping, which the driver rejects, so the reservation, the mappings, and the physical memory leak and the Buffer deleter reports a CUDAWarning. The equal-size branch hits the same alignment rule incuMemSetAccessand raises. Reachable today through the slow path. No test grows to an unaligned size. Fix belongs to the ownership redesign (epic #2906).