Skip to content
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
1519286
Implement qir-qsim app for dynamic measurement handling
wongey Nov 6, 2024
177aaa4
Remove redudant qsim folder
wongey Nov 6, 2024
39223c3
Clean up results printing and output from Vicente
wongey Nov 6, 2024
c699ae4
Add dyanamic BV example from Vicente
wongey Nov 6, 2024
65054f2
Revert changes to upstream and remove tpls
sethrj Nov 22, 2024
63874bc
Update goldfinger configuration
sethrj Nov 22, 2024
91753d6
Add qsim
sethrj Nov 22, 2024
e289381
Update version to get include directories working
sethrj Nov 22, 2024
ac7c244
Run clang format
sethrj Nov 22, 2024
ece521f
Add qsim dynamicbv test
wongey Nov 25, 2024
713ace6
Merge branch 'ORNL-QCI:main' into qir-qsim
wongey Nov 25, 2024
a34f190
Capitalize class names q -> Q
wongey Nov 26, 2024
8fb40f3
Update qsim file names
wongey Nov 26, 2024
25d9433
Add examples
wongey Nov 26, 2024
22d0ac9
Minor formatting
wongey Nov 26, 2024
29be7ae
Resolve seed issue
wongey Nov 27, 2024
19867f3
Minor formatting
wongey Nov 27, 2024
ede6e4a
Update qsim unit test
wongey Nov 27, 2024
6fe3474
Refactor to move public to private types
wongey Nov 27, 2024
24a06bb
Unused variables and naming
sethrj Nov 27, 2024
aadbb8a
Use PIMPL
sethrj Nov 27, 2024
6f13b04
Delete tuple runtime, fix errors
sethrj Nov 27, 2024
35778ad
Fix qsim test
wongey Nov 27, 2024
8520063
Merge branch 'main' into qir-qsim
wongey Dec 13, 2024
4658b44
Merge branch 'main' into qir-qsim
wongey Dec 18, 2024
e77166c
Merge branch 'main' into qir-qsim
wongey Dec 18, 2024
6828673
Merge branch 'ORNL-QCI:main' into qir-qsim
wongey Dec 20, 2024
bdd35c4
including OutputDistribution into the libs list
vicenley Dec 23, 2024
cb373ba
old BufferManager now in qiree namespace
vicenley Dec 23, 2024
181737d
deleting the old BufferManager
vicenley Dec 23, 2024
a92aacf
updating libs list
vicenley Dec 23, 2024
040b834
updating manager (Buffer)
vicenley Dec 23, 2024
c5d2f04
REVERT ME Delete OutputDistribution and qsim app temporarily
wongey Jan 14, 2025
10ed1ae
Fix build (some to be reverted)
sethrj Jan 14, 2025
f5f54cc
Store results in a buffer for post-entrypoint retrieval
sethrj Jan 14, 2025
43c5b79
Add helper function
sethrj Jan 14, 2025
5e32f3e
add qirlightning runtime
josephleekl Jan 14, 2025
40c8fb7
add simple demo
josephleekl Jan 14, 2025
a76563c
Update README.md
josephleekl Jan 15, 2025
611fa66
remove catalyst runtime deps and update demo
josephleekl Jan 15, 2025
de4d402
Merge branch 'qir-lightning' of github.com:PennyLaneAI/qiree into qir…
josephleekl Jan 15, 2025
6c72907
remove redundant file
josephleekl Jan 15, 2025
6da98d3
update lightningquantum
josephleekl Jan 15, 2025
ceea8ac
Merge branch 'main' into qir-lightning
josephleekl Mar 10, 2025
7713cca
update
josephleekl Mar 10, 2025
e777b9c
format
josephleekl Mar 10, 2025
6caa667
support lightning
josephleekl Mar 10, 2025
422b3e7
add seeding
josephleekl Mar 11, 2025
7f6598a
update
josephleekl Mar 11, 2025
6246010
update
josephleekl Mar 12, 2025
88dbe30
update readme
josephleekl Mar 12, 2025
5a51303
Merge branch 'main' into qir-lightning
josephleekl Mar 12, 2025
99800fa
update readme
josephleekl Mar 12, 2025
3eb3002
update
josephleekl Mar 13, 2025
b8ec071
remove paths
josephleekl Mar 13, 2025
ce5d764
update
josephleekl Mar 13, 2025
13cdde7
Merge branch 'main' into qir-lightning
josephleekl Mar 13, 2025
b7b6aee
update installation instructions
josephleekl May 5, 2025
d15106b
update tests and GH workflow
josephleekl May 30, 2025
a10c915
Merge branch 'main' into qir-lightning
josephleekl Jun 17, 2025
227f5c6
update reset
josephleekl Jun 17, 2025
17bae43
Merge branch 'main' into qir-lightning
josephleekl Jun 24, 2025
cf66bdb
single-result update
josephleekl Jun 24, 2025
b5eb61b
Merge branch 'main' into qir-lightning
josephleekl Jul 18, 2025
f9b76ae
update lightnign installation instructions
josephleekl Jul 18, 2025
01dc855
Merge branch 'main' into qir-lightning
josephleekl Jul 19, 2025
5574e46
update shots to seed
josephleekl Jul 19, 2025
00080eb
update github workflow to run build-lightning
josephleekl Jul 22, 2025
aa25420
remove demo and pin catalyst
josephleekl Jul 30, 2025
cffe641
Merge branch 'main' into qir-lightning
josephleekl Oct 8, 2025
a93414e
update
josephleekl Oct 8, 2025
f8e43c5
update docs
josephleekl Oct 8, 2025
2602033
update private member names
josephleekl Oct 20, 2025
c8c6917
seth comments
josephleekl Oct 22, 2025
6737300
remove simple_demo
josephleekl Oct 22, 2025
b1344f7
remove build-lightning workflow
josephleekl Oct 22, 2025
290a7e8
remove build-lightning workflow
josephleekl Oct 22, 2025
d1d1c5c
improve formatting for cmake/support_catalyst.cmake
josephleekl Oct 22, 2025
a1736ce
Merge branch 'main' into qir-lightning
josephleekl Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/build-lightning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Build directly on the GitHub runner with caching
name: build-lightning
on:
workflow_dispatch:
workflow_call:

concurrency:
group: build-lightning-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}-${{github.workflow}}
cancel-in-progress: true

jobs:
linux:
name: ${{matrix.runner}}-${{matrix.compiler}}-${{matrix.version}}-llvm${{matrix.llvm}}
strategy:
matrix:
include:
- runner: jammy
compiler: gcc
version: 12
llvm: 14
- runner: jammy
compiler: clang
version: 15
llvm: 15
runs-on: >-
${{ matrix.runner == 'focal' && 'ubuntu-20.04'
|| matrix.runner == 'jammy' && 'ubuntu-22.04'
|| null
}}
env:
CCACHE_DIR: "${{github.workspace}}/.ccache"
CCACHE_MAXSIZE: "10G"
CC: ${{matrix.compiler}}-${{matrix.version}}
CXX: ${{matrix.compiler == 'gcc' && 'g++' || 'clang++'}}-${{matrix.version}}
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Install dependencies
run: |
sudo apt-get -q -y update
sudo apt-get -q -y install \
ccache cmake ninja-build libgtest-dev \
llvm-${{matrix.llvm}}-dev \
${{matrix.compiler}}-${{matrix.version}} \
${{matrix.compiler == 'gcc' && format('g++-{0}', matrix.version) || ''}}
echo "Installed toolchain:"
ld --version | head -1
$CC --version | head -1
$CXX --version | head -1
llvm-config-${{matrix.llvm}} --version | head -1
python -m pip install pennylane-lightning
- name: Check out
uses: actions/checkout@v4
- name: Set up ccache
uses: actions/cache@v4
with:
path: ${{env.CCACHE_DIR}}
key: ccache-${{matrix.runner}}-${{matrix.compiler}}-${{matrix.version}}-${{github.run_id}}
restore-keys: ccache-${{matrix.runner}}-${{matrix.compiler}}-${{matrix.version}}
- name: Zero ccache stats
run: |
ccache -z
- name: Configure
run: |
export LIGHTNING_SIM_PATH=$(python -c "import site; print( f'{site.getsitepackages()[0]}/pennylane_lightning')")/liblightning_qubit_catalyst.so
mkdir build && cd build
cmake -GNinja \
-DQIREE_GIT_DESCRIBE="${{github.event.pull_request
&& format(';-pr.{0};', github.event.pull_request.number)
|| format(';-{0};', github.ref_name)}}" \
-DQIREE_BUILD_TESTS:BOOL=ON \
-DQIREE_DEBUG:BOOL=ON \
-DQIREE_USE_XACC:BOOL=OFF \
-DQIREE_USE_LIGHTNING:BOOL=ON \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install" \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic" \
..
- name: Build all
working-directory: build
run: |
ninja
- name: Run tests
working-directory: build
run: |
ctest --parallel 2 --timeout 15 --output-on-failure
- name: Install
working-directory: build
run: |
ninja install
- name: Show ccache stats
run: |
ccache -s

# vim: set nowrap tw=100:
3 changes: 3 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ concurrency:
jobs:
build-fast:
uses: ./.github/workflows/build-fast.yml
build-lightning:
uses: ./.github/workflows/build-lightning.yml
# Specifying a dependent job allows us to select a single "requires" check in the project GitHub settings
all:
if: ${{ always() }}
needs:
- build-fast
- build-lightning
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ concurrency:
jobs:
build-fast:
uses: ./.github/workflows/build-fast.yml
build-lightning:
uses: ./.github/workflows/build-lightning.yml
all:
needs:
- build-fast
- build-lightning
runs-on: ubuntu-latest
steps:
- name: Success
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ endmacro()
option(QIREE_BUILD_DOCS "Build QIR-EE documentation" OFF)
option(QIREE_BUILD_TESTS "Build QIR-EE unit tests" ON)
option(QIREE_BUILD_EXAMPLES "Build QIR-EE examples" OFF)
option(QIREE_USE_QSIM "Download and build Google qsim backend" OFF)
option(QIREE_USE_XACC "Build XACC interface" ON)
option(QIREE_USE_QSIM "Download and build Google qsim backend" ON)
option(QIREE_USE_XACC "Build XACC interface" OFF)
option(QIREE_USE_LIGHTNING "Build Pennylane Lightning backend" OFF)

qiree_set_default(BUILD_TESTING ${QIREE_BUILD_TESTS})

Expand Down Expand Up @@ -137,6 +138,16 @@ if(QIREE_USE_QSIM)
)
endif()

if(QIREE_USE_LIGHTNING)
qiree_add_library(qiree_lightning INTERFACE)
add_library(QIREE::lightning ALIAS qiree_lightning)
target_include_directories(qiree_lightning SYSTEM INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/external>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/external>"
)
endif()


if(QIREE_USE_XACC)
find_package(XACC REQUIRED)
endif()
Expand Down
14 changes: 14 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ if(QIREE_USE_QSIM)
)
endif()

#-----------------------------------------------------------------------------#
# LIGHTNING FRONT END
#-----------------------------------------------------------------------------#

if(QIREE_USE_LIGHTNING)
qiree_add_executable(qir-lightning
qir-lightning.cc
)
target_link_libraries(qir-lightning
PUBLIC QIREE::qiree QIREE::qirlightning
PRIVATE CLI11::CLI11
)
endif()

#-----------------------------------------------------------------------------#
# XACC FRONT END
#-----------------------------------------------------------------------------#
Expand Down
74 changes: 74 additions & 0 deletions app/qir-lightning.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other QIR-EE developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//---------------------------------------------------------------------------//
//! \file app/qir-lightning.cc
//---------------------------------------------------------------------------//
#include <cstdlib>
#include <iostream>
#include <string>
#include <CLI/CLI.hpp>

#include "qiree/Executor.hh"
#include "qiree/Module.hh"
#include "qiree/ResultDistribution.hh"
#include "qirlightning/LightningQuantum.hh"
#include "qirlightning/LightningRuntime.hh"

using namespace std::string_view_literals;

namespace qiree
{
namespace app
{
//---------------------------------------------------------------------------//
void run(std::string const& filename, int num_shots)
{
// Load the input
Executor execute{Module{filename}};

// Set up qsim
LightningQuantum sim(std::cout, 0);
LightningRuntime rt(std::cout, sim);
ResultDistribution distribution;

// Run several time = shots (default 1)
for (int i = 0; i < num_shots; i++)
{
execute(sim, rt);
distribution.accumulate(rt.result());
}

std::cout << distribution.to_json() << std::endl;
}

//---------------------------------------------------------------------------//
} // namespace app
} // namespace qiree

//---------------------------------------------------------------------------//
/*!
* Execute and run.
*/
int main(int argc, char* argv[])
{
int num_shots{1};
std::string filename;

CLI::App app;

auto* filename_opt
= app.add_option("--input,-i,input", filename, "QIR input file");
filename_opt->required();

auto* nshot_opt
= app.add_option("-s,--shots", num_shots, "Number of shots");
nshot_opt->capture_default_str();

CLI11_PARSE(app, argc, argv);

qiree::app::run(filename, num_shots);

return EXIT_SUCCESS;
}
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ if(QIREE_USE_QSIM)
add_subdirectory(qirqsim)
endif()

if(QIREE_USE_LIGHTNING)
add_subdirectory(qirlightning)
endif()

#---------------------------------------------------------------------------##
69 changes: 69 additions & 0 deletions src/qirlightning/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#---------------------------------*-CMake-*----------------------------------#
# Copyright 2024 UT-Battelle, LLC, and other QIR-EE developers.
# See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#----------------------------------------------------------------------------#

# Fetch Catalyst runtime include files
include(FetchContent)

include("${CMAKE_CURRENT_SOURCE_DIR}/support_catalyst.cmake")
FindCatalyst(qirlightning)

# Set the path to the lightning simulator shared library
if(DEFINED ENV{LIGHTNING_SIM_PATH})
set(RTDLIB_PATH "$ENV{LIGHTNING_SIM_PATH}")
message(STATUS "RTDLIB_PATH set from environment variable LIGHTNING_SIM_PATH: ${RTDLIB_PATH}")
else()
# Throw an error if the environment variable is not defined
message(FATAL_ERROR "Environment variable LIGHTNING_SIM_PATH is not defined. Please set it to the path of the Lightning simulator shared library.")
endif()

# Set the device name for the lightning simulator
execute_process(
COMMAND nm -DC "${RTDLIB_PATH}" | grep " Factory"
OUTPUT_VARIABLE GREP_OUTPUT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(GREP_OUTPUT)
string(REGEX MATCH "T (.*)Factory" SYMBOL_MATCH "${GREP_OUTPUT}")
if(SYMBOL_MATCH)
string(REGEX REPLACE "T (.*)Factory" "\\1" RTDDEVICE_NAME "${SYMBOL_MATCH}")
message(STATUS "Found Lightning Simulator. Extracted RTDDEVICE_NAME: ${RTDDEVICE_NAME}")
else()
message(FATAL_ERROR "Symbol 'Factory' found, but regex failed to extract.")
endif()
else()
message(FATAL_ERROR "Symbol 'Factory' not found in ${RTDLIB_PATH}. Please ensure LIGHTNING_SIM_PATH is set correctly.")
endif()


# Adding lightning as a library to qiree
qiree_add_library(qirlightning
LightningQuantum.cc
LightningRuntime.cc
)

target_compile_definitions(qirlightning PRIVATE
RTDLIB="${RTDLIB_PATH}"
RTDDEVICE="${RTDDEVICE_NAME}"
)

#Link the lightning library to qiree and any other relevant libraries
target_link_libraries(qirlightning
PUBLIC QIREE::qiree # Link to qiree
PRIVATE QIREE::lightning
)

#----------------------------------------------------------------------------#
# HEADERS
#----------------------------------------------------------------------------#

# Install headers, matching the relevant .hh files for qsim integration
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qirlightning"
COMPONENT development
FILES_MATCHING REGEX ".*\\.hh?$"
)
Loading