Skip to content

Design support for reduced precision types in dpctl #72

Open

Description

@diptorupd

We should support reduced precision types that are supported in Sycl.

Activity

  1. added this to the gold milestone on Oct 5, 2020
  2. PokhodenkoSA commented on Feb 5, 2021

    @PokhodenkoSA
    Contributor
    class c_half(ctypes._SimpleCData):
      _type_ = "e"
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: class must define a '_type_' attribute which must be
    a single character string containing one of 'cbBhHiIlLdfuzZqQPXOv?g'.

    Links:

  3. oleksandr-pavlyk commented on Feb 5, 2021

    @oleksandr-pavlyk
    Contributor

    The scope of the support matters. The main purpose of supporting in dpctl is to be able to submit kernels that take reduced precision arguments.

    In addition to standard C/C++ types, SYCL supports std::byte and sycl::half (assuming device supports it). See tables 4.105 and 5.1 in the SYCL 2020 provisional standard. bfloa16 is not presently supported. Reference to an extension proposal would be good to record in this issue.

    Anyhow, for dpctl to support any additional type, we need Python class representing the type, say dpctl.types.c_half and dpctl.types.c_bfloat16, whose purpose in life is to hold the value, and designate its type. It should have a constructor to convert from other floating point types, i.e. Python floats, ctypes.c_float, ctypes.c_double, etc., and allow to get the reference to the value.

    DPCTL's SyclQueue.submit will then recognize this class, and call KernelSetArg with the proper enum value.

  4. changed the title [-]Design support for reduced precision types in dpCtl[/-] [+]Design support for reduced precision types in dpctl[/+] on Apr 15, 2021
  5. oleksandr-pavlyk commented on Sep 25, 2021

    @oleksandr-pavlyk
    Contributor

    Here is example of using ctypes to convert a single ctype.c_float value input into a ctypes.c_short encoding the bits of the corresponding float16 value. https://gamedev.stackexchange.com/questions/28023/python-float-32bit-to-half-float-16bit

    I wonder is this could be a start of implementing our own float16 type object.

  6. diptorupd commented on Mar 1, 2024

    @diptorupd
    ContributorAuthor

    @oleksandr-pavlyk Is the issue still relevant? If not I will suggest it to be closed.

  7. removed their assignment
    on Mar 1, 2024
  8. ndgrigorian commented on Apr 12, 2026

    @ndgrigorian
    Collaborator

    To clarify, the issue is still relevant, because it would be great to submit kernels via dpctl.SyclQueue.submit which take these types from Python/Cython

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions