heir icon indicating copy to clipboard operation
heir copied to clipboard

Reconsider "application data" field on LWE ciphertext

Open j2kun opened this issue 2 months ago • 3 comments

Now that we have (nearly) completed the packing system, the application_data attribute on an LWE ciphertext type is currently only used for the debug handler framework, so that the debug handler can understand how to unpack to print cleartext values.

With the changes in https://github.com/google/heir/pull/2199 to use multi-packed ciphertexts by default, the best we will be able to do with this attribute is to print the packed cleartext values (because the remainder of the logic of how to unpack is not present on the LWE ciphertext type).

We should remove the application data field, and instead adapt the debug handler framework so that it is aware of the new layout system, and insert secret.reveal/tensor_ext.unpack ops appropriately that can be lowered automatically.

j2kun avatar Sep 30 '25 22:09 j2kun

I agree that the shapes of the application data can be inferred from the packing, but do we still need to hold on to the underlying data type? I would keep this open until we do some non-trivial type casting, e.g. from an i32 quantized model to an f32 CKKS model. But maybe that still doesn't change anything in the system? Maybe just for evaluations?

asraa avatar Oct 01 '25 14:10 asraa

That is a good point, I hadn't considered something like encoding i64 in i16 as part of this, but it would be required to enable the full unpacking/decoding in the debug helper

j2kun avatar Oct 01 '25 19:10 j2kun

This issue has 2 outstanding TODOs:

This comment was autogenerated by todo-backlinks

github-actions[bot] avatar Oct 10 '25 17:10 github-actions[bot]