Repository navigation
ML-KEM-1024 AArch64: NEON compress_encode and decode_decompress (d = 5, 11) - #2861
Merged
Merged
Conversation
… widths) The vector codecs' widths carry their addend and reach 11 bits, so the ML-KEM-1024 codecs (d = 5, 11) can use the steps and loops of ML-KEM-768's. The proofs of the ML-KEM-1024 codecs follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
…d = 5 iteration Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
…ed with d = 10 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
…11 decompression of a group Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
…ar stream lemmas Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #991.
This follows up #2772 (the NEON codecs for ML-KEM-768) for ML-KEM-1024's widths. On AArch64,
vg_mlkem1024_compress_encodeandvg_mlkem1024_decode_decompresswere scalar loops that handled one coefficient at a time. Both are now vector loops that handle 32 coefficients per iteration, reusing the 768 codecs' loop framework (Proof/MlKem/AArch64/CodecV/).Changes
Compress (
Impl/MlKem1024/AArch64/Compress.lean)(x · mul + add) >> 19 mod 2ᵈ, the same as for 768.Widthgains anaddfield:width5 = ⟨5, 8, 5, 5040, 261888⟩andwidth11 = ⟨11, 8, 11, 322542, 261888⟩.Compress_dfor everyx < qbycompress1024_eq.merge88). Three TBLs gather the 44 bytes, which are stored as 16 + 16 + 8 + 4 bytes.Decompress
ddSplit, now shared with 768's d = 10) and then into 5-bit values (dd5Quarter).dd11Group), whichddSplitsplits into 11-bit values.Shared framework (768)
These changes generalize the 768 framework to more widths. 768's generated code is unchanged.
WOkstates compression as(x · mul + add) / 2¹⁹ mod 2ᵈand allowsd ≤ 11.cmpV_oktakes the boundsmul ≤ 322542andadd < 2¹⁹.vloop_okanddloop_okleave room for the extra index and constant registers (v20–v23).ddSplit_okis factored out ofDd10.lean, for b = 10 or 11.Proofs
Proof/MlKem1024/AArch64/CodecV/, one iteration per width and direction:Ce5,Ce11,Dd5,Dd11, their*Stepfiles,Dword88andWidths.compressEncodeAArch64,decodeDecompressAArch64) and their theorem names.Stream.leanis deleted: only the scalar proofs used it.No changes to
TCB/orSpec/. The new code uses only instructions already in the AArch64 model.Speed
Neoverse N2, run 39238659055, compared with
main(dbfa7dd), with the fastest of the copies per side:mlkem1024_decapsmlkem1024_encapsmlkem1024_encaps_from_bytesmlkem1024_keygenChecks
These pass locally:
lake buildsrc/asm/aarch64/mlkem1024.rschanges)check_lean_imports,check_lean_modules,check_registrations,check_lean_speed,check_vectors,check_arch_gates,check_variants,check_mcdt,cpu_tests.py lintalgorithms_table.py(table unchanged)cargo fmt,clippyGenerated by Claude Code