@@ -180,12 +180,13 @@ multiprocessing.reduction.register(IPCAllocationHandle, _reduce_allocation_handl
180180cdef class VirtualMemoryIPCBufferDescriptor(IPCBufferDescriptor ):
181181 """ Serializable object describing a :class:`VirtualMemoryBuffer` that can be shared between processes.
182182
183- The descriptor holds one exported handle per physical allocation that
184- backs the buffer, in address order (``handles``), with each allocation's
185- size (``sizes``) and the buffer's size (``size``, which may be smaller
186- than their sum). With POSIX file descriptors the handles are
187- :class:`IPCAllocationHandle` objects: the descriptor owns them and closes
188- them when it is released.
183+ The descriptor holds one exported POSIX file descriptor per physical
184+ allocation that backs the buffer, in address order (``handles``, each an
185+ :class:`IPCAllocationHandle` that the descriptor owns and closes when it
186+ is released), with each allocation's size (``sizes``) and the buffer's
187+ size (``size``, which may be smaller than their sum). ``handle_type`` is
188+ ``"posix_fd"``, the only handle type cuda.core shares today; the rules
189+ below describe file descriptors.
189190
190191 A descriptor pins the physical memory while it exists, in every process
191192 that holds one, and nothing else does: the exporting buffer keeps no
@@ -200,8 +201,8 @@ cdef class VirtualMemoryIPCBufferDescriptor(IPCBufferDescriptor):
200201 ``Process`` arguments, or a ``Pool``) pickles the descriptor, or a buffer,
201202 and duplicates the file descriptors into the receiving process; plain
202203 ``pickle`` cannot carry them and raises. A process with its own file
203- descriptor passing sends ``fds``, ``sizes``, ``handle_type`` , and ``size``
204- itself, and the receiver rebuilds the descriptor with :meth:`from_fds`.
204+ descriptor passing sends ``fds``, ``sizes``, and ``size`` itself , and the
205+ receiver rebuilds the descriptor with :meth:`from_fds`.
205206
206207 Note
207208 ----
@@ -230,15 +231,15 @@ cdef class VirtualMemoryIPCBufferDescriptor(IPCBufferDescriptor):
230231 fds: Iterable[int | IPCAllocationHandle],
231232 sizes: Iterable[int],
232233 *,
233- handle_type: VirtualMemoryHandleType | str = " posix_fd" ,
234234 size: int | None = None ,
235235 ) -> VirtualMemoryIPCBufferDescriptor:
236- """Build a descriptor from file descriptors received outside ``multiprocessing``.
236+ """Build a descriptor from POSIX file descriptors received outside ``multiprocessing``.
237237
238- The exporter sends ``fds``, ``sizes``, ``handle_type``, and ``size``
239- of its descriptor through a transport of its own (a Unix socket with
240- ``SCM_RIGHTS``, for example ); the receiver rebuilds the descriptor
241- here and imports it with :meth:`Buffer.from_ipc_descriptor`.
238+ The exporter sends ``fds``, ``sizes``, and ``size`` of its descriptor
239+ through a transport of its own (a Unix socket with ``SCM_RIGHTS``, for
240+ example ); the receiver rebuilds the descriptor here and imports it
241+ with :meth:`Buffer.from_ipc_descriptor`. The result's ``handle_type``
242+ is ``"posix_fd"``, the only handle type a file descriptor can carry.
242243
243244 Parameters
244245 ----------
@@ -250,29 +251,21 @@ cdef class VirtualMemoryIPCBufferDescriptor(IPCBufferDescriptor):
250251 holder.
251252 sizes : Iterable[int]
252253 The exporter's ``sizes``, one per handle.
253- handle_type : VirtualMemoryHandleType | str , optional
254- The exporter's ``handle_type``; ``"posix_fd"`` by default.
255254 size : int , optional
256255 The exporter's ``size``, at most the sum of ``sizes``; the sum by
257256 default.
258257
259258 Raises
260259 ------
261260 ValueError
262- If the counts differ , a size is not positive , ``size`` exceeds the
263- sum of ``sizes``, or ``handle_type`` cannot be shared .
261+ If the counts differ , a size is not positive , or ``size`` exceeds
262+ the sum of ``sizes``.
264263 RuntimeError
265264 If an :class:`IPCAllocationHandle` is closed.
266265 OSError
267266 If an ``int`` is not an open file descriptor.
268267 """
269- # Lazy import: this module is loaded while _virtual_memory_resource imports it.
270- from cuda.core._memory._virtual_memory_resource import VirtualMemoryResourceOptions
271- from cuda.core.typing import VirtualMemoryHandleType
272-
273- if handle_type is None:
274- raise ValueError("handle_type = None cannot be shared; the exporter' s handle_type is required")
275- driver_type = int (VirtualMemoryResourceOptions._handle_type_to_driver(VirtualMemoryHandleType(handle_type)))
268+ cdef int driver_type = < int > cydriver.CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR
276269 cdef tuple sizes_t = tuple (operator.index(n) for n in sizes)
277270 cdef list given = list (fds)
278271 if len(given ) != len(sizes_t ):
@@ -318,15 +311,20 @@ cdef class VirtualMemoryIPCBufferDescriptor(IPCBufferDescriptor):
318311
319312 @property
320313 def handles(self ) -> tuple[IPCAllocationHandle , ...]:
321- """The exported handles , one per allocation , in address order; the descriptor owns them."""
314+ """The exported handles , one :class:`IPCAllocationHandle` per allocation , in address order.
315+
316+ The descriptor owns them and closes them when it is released.
317+ """
322318 return self._handles
323319
324320 @property
325321 def fds(self ) -> tuple[int , ...]:
326322 """The exported file descriptors as integers , for a transport of your own.
327323
328324 They belong to this descriptor: send or duplicate them while it is
329- alive. Each one is released when the descriptor is.
325+ alive , because each one is closed when the descriptor is released.
326+ Keep the descriptor in a variable while you use them; the numbers
327+ from ``buf.ipc_descriptor.fds`` alone may already be closed.
330328 """
331329 return tuple(int(handle ) for handle in self._handles )
332330
0 commit comments