Skip to content

Add ILP bootstrap placement pass#2667

Merged
copybara-service[bot] merged 1 commit intogoogle:mainfrom
edwjchen:ilp-bootstrap
Mar 9, 2026
Merged

Add ILP bootstrap placement pass#2667
copybara-service[bot] merged 1 commit intogoogle:mainfrom
edwjchen:ilp-bootstrap

Conversation

@edwjchen
Copy link
Contributor

@edwjchen edwjchen commented Feb 18, 2026

This PR is an initial attempt at implementing a naive ILP-based bootstrap placement pass for more efficient bootstrap and secret-mgmt operation placement. The pass does not rely on the current secret-mgmt-insert-pass, as the pass initially solves for the level of each op, thereby determining the bootstrap and other secret-mgmt operation placement.

  • New pass --ilp-bootstrap-placement with option bootstrap-waterline
  • LIT tests: bootstrap_placement_comparison.mlir, ilp_relin_modreduce_placement.mlir.

At a high-level, the formulation is as follows:

  • Variables
    • the input level of each op, the output level of each op, and whether a bootstrap is placed on an op.
  • Constraints
    • Level bounds: 0 <= op.level <= bootstrapWaterline
    • Operand matching: operand levels must be equal
    • Multiplication: assumes multiplications consume 1 level
    • Non-mult: all other operations forward the operand level
    • Bootstrap (big-M): if bootstrap, then the output level is the bootstrapWaterline, otherwise the input level is forwarded to the output level.
  • Objective: minimize number of bootstrap operations

Note: This is still a naive ILP implementation and there are concerns yet to be addressed.

  • This ILP formulation relies on the assumption that every multiplication consumes a level. This can be relaxed with more fine-grain scale analysis, (e.g., that delays multiple multiplications before a rescale instruction).
  • The ILP formulation only considers the input and output level of each vertex. However, this misses potential level changes along edges (e.g., when two independent data paths converge at an op with a level mismatch). The assumption assumes a modReduce operation after every multiplication, and all operands levels are equal without additional modReduce operations.

These limitations will be addressed in the future.

@j2kun j2kun self-requested a review February 21, 2026 03:50
Copy link
Collaborator

@j2kun j2kun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good! I have a few performance comments on the ILP, one major organizational comment on the IR update itself, and the rest are nitpicks.

@edwjchen edwjchen force-pushed the ilp-bootstrap branch 3 times, most recently from 3bc02ba to 916396a Compare March 9, 2026 02:09
@j2kun
Copy link
Collaborator

j2kun commented Mar 9, 2026

Please run pre-commit run --all-files to fix the linter errors. You can set it up to run automatically as a git hook via https://heir.dev/docs/development/#pre-commit

- New pass: --ilp-bootstrap-placement with option bootstrap-waterline
- Debug: -debug-only=ilp-bootstrap-placement (output model constraints and solution)
- Tests: bootstrap_placement_comparison.mlir, ilp_relin_modreduce_placement.mlir
@edwjchen
Copy link
Contributor Author

edwjchen commented Mar 9, 2026

Please run pre-commit run --all-files to fix the linter errors. You can set it up to run automatically as a git hook via https://heir.dev/docs/development/#pre-commit

Updated!

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Mar 9, 2026
@copybara-service copybara-service bot merged commit 6abb95e into google:main Mar 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants