Skip to content

Add printf buffer flush delay to EP_DEVICE_ASSERT#542

Open
yurekami wants to merge 1 commit intodeepseek-ai:mainfrom
yurekami:fix-device-assert-trap
Open

Add printf buffer flush delay to EP_DEVICE_ASSERT#542
yurekami wants to merge 1 commit intodeepseek-ai:mainfrom
yurekami:fix-device-assert-trap

Conversation

@yurekami
Copy link
Copy Markdown
Contributor

Summary

Problem

While PR #539 fixed the trap() function to delay before aborting, EP_DEVICE_ASSERT was still using raw asm("trap;") without any delay. This meant assertion failures in device code could still lose their printf output.

Solution

Added the same delay loop using NUM_TRAP_FLUSH_ITERATIONS and __nanosleep(NUM_WAIT_NANOSECONDS) before the trap instruction in EP_DEVICE_ASSERT.

Changes

  • csrc/kernels/exception.cuh - Added flush delay to EP_DEVICE_ASSERT macro

Test plan

  • Trigger a device assertion and verify the message is printed
  • Verify no performance impact on normal execution (delay only on error path)

Related to #480

🤖 Generated with Claude Code

Similar to the trap() function fix (PR deepseek-ai#539), this adds a delay before
the trap in EP_DEVICE_ASSERT to ensure printf buffer contents are
flushed before kernel termination.

This ensures assertion failure messages from device code are not lost
when the kernel aborts.

Related to deepseek-ai#480

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant