§
    ­˜ºh®  ã                   ó¤  — U d dl Z d dlZd dlmZmZ d dlZd dlmZ g d¢Ze	e
         ed<   de
defd„Z eej        d	¦  «        sï eej        d
¦  «        rJ ‚ eej        d¦  «        rJ ‚ eej        d¦  «        rJ ‚ eej        d¦  «        rJ ‚ eej        d¦  «        rJ ‚ ed	¦  «        ej        j        d	<    ed
¦  «        ej        j        d
<    ed¦  «        ej        j        d<    ed¦  «        ej        j        d<    ed¦  «        ej        j        d<    ed¦  «        ej        j        d<   deddfd„Zdeddfd„Z G d„ d¦  «        ZdS )é    N)ÚCallableÚOptional)ÚStorage)Úgds_register_bufferÚgds_deregister_bufferÚGdsFileÚ__all__ÚnameÚreturnc                 ó   ‡ — ˆ fd„}|S )Nc                  ó*   •— t          d‰› d�¦  «        ‚)Nz	torch._C.z" is not supported on this platform)ÚRuntimeError)ÚargsÚkwargsr
   s     €úV/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/torch/cuda/gds.pyÚfnz_dummy_fn.<locals>.fn   s   ø€ ÝÐO tÐOÐOÐOÑPÔPÐPó    © )r
   r   s   ` r   Ú	_dummy_fnr      s(   ø€ ðQð Qð Qð Qð Qð €Ir   Ú_gds_register_bufferÚ_gds_deregister_bufferÚ_gds_register_handleÚ_gds_deregister_handleÚ_gds_load_storageÚ_gds_save_storageÚsc                 óD   — t           j                             | ¦  «         dS )a:  Registers a storage on a CUDA device as a cufile buffer.

    Example::

        >>> # xdoctest: +SKIP("gds filesystem requirements")
        >>> src = torch.randn(1024, device="cuda")
        >>> s = src.untyped_storage()
        >>> gds_register_buffer(s)

    Args:
        s (Storage): Buffer to register.
    N)ÚtorchÚ_Cr   ©r   s    r   r   r   &   s    € õ 
„H×!Ò! !Ñ$Ô$Ð$Ð$Ð$r   c                 óD   — t           j                             | ¦  «         dS )aw  Deregisters a previously registered storage on a CUDA device as a cufile buffer.

    Example::

        >>> # xdoctest: +SKIP("gds filesystem requirements")
        >>> src = torch.randn(1024, device="cuda")
        >>> s = src.untyped_storage()
        >>> gds_register_buffer(s)
        >>> gds_deregister_buffer(s)

    Args:
        s (Storage): Buffer to register.
    N)r   r   r   r    s    r   r   r   6   s    € õ 
„H×#Ò# AÑ&Ô&Ð&Ð&Ð&r   c                   óf   — e Zd ZdZdedefd„Zdd„Zdd„Zdd	„Z	dde
deddfd„Zdde
deddfd„ZdS )r   a“  Wrapper around cuFile.

    cuFile is a file-like interface to the GPUDirect Storage (GDS) API.

    See the `cufile docs <https://docs.nvidia.com/gpudirect-storage/api-reference-guide/index.html#cufile-io-api>`_
    for more details.

    Args:
        filename (str): Name of the file to open.
        flags (int): Flags to pass to ``os.open`` when opening the file. ``os.O_DIRECT`` will
            be added automatically.

    Example::

        >>> # xdoctest: +SKIP("gds filesystem requirements")
        >>> src1 = torch.randn(1024, device="cuda")
        >>> src2 = torch.randn(2, 1024, device="cuda")
        >>> file = torch.cuda.gds.GdsFile(f, os.O_CREAT | os.O_RDWR)
        >>> file.save_storage(src1.untyped_storage(), offset=0)
        >>> file.save_storage(src2.untyped_storage(), offset=src1.nbytes)
        >>> dest1 = torch.empty(1024, device="cuda")
        >>> dest2 = torch.empty(2, 1024, device="cuda")
        >>> file.load_storage(dest1.untyped_storage(), offset=0)
        >>> file.load_storage(dest2.untyped_storage(), offset=src1.nbytes)
        >>> torch.equal(src1, dest1)
        True
        >>> torch.equal(src2, dest2)
        True

    ÚfilenameÚflagsc                 óä   — t           j        dk    rt          d¦  «        ‚|| _        || _        t          j        ||t
          j        z  ¦  «        | _        d | _	        |  
                    ¦   «          d S )NÚwin32z*GdsFile is not supported on this platform.)ÚsysÚplatformr   r#   r$   ÚosÚopenÚO_DIRECTÚfdÚhandleÚregister_handle)Úselfr#   r$   s      r   Ú__init__zGdsFile.__init__g   se   € ÝŒ<˜7Ò"Ð"ÝÐKÑLÔLÐLØ ˆŒØˆŒ
Ý”'˜( E­B¬KÑ$7Ñ8Ô8ˆŒØ%)ˆŒØ×ÒÑÔÐÐÐr   r   Nc                 ón   — | j         �|                      ¦   «          t          j        | j        ¦  «         d S )N)r-   Úderegister_handler)   Úcloser,   ©r/   s    r   Ú__del__zGdsFile.__del__p   s4   € ØŒ;Ð"Ø×"Ò"Ñ$Ô$Ð$Ý
Œ�”ÑÔÐÐÐr   c                 óz   — | j         �
J d¦   «         ‚t          j                             | j        ¦  «        | _         dS )zpRegisters file descriptor to cuFile Driver.

        This is a wrapper around ``cuFileHandleRegister``.
        Nz4Cannot register a handle that is already registered.)r-   r   r   r   r,   r4   s    r   r.   zGdsFile.register_handleu   s:   € ð ŒKÐÐØAñ  ÔÐå”h×3Ò3°D´GÑ<Ô<ˆŒˆˆr   c                 ó~   — | j         €
J d¦   «         ‚t          j                             | j         ¦  «         d| _         dS )zvDeregisters file descriptor from cuFile Driver.

        This is a wrapper around ``cuFileHandleDeregister``.
        Nz2Cannot deregister a handle that is not registered.)r-   r   r   r   r4   s    r   r2   zGdsFile.deregister_handle   s@   € ð ŒKÐ#Ð#Ø?ñ $Ô#Ð#åŒ×'Ò'¨¬Ñ4Ô4Ð4ØˆŒˆˆr   r   ÚstorageÚoffsetc                 ót   — | j         €
J d¦   «         ‚t          j                             | j         ||¦  «         dS )am  Loads data from the file into the storage.

        This is a wrapper around ``cuFileRead``. ``storage.nbytes()`` of data
        will be loaded from the file at ``offset`` into the storage.

        Args:
            storage (Storage): Storage to load data into.
            offset (int, optional): Offset into the file to start loading from. (Default: 0)
        Nz4Cannot load data from a file that is not registered.)r-   r   r   r   ©r/   r8   r9   s      r   Úload_storagezGdsFile.load_storageŠ   s?   € ð ŒKÐ#Ð#ØAñ $Ô#Ð#åŒ×"Ò" 4¤;°¸Ñ@Ô@Ð@Ð@Ð@r   c                 ót   — | j         €
J d¦   «         ‚t          j                             | j         ||¦  «         dS )aU  Saves data from the storage into the file.

        This is a wrapper around ``cuFileWrite``. All bytes of the storage
        will be written to the file at ``offset``.

        Args:
            storage (Storage): Storage to save data from.
            offset (int, optional): Offset into the file to start saving to. (Default: 0)
        Nz2Cannot save data to a file that is not registered.)r-   r   r   r   r;   s      r   Úsave_storagezGdsFile.save_storage™   s?   € ð ŒKÐ#Ð#Ø?ñ $Ô#Ð#åŒ×"Ò" 4¤;°¸Ñ@Ô@Ð@Ð@Ð@r   )r   N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚintr0   r5   r.   r2   r   r<   r>   r   r   r   r   r   G   sê   € € € € € ðð ð> ð ¨Sð ð ð ð ðð ð ð ð
=ð =ð =ð =ð	ð 	ð 	ð 	ðAð A Gð A°Sð AÀð Að Að Að AðAð A Gð A°Sð AÀð Að Að Að Að Að Ar   r   )r)   r'   Útypingr   r   r   Útorch.typesr   r	   ÚlistrC   Ú__annotations__r   Úhasattrr   Ú__dict__r   r   r   r   r   r   ú<module>rK      sa  ðØ 	€	€	€	€	Ø 
€
€
€
Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à €€€Ø Ð Ð Ð Ð Ð ðð ð €ˆˆcŒð ð ñ ð�Cð ˜Hð ð ð ð ð €wˆuŒxÐ/Ñ0Ô0ð LØˆw�u”xÐ!9Ñ:Ô:Ð:Ð:Ð:Øˆw�u”xÐ!7Ñ8Ô8Ð8Ð8Ð8Øˆw�u”xÐ!9Ñ:Ô:Ð:Ð:Ð:Øˆw�u”xÐ!4Ñ5Ô5Ð5Ð5Ð5Øˆw�u”xÐ!4Ñ5Ô5Ð5Ð5Ð5à09°	Ð:PÑ0QÔ0Q€E„HÔÐ,Ñ-Ø2;°)Ð<TÑ2UÔ2U€E„HÔÐ.Ñ/Ø09°	Ð:PÑ0QÔ0Q€E„HÔÐ,Ñ-Ø2;°)Ð<TÑ2UÔ2U€E„HÔÐ.Ñ/Ø-6¨YÐ7JÑ-KÔ-K€E„HÔÐ)Ñ*Ø-6¨YÐ7JÑ-KÔ-K€E„HÔÐ)Ñ*ð%˜7ð % tð %ð %ð %ð %ð '˜Wð '¨ð 'ð 'ð 'ð 'ð"_Að _Að _Að _Að _Añ _Aô _Að _Að _Að _Ar   