Skip to content

Improve memory allocation for LLM-like models #13545

Closed

Description

@silvasean

What happened?

Same repro as #13543, but patch https://github.com/openxla/iree/blob/03110def3fab268812ee33b183786fd991514a68/runtime/src/iree/modules/hal/module.c#L1121 to increase the count from 32 to 128 to work around #13543.

Error:

iree/runtime/src/iree/hal/drivers/cuda/cuda_device.c:538: INTERNAL; CUDA driver error 'CUDA_ERROR_ILLEGAL_ADDRESS' (700):
 an illegal memory access was encountered; cuStreamSynchronize; while invoking native function hal.device.queue.execute; 
while calling import;

(full error log here)

Steps to reproduce your issue

See above

What component(s) does this issue relate to?

Runtime

Version information

iree.git @ 4d6c2b8 (I have a couple trivial local modifications, but should be unrelated to this bug)

Additional context

No response

Activity

  1. added
    bug 🐞
    on May 10, 2023
  2. silvasean commented on May 10, 2023

    @silvasean
    ContributorAuthor

    If I comment out the cuStreamSynchronize then the error gets attributed to:

    iree/runtime/src/iree/hal/drivers/cuda/stream_command_buffer.c:507: INTERNAL; CUDA driver error 'CUDA_ERROR_ILLEGAL_ADDRESS' (700): an illegal memory access was encountered; cuLaunchKernel; while invoking native function hal.device.queue.execute; while calling import;
    
  3. silvasean commented on May 10, 2023

    @silvasean
    ContributorAuthor

    I suspect that this is due to a miscompile. Can somebody confirm that that is what this likely means? I will bisect it tomorrow.

  4. silvasean commented on May 10, 2023

    @silvasean
    ContributorAuthor

    It looks like it is likely due to running out of memory. It would be nice if we could diagnose this better. I will try a smaller variant of this model. However, it is important to note that this model runs successfully on XLA:GPU with the available memory (A100-40GB), so perhaps we can use this bug to guide improvements to our memory allocation strategy. I renamed the bug to reflect that.

  5. silvasean commented on May 10, 2023

    @silvasean
    ContributorAuthor

    I tried with --device_allocator=caching and got the same error.

  6. changed the title [-]cuStreamSynchronize: CUDA_ERROR_ILLEGAL_ADDRESS[/-] [+][CUDA] Improve memory allocation[/+] on May 10, 2023
  7. silvasean commented on May 11, 2023

    @silvasean
    ContributorAuthor

    Also if this is IREE's OOM failure mode, we should try to improve this, as it is really non-obvious. XLA:GPU gives a detailed diagnosis listing the buffers involved in the OOM situation and their sizes and names.

  8. kushanam commented on May 11, 2023

    @kushanam

    @silvasean I tried to repro the issue with the latest iree commit and I get
    LLVM ERROR: operation destroyed but still has uses while creating the vmfb file. Any ideas what might have I done wrong?

  9. stellaraccident commented on May 12, 2023

    @stellaraccident
    Collaborator

    That looks like the thing that Sean was working around by disabling the transform dialect for CUDA. I can't find the issue right now, but it is waiting until next week for the owner of the component to return from vacation.

  10. stellaraccident commented on May 12, 2023

    @stellaraccident
    Collaborator

    This one, I think: #13419

  11. kushanam commented on May 12, 2023

    @kushanam

    Thank you @stellaraccident!

  12. kushanam commented on May 12, 2023

    @kushanam

    @stellaraccident seems like I already tried the workaround which is also in the linked issue. Still getting the same error.

  13. silvasean commented on May 12, 2023

    @silvasean
    ContributorAuthor

    That is a separate issue tracked here: #13459
    I don't know why I am not hitting it in my particular setup.

  14. 65 remaining items

  15. moved this from Not Started to Done in (Deprecated) IREEon Jun 22, 2023
  16. added a commit that references this issue on Jun 25, 2023
    839c1c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug 🐞

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions