Skip to content

Fix overflow and dynamic pipeline remainder loop start#1061

Open
xintin wants to merge 3 commits intomainfrom
xintin/fix_overflow_and_dynamic_pipeline_remainder_loop_start
Open

Fix overflow and dynamic pipeline remainder loop start#1061
xintin wants to merge 3 commits intomainfrom
xintin/fix_overflow_and_dynamic_pipeline_remainder_loop_start

Conversation

@xintin
Copy link
Contributor

@xintin xintin commented Mar 6, 2026

  • In schedule.py, build_guarded_pipeline_with_remainder generates this structure:
if (max_iv >= num_stages + unroll_factor - 1):    // guard
    result = pipeline(prologue + kernel + epilogue)
else:
    result = init_values

remainder_loop(start=pipelined_iterations, count=max_iv, init=result)

The remainder loop always starts at pipelined_iterations, regardless of whether the guard was true or false. When the guard is false (the pipeline didn't run), the start should be 0, not pipelined_iterations.

  • Buffer offset calculations used signed 32-bit limits (2^31 - 1), capping addressable memory at ~2 GB. This patch switches to unsigned 32-bit limits (2^32 - 1) to support up to ~4 GB, and drops the nsw (no-signed-wrap) overflow flag on offset arithmetic so the compiler doesn't misoptimize offsets above the signed range.

  • Updated buffer size constants for i8 type (2147483646 to 4294967294), OOB index dense constant (2147483647 to 4294967295), validBytes constant (2147483646 to 4294967294). Updated f16, f32, i32 buffer sizes.

@xintin xintin force-pushed the xintin/fix_overflow_and_dynamic_pipeline_remainder_loop_start branch 2 times, most recently from affcf72 to 01bb2aa Compare March 6, 2026 03:58
@xintin xintin requested a review from harsh-nod March 6, 2026 03:59
@xintin xintin force-pushed the xintin/fix_overflow_and_dynamic_pipeline_remainder_loop_start branch from 6a0eaeb to 04b34b5 Compare March 6, 2026 05:14
xintin added 2 commits March 6, 2026 05:18
Signed-off-by: xintin <gaurav.verma@amd.com>
Signed-off-by: xintin <gaurav.verma@amd.com>
@xintin xintin force-pushed the xintin/fix_overflow_and_dynamic_pipeline_remainder_loop_start branch from 04b34b5 to b26d3b3 Compare March 6, 2026 05:19
@xintin xintin marked this pull request as draft March 6, 2026 05:29
@xintin xintin marked this pull request as ready for review March 6, 2026 05:36
@xintin xintin force-pushed the xintin/fix_overflow_and_dynamic_pipeline_remainder_loop_start branch from 26d9fa6 to 53d89ff Compare March 6, 2026 05:46
Signed-off-by: xintin <gaurav.verma@amd.com>
@xintin xintin force-pushed the xintin/fix_overflow_and_dynamic_pipeline_remainder_loop_start branch from 53d89ff to 7660835 Compare March 6, 2026 06:25
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