Skip to content

Support level reduction interface for multiple secret operands - #3324

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_962185352
Aug 10, 2026
Merged

Support level reduction interface for multiple secret operands#3324
copybara-service[bot] merged 1 commit into
mainfrom
test_962185352

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Support level reduction interface for multiple secret operands

This is intended to support an eager (greedy) bootstrap placement pass earlier in the pipeline, by treating linalg ops and polynomial evaluation ops all as atomic, ensuring bootstraps aren't inserted mid-loop.

To support that, we need to know at level analysis time which of the (potentially multiple) operands of a linalg op are secret. For ops like ct-ct mul, this is a hard requirement, and for ops like matvec, we have seen cases where the vector or the matrix can be secret while the other is plaintext.

@copybara-service
copybara-service Bot force-pushed the test_962185352 branch 2 times, most recently from c18ec95 to 1bb8df9 Compare August 10, 2026 17:08
@copybara-service copybara-service Bot changed the title Support level reduction interface for linalg ops Support level reduction interface for multiple secret operands Aug 10, 2026
@j2kun
j2kun requested a review from mdgrs August 10, 2026 17:12
@copybara-service
copybara-service Bot force-pushed the test_962185352 branch 2 times, most recently from 280ca75 to aa3e7c4 Compare August 10, 2026 19:12
linalg::Conv1DNcwFcwOp::attachInterface<
LinalgReducesLevelOpInterfaceModel<linalg::Conv1DNcwFcwOp>>(*ctx);
linalg::Conv2DNhwcFhwcOp::attachInterface<
LinalgReducesLevelOpInterfaceModel<linalg::Conv2DNhwcFhwcOp>>(*ctx);

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.

The one that we work with in ConvertToCiphertextSemanctics and LayoutPropagation is instead NchwFchw. Why is this the conv2d that is registered?

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.

Fixed

levelVal = level.getInt();
} else if (level.isMaxLevel()) {
levelVal = levelBudget;
} else {

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.

What if it is Uninit or Invalid? is it right to continue, or should a bootstrap be added?

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.

I think both of these should trigger an error.

SmallVector<OpOperand*> getOperandsToReduce(
Operation* op, const DataFlowSolver* solver) const {
SmallVector<OpOperand*> result;
for (auto& operand : op->getOpOperands()) {

@mdgrs mdgrs Aug 10, 2026

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.

I don't know much about this, but my untrusty sidekick tells me that we should use getDpsInputOperands to avoid the outs accumulator that getOpOperands includes in the output

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.

You're right, but I think we only want to avoid the outs accumulator because we know that these ops will not reduce the level of the outs.

@copybara-service
copybara-service Bot force-pushed the test_962185352 branch 3 times, most recently from 226c98f to 2a731fa Compare August 10, 2026 23:39
This is intended to support an eager (greedy) bootstrap placement pass earlier in the pipeline, by treating linalg ops and polynomial evaluation ops all as atomic, ensuring bootstraps aren't inserted mid-loop.

To support that, we need to know at level analysis time which of the (potentially multiple) operands of a linalg op are secret. For ops like ct-ct mul, this is a hard requirement, and for ops like matvec, we have seen cases where the vector or the matrix can be secret while the other is plaintext.

PiperOrigin-RevId: 962442140
@copybara-service
copybara-service Bot merged commit b5fd466 into main Aug 10, 2026
@copybara-service
copybara-service Bot deleted the test_962185352 branch August 10, 2026 23:53
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