Skip to content

Orbit: Level-dependent Cost Model - #3187

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
edwjchen:orbit-ilp-m0-review
Jul 16, 2026
Merged

Orbit: Level-dependent Cost Model#3187
copybara-service[bot] merged 1 commit into
google:mainfrom
edwjchen:orbit-ilp-m0-review

Conversation

@edwjchen

Copy link
Copy Markdown
Collaborator

Level-dependent cost model

orbit-cost-model=PATH loads a JSON cost model whose latencyTable maps
each key to a per-level latency array (index i = latency at level i + 1).
All keys are required:

  • bootstrap, rescale: constant per-decision costs in the objective
    (positive-sample average / per-level max), overriding the bootstrap-cost
    and rescale-cost options.
  • addCtCt, addCtPt, mulCtCt, mulCtPt, rotate, negate: each array
    is least-squares fitted to cost(level) = slope * level + intercept, and
    every tracked op is charged its fitted cost at its ILP-chosen input level.
    Ciphertext-ciphertext vs ciphertext-plaintext is decided per op from
    secretness analysis.

Solver configuration

The ILP is solved to a fixed 1% relative optimality gap with no time limit,
matching Orbit's solver setup (Gurobi MIPGap / CBC gapRel = 0.01).

@edwjchen
edwjchen requested a review from j2kun July 11, 2026 00:34

@j2kun j2kun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great work! Only minor nits and notes.

Comment thread lib/Analysis/ILPBootstrapPlacementAnalysis/ILPBootstrapPlacementAnalysis.cpp Outdated
const llvm::json::Array* latencies = latencyTable->getArray(opName);
// Read one op's per-level latency array (index i holds the latency at level
// i + 1).
static std::optional<SmallVector<double>> readLatencies(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just FYI, my intention is to eventually replace the json config/parsing code with a tablegen-based backend configuration.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good!

Comment thread lib/Transforms/ILPBootstrapPlacement/ILPBootstrapPlacement.cpp Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we have a real cost model file to use? I think it would be worth checking in at some point (doesn't have to be this PR)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps on a separate PR, I could pull in the cost modeling script used in Orbit for Lattigo? The gist of how it works is it finds the average latency of each HE operation at various levels.

On another note, it seems worthwhile to build a general cost model script for both the layout assignment, bootstrap placement, and any foreseeable optimization passes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, please see the neighboring PR on backend configuration: #2607

IMO the better long-term design does not compute any values on the fly, as in this PR, and instead the construction of the cost model and any postprocessing is a separate script from the loading and use in the compiler.

@edwjchen
edwjchen force-pushed the orbit-ilp-m0-review branch from cc88fec to d25f10c Compare July 13, 2026 23:49
@edwjchen
edwjchen requested a review from j2kun July 13, 2026 23:54
@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Jul 14, 2026
@j2kun

j2kun commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

For some reason it doesn't like my coauthorship on these commits. Please amend that commit and remove my coauthorship and it should get merged.

@edwjchen
edwjchen force-pushed the orbit-ilp-m0-review branch from d25f10c to b72a6a1 Compare July 16, 2026 08:59
@copybara-service
copybara-service Bot merged commit 1fcba2e into google:main Jul 16, 2026
11 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