This repository packages extracted Number Theoretic Transform RTL variants from YATA and HOGE with small Verilator tests that compare against the current TFHEpp C++ reference headers.
variants/yata-raintt: YATA compressed 27-bit RAINTTNTTandINTT.variants/hoge-streaming: HOGE streaming 64-bit INTT plus an NTT wrapper.variants/hoge-externalproduct: HOGE ExternalProduct pipeline used as the executable forward NTT oracle.variants/hoge-nttid: HOGE full-vector NTT/INTT identity pipeline.third_party/TFHEpp: TFHEpp submodule used as the C++ reference.docs/ntt-module-specs.md: top-level module specifications for generating replacement Verilog that passes the included tests.tasks/: machine-readable benchmark task manifests for architecture search.docs/architecture-search-space.mdanddocs/scoring.md: search knobs and evaluation rules.examples/autontt/: AutoNTT-oriented mapping notes and custom reduction examples.
The copied YATA and HOGE RTL is AGPL-3.0 licensed. See NOTICE.md and
licenses/.
Install sbt, cmake, ninja, clang++, and verilator, then run:
git submodule update --init --recursive
scripts/run_all.shThe script generates Verilog with sbt run, configures CMake with Clang, builds
the Verilator harnesses, and runs CTest.
Build the container:
apptainer build --mksquashfs-args "-processors 1" llm-ntt.sif apptainer/llm-ntt.defRun the same build and test flow inside the container:
apptainer run --no-home --pwd /work --bind "$(pwd):/work" llm-ntt.sifThe %runscript expects the repository to be mounted at /work. The
single-threaded squashfs argument avoids mksquashfs orderer failures observed
on some unprivileged Apptainer hosts.
Generate Verilog only:
scripts/gen_verilog.shBuild and test after Verilog generation:
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
cmake --build build
ctest --test-dir build --output-on-failureEvaluate a single benchmark task, using the extracted RTL as the baseline:
scripts/evaluate_candidate.sh --task hoge_streaming_intt_1024_p64Evaluate candidate Verilog in a directory:
scripts/evaluate_candidate.sh \
--task hoge_streaming_intt_1024_p64 \
--verilog-dir candidate/hoge-inttAdd an optional flattened Yosys structural estimate:
scripts/evaluate_candidate.sh \
--task hoge_externalproduct_ntt_1024_p64 \
--with-yosysyata_raintt_reference_test: compares streamed YATAINTTandNTTagainstraintt::TwistINTT/raintt::TwistNTTwithUSE_COMPRESS. INTT input lanelat cycleccarries coefficientl * 8 + c; NTT output lanelat cycleccorresponds to coefficientl * 8 + c.hoge_streaming_reference_test: drives HOGEINTTWrapand compares againstcuHEpp::TwistINTT.hoge_externalproduct_ntt_reference_test: drives HOGEExternalProductWrapand compares the final 32-bit torus output against TFHEppExternalProduct<lvl1param>, whose final boundary isTwistNTT.hoge_nttid_identity_test: drives HOGENTTidand checks that the combined INTT/NTT pipeline returns the original polynomial moduloP.
The HOGE forward NTTWrap manifest, hoge_streaming_ntt_1024_p64, is a
lint-only tier0 interface task. Use hoge_externalproduct_ntt_1024_p64 for
HOGE forward NTT arithmetic and latency comparisons.