Skip to content

Fix dynamic pipeline remainder loop start#1067

Merged
xintin merged 5 commits intomainfrom
xintin/fix_dynamic_pipeline_remainder_loop_start
Mar 6, 2026
Merged

Fix dynamic pipeline remainder loop start#1067
xintin merged 5 commits intomainfrom
xintin/fix_dynamic_pipeline_remainder_loop_start

Conversation

@xintin
Copy link
Contributor

@xintin xintin commented Mar 6, 2026

When max_iv < rounding_stride the pipeline conditional returns init values and the remainder loop must start from 0 instead of pipelined_iterations. Use sympy.Piecewise to pick the correct start.

  • 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.

When max_iv < rounding_stride the pipeline conditional returns init
values and the remainder loop must start from 0 instead of
pipelined_iterations. Use sympy.Piecewise to pick the correct start.

Signed-off-by: xintin <gaurav.verma@amd.com>
Made-with: Cursor
@xintin xintin force-pushed the xintin/fix_dynamic_pipeline_remainder_loop_start branch 2 times, most recently from 41fa709 to 2fe13c4 Compare March 6, 2026 18:11
Signed-off-by: xintin <gaurav.verma@amd.com>
@xintin xintin force-pushed the xintin/fix_dynamic_pipeline_remainder_loop_start branch from 2fe13c4 to 59eb6de Compare March 6, 2026 18:13
@xintin
Copy link
Contributor Author

xintin commented Mar 6, 2026

waiting for ci to pass. saw a couple flaky test failures in the earlier PR.
if it is not flaky, i will fix them before merging.

Signed-off-by: xintin <gaurav.verma@amd.com>
@xintin xintin merged commit c130b5e into main Mar 6, 2026
17 checks passed
@xintin xintin deleted the xintin/fix_dynamic_pipeline_remainder_loop_start branch March 6, 2026 20:22
willghatch added a commit that referenced this pull request Mar 6, 2026
This builds on PRs #1061, #1063, and #1067 to get the block size 256x224x256 working for the list of shapes we were looking at today.

Signed-off-by: William G Hatch <william@hatch.uno>
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.

2 participants