This repository contains the research artifact for running and studying large language model (LLM) inference using the Intel/Altera FPGA AI Suite and Open FPGA Stack (OFS). Its primary contribution is TorchDLA, a PyTorch integration layer that captures supported operators, generates compilation artifacts, dispatches workloads to FPGA AI Suite kernels, and models end-to-end serving performance.
Vendor-provided components are governed by their respective licenses and are not distributed in this repository. Consequently, some source files and scripts reference paths, programs, or artifacts that are not included here. These references are retained to document the original research workflow. This repository is not intended to provide an out-of-the-box FPGA AI Suite installation.
To build or run the hardware-backed workflow, obtain the required FPGA AI Suite license and software from the official Altera FPGA AI Suite page, follow Altera's installation instructions, and update the paths in the provided scripts to match your local installation.
dla/: Placeholder for a user-provided FPGA AI Suite installation.scripts/: Shell workflows for preparing the host environment, building supporting software, compiling TorchDLA catalogs, configuring the FPGA, and running experiments.archive/: Host and dependency setup scripts for FPGA AI Suite, OFS, OPAE, DFL, OpenVINO, and OPAE simulation.dla/: Wrappers for FPGA AI Suite builds, device programming, inference, and debugging.pr/: Scripts for partial-reconfiguration setup and latency measurement.torch-dla/: Shell wrappers for the TorchDLA compiler, runtime, extension module, inference flow, and online serving entry points.Dockerfile,build_image.sh,update_image.sh, andrun_dev_docker.sh: Helpers for building and launching the development container.
torch_dla/: PyTorch-facing software stack implementation.compiler/: Graph capture, operator definitions, catalog generation, metadata handling, tiling exploration, and profiling.model/: Model adaptations for capturing and executing supported LLM operators.runtime/: Request scheduling, worker control, and serving orchestration.scripts/: Python entry points for compilation, inference, trace collection, serving, and latency replay.simulator/: Performance model for replaying latency traces and evaluating serving configurations with additional devices. Its scheduling and execution logic mirrors the end-to-end serving implementation inruntime/.torch_dla/csrc/: C++ PyTorch extension containing custom ATen operators and DLA runtime bindings.
.gitmodules: Official upstream URLs for the public OFS dependencies.SUBMODULES.txt: Record of submodule paths, official URLs, and upstream commit IDs.
The following steps provide an overview rather than a complete installation procedure for the vendor toolchain.
-
Install a supported Linux environment, the required FPGA development tools, and a licensed FPGA AI Suite release by following Altera's official instructions.
-
Review
SUBMODULES.txt, clone each listed repository at the recorded path, and check out the corresponding commit. For example:mkdir -p ofs git clone <url-from-SUBMODULES.txt> <path-from-SUBMODULES.txt> git -C <path-from-SUBMODULES.txt> checkout <commit-from-SUBMODULES.txt>
-
Install or extract FPGA AI Suite into
dla/, or update the scripts to reference an existing installation.
The development container can be built and launched from scripts/:
cd scripts
./build_image.sh
./run_dev_docker.shThe scripts in scripts/archive/ document the machine configuration used during development:
add_ofs_submodules.sh: Adds the upstream OFS repositories and checks out the recorded branches or tags.install_ai_suite_pkg.sh: Installs prerequisites and extracts a licensed FPGA AI Suite Debian package into a user-selecteddla/directory.install_dfl_driver.sh: Installs build dependencies, builds and installs thelinux-dfl-backportDKMS package, and reports driver status.install_dfl_kernel.sh: Builds and installs the OFS DFL Linux kernel using the repository's DFL configuration and recommended boot settings.install_opae_sdk.sh: Builds the recorded OPAE SDK revision and installs it under/usr.install_opae_sim.sh: Builds and installs the OPAE simulation library from the recorded OPAE simulator revision.install_openvino.sh: Downloads OpenVINO 2023.3, installs its dependencies under/opt/intel, installs the required Python development tools, and appends environment initialization commands to~/.bashrc.
The scripts in scripts/torch-dla/ assume that the vendor compiler, runtime, and required model files are already available:
build_runtime.sh: Creates a runtime workspace and builds the FPGA AI Suite runtime for the Agilex 7 I-Series development kit.build_module.sh: Copies the current TorchDLA sources into the workspace and builds the C++ PyTorch extension against the DLA runtime.create_workdir.sh: Builds the runtime, creates a Python virtual environment, copies TorchDLA into the workspace, and installs its Python dependencies.copy_to_workdir.sh: Synchronizestorch_dla/withworkspace/torch_dla/.compile.sh: Captures the selected model operators and compiles prefill and decode catalogs using the vendor DLA compiler.setup_afu.sh: Creates FPGA virtual functions and grants OPAE access to the configured PCI device. Run this script before starting any inference workload.run.sh: Runs direct model inference using previously compiled catalogs. ConfigureTORCH_DLA_PCI_ID,COREDLA_MMD_BOARD_NAME, andTORCH_DLA_DEVICE_STAGE_ORDERfor the target system.run_serving.sh: Launches the serving experiment with separate prefill and decode workers. Model paths, benchmark data, board identifiers, PCI addresses, CPU sets, and request-rate settings are specific to the experimental environment and must be configured accordingly.
Original code included in this export is released under the Apache License 2.0. See LICENSE for details. External FPGA AI Suite and OFS components are governed by their own licenses and are not covered by this repository's Apache License.