MP-SPDZ icon indicating copy to clipboard operation
MP-SPDZ copied to clipboard

Inconsistent results with small unrolling budgets

Open sebw42 opened this issue 2 months ago • 3 comments

Describe the bug Hi, I've noticed an issue with setting loop unrolling budgets. When setting the budget to a low number of iterations, e.g. -b 10, the following program behaves unexpectedly, even though it's loop only has 2 iterations:

arr = cint.Array(3)
arr.assign([0, 1, 2])

@for_range_opt(2)
def _(i):
    arr[1 + i] = arr[1 - i]

print_ln('%s', arr)

The second iteration of the loop (that sets arr[2] to arr[0]) seems to not be executed. It works as expected with a higher budget (e.g. -b 100).

Thanks for having a look!

To Reproduce Compilation: python3 compile.py test_program -b 10 Compilation: Scripts/mascot.sh test_program

Expected behavior Expected output: [0, 1, 0]

Error message Actual output: [0, 1, 2]

MP-SPDZ version Commit: 1986dce374727a6bb334001b18e0f1d598bea51a

Additional context /

sebw42 avatar Oct 14 '25 09:10 sebw42

Thank you for raising this. You should find that 7e576fab0d5274961ca64d0c4dd8c6082b572565 fixes it.

mkskeller avatar Oct 16 '25 02:10 mkskeller

Hi, thank you for fixing this! The program above now works with a small budget. However, I've noticed that compiling with the (larger) standard budget (python3 compile.py test_program) and executing as before now results in the incorrect output [0 ,1, 2]. Thanks for looking into this!

sebw42 avatar Oct 22 '25 07:10 sebw42

You should find that 383c18f1cb fixes that.

mkskeller avatar Oct 29 '25 22:10 mkskeller