Skip to content

to_host() Fails on Vulkan backend #25284

Open

Description

@Honza-Hroch

What happened?

The to_host() operation fails on the Vulkan backend—both in the output when running code compiled via the compiler and with manually allocated arrays. It fails due to a memory alignment error.
ValueError: could not import host allocation: D:\a\iree\iree\c\runtime\src\iree\hal\drivers\vulkan\allocator.c:1985: INVALID_ARGUMENT; host allocation import pointer does not satisfy Vulkan minImportedHostPointerAlignment 4096

Steps to reproduce your issue

Reproduction code, for manualy created array is
`import iree.runtime

driver = iree.runtime.get_driver("vulkan")
device = driver.create_default_device()
buffer=device.allocator.allocate_buffer(iree.runtime.MemoryType.DEVICE_LOCAL,iree.runtime.BufferUsage.TRANSFER_SOURCE,4)
buffer_view=iree.runtime.HalBufferView(buffer,(1,),iree.runtime.HalElementType.FLOAT_32)
array=iree.runtime.DeviceArray(device,buffer_view)
array.to_host()`

What component(s) does this issue relate to?

Runtime

Version information

IREE runtime installed form PIP with versions 3.13.1 and 3.14.0rc20261114
It si running on Windows 11 with an NVIDIA GeForce RTX 3050.

Additional context

The same code runs on cuda backand without erorss.

Activity

  1. added
    bug 🐞
    on Nov 15, 2026
  2. github-actions commented on Nov 15, 2026

    @github-actions

    Hello @Honza-Hroch 👋

    Thank you for submitting an issue to IREE! It looks like it's your first one.

    The volume of issues is huge, and triage times may vary. If you need quicker assistance on the issue, consider posting it on IREE Discord and providing short context there.
    Feel free to identify the most frequent contributors to the corresponding part of the codebase via Git history/CODEOWNERS and (gently!) tag them below.


    Action required: acknowledge IREE project policies

    IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.

    Please note that all contributions to IREE, including GitHub issues, must follow our IREE AI Tool Use Policy. This means:

    • Issue reporters must fully understand the primary issue and the impact of the problem.
      For bug reports, specifics of the use-case, workflow and/or crash scenario usually suffice.
      For improvement suggestions, this usually implies deeper understanding of suboptimal code, IR design choices, assumed performance tradeoffs, etc.
    • Contributors must write the summary of the issue themselves, so that the exact impact and scenario is clear to other participants.
    • Issue authors are expected to review and understand all LLM/AI-assisted segments of the report, if any. E.g.: CLI commands and IR reproducers, model/framework details, lowering pipeline details, assumptions about problematic behaviors of IREE components.
    • Substantial use of LLM/generative AI tools must be disclaimed in the header or footer of the issue description.

    Before the issue can be triaged, we kindly ask you to reply to this message and confirm that you understand and accept the proposed policy. As required, please adjust your initial issue description.


    If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.

    Thank you,
    The IREE Community

  3. Honza-Hroch commented on Nov 15, 2026

    @Honza-Hroch
    Author

    Hello, I have read the contributor guidelines and agree to them. I wrote the reproduction code myself. I used a translator for some parts of the problem description, as English is not my native language.

  4. devtbi commented on Nov 16, 2026

    @devtbi
    Contributor

    @Honza-Hroch slightly awkward error. The device buffer you allocated is not host_visible, so calling to_host implicitly falls back to copy, which in turn allocates a host-buffer that doesn't adhere to alignment requirements that Vulkan would need to execute the copy. I'm not sure what exactly you are attempting to do, but the obvious fix would be to make the vulkan allocation host_visible / or to create a staging buffer that is on the host, to copy data into a device_local non-host-visible buffer.

  5. added
    enhancement ➕
    bug 🐞
    and removed
    bug 🐞
    enhancement ➕
    on Nov 16, 2026
  6. Honza-Hroch commented on Nov 16, 2026

    @Honza-Hroch
    Author

    @devtbi Thank you for your answer!
    I try to explain what I did. The complete traceback is

    Traceback (most recent call last):
      File "C:\Users\honza\PycharmProjects\vulkan_torch\minimal_reproduction.py", line 9, in <module>
        array.to_host()
        ~~~~~~~~~~~~~^^
      File "C:\Users\honza\PycharmProjects\vulkan_torch\.venv\Lib\site-packages\iree\runtime\array_interop.py", line 126, in to_host
        return self._transfer_to_host(False)
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
      File "C:\Users\honza\PycharmProjects\vulkan_torch\.venv\Lib\site-packages\iree\runtime\array_interop.py", line 151, in _transfer_to_host
        return self._copy_to_host()
               ~~~~~~~~~~~~~~~~~~^^
      File "C:\Users\honza\PycharmProjects\vulkan_torch\.venv\Lib\site-packages\iree\runtime\array_interop.py", line 197, in _copy_to_host
        host_buf = alloc.import_host_allocation(
            result,
            memory_type=mem_type,
            allowed_usage=import_usage,
        )
    ValueError: could not import host allocation: D:\a\iree\iree\c\runtime\src\iree\hal\drivers\vulkan\allocator.c:1985: INVALID_ARGUMENT; host allocation import pointer does not satisfy Vulkan minImportedHostPointerAlignment 4096
    
    

    Method _copy_to_host has two ways. The
    first way uses import_host_allocation, and which currently doesn´t work with Vulkan. The second one uses allocate_buffer and this approach works. My question is whether Vulkan should always use the second way, or if the first way should be fixed.

  7. devtbi commented on Nov 17, 2026

    @devtbi
    Contributor

    should be fixed, but that might be non-trivial

  8. Honza-Hroch commented on Nov 20, 2026

    @Honza-Hroch
    Author

    Here is what I have managed to find out so far:
    The _copy_to_host() method allocates a buffer using np.empty, which does not guarantee any specific alignment.
    It appears that the IREE runtime API lacks a mechanism to retrieve the required alignment for the current backend. A function designed to return the requirements for an external buffer—ensuring it can be imported—was proposed in a TODO comment within runtime/src/iree/hal/allocator.h, but it seems it was never implemented. Implementing it, however, would entail an API extension that all backends would be required to support.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions