Skip to content

RotationAnalysis: model nested affine.for in arithmetic DAGs - #3354

Open
AlexanderViand wants to merge 1 commit into
mainfrom
alex/rotation-analyis-affine-for
Open

RotationAnalysis: model nested affine.for in arithmetic DAGs#3354
AlexanderViand wants to merge 1 commit into
mainfrom
alex/rotation-analyis-affine-for

Conversation

@AlexanderViand

Copy link
Copy Markdown
Collaborator

RotationAnalysis rebuilds an enclosing scf.for as an ArithmeticDag and enumerates the shifts its rotations use, so configure-crypto-context can generate exactly the Galois keys a program needs. DagBuilder covered scf.for, scf.if and the tensor ops, but not an affine.for nested in that reconstructed loop. The analysis still reports success, but the rotations inside the affine loop disappear.

This teaches DagBuilder to model constant-bound affine.for and affine.yield just like their scf counterparts. The lit test exercises both the induction variable and induction-variable-plus-constant forms inside an affine.for nested in scf.for; the unit test covers DAG evaluation directly.

(If you can't already tell from the language - this one is straight from the 🤖. It checks out to me and works for us, but I'm not sure if there are subtleties about either the RotationAnalysis or the DagBuilder I'm missing)

RotationAnalysis rebuilds an enclosing scf.for as an ArithmeticDag and
enumerates the shifts its rotations use, so configure-crypto-context can
generate exactly the Galois keys a program needs. DagBuilder covered scf.for,
scf.if and the tensor ops, but not an affine.for nested in that reconstructed
loop.

An unhandled nested op is resolved as an opaque variable, severing everything
upstream of it from the DAG root. The analysis still reports success, but the
rotations inside the affine loop disappear. On tcn, rotate(ct, %i + 64) over
%i = 1..5 therefore omitted the key for rotation 65 and failed at runtime.

Teach DagBuilder to model constant-bound affine.for and affine.yield just like
their scf counterparts. The lit test exercises both the induction variable and
induction-variable-plus-constant forms inside an affine.for nested in scf.for;
the unit test covers DAG evaluation directly.

This does not handle a rotation whose enclosing loop is a bare affine.for.
RotationAnalysis still rejects that case under TODO(#2712); this change only
prevents nested affine loops from severing an scf.for DAG.
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.

1 participant