Add exact tensor network C++ backend to LT #2592
This file contains 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
name: Testing::x86_64::Windows:C++ | |
on: | |
workflow_call: | |
inputs: | |
lightning-version: | |
type: string | |
required: true | |
description: The version of Lightning to use. Valid values are either 'release' (most recent release candidate), 'stable' (most recent git-tag) or 'latest' (most recent commit from master) | |
pennylane-version: | |
type: string | |
required: true | |
description: The version of PennyLane to use. Valid values are either 'release' (most recent release candidate), 'stable' (most recent git-tag) or 'latest' (most recent commit from master) | |
push: | |
branches: | |
- master | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
paths: | |
- .github/workflows/tests_windows_cpp.yml | |
- pennylane_lightning/core/src/** | |
- '!pennylane_lightning/core/src/simulators/lightning_gpu/**' | |
concurrency: | |
group: tests_windows_cpp-${{ github.ref }}-${{ github.event_name }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} | |
cancel-in-progress: true | |
jobs: | |
win-set-matrix-x86: | |
if: github.event.pull_request.draft == false | |
name: Set builder matrix | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout PennyLane-Lightning | |
uses: actions/checkout@v4 | |
- name: Kokkos execution strategy | |
id: exec_model | |
run: echo "exec_model=[\"SERIAL\"]" >> $GITHUB_OUTPUT # We may also adopt [OPENMP, THREADS] in later iterations | |
- name: Kokkos version | |
id: kokkos_version | |
run: echo "kokkos_version=[\"4.5.00\"]" >> $GITHUB_OUTPUT | |
outputs: | |
exec_model: ${{ steps.exec_model.outputs.exec_model }} | |
kokkos_version: ${{ steps.kokkos_version.outputs.kokkos_version }} | |
build_dependencies_kokkos: | |
needs: [win-set-matrix-x86] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest] | |
exec_model: ${{ fromJson(needs.win-set-matrix-x86.outputs.exec_model) }} | |
kokkos_version: ${{ fromJson(needs.win-set-matrix-x86.outputs.kokkos_version) }} | |
timeout-minutes: 30 | |
name: Build Kokkos core (kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Cache installation directories | |
id: kokkos-cache | |
uses: actions/cache@v4 | |
with: | |
path: D:\a\install_dir\${{ matrix.exec_model }} | |
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-Debug | |
- name: Clone Kokkos libs | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
cd D:\a | |
git clone --branch ${{ matrix.kokkos_version }} https://github.com/kokkos/kokkos.git | |
- name: Create installation directory | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
Remove-Item -Path D:\a\install_dir\${{ matrix.exec_model }} -Recurse -Force -ErrorAction Ignore | |
mkdir -p D:\a\install_dir\${{ matrix.exec_model }} | |
- name: Install dependencies | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
python -m pip install cmake build | |
- name: Build Kokkos core library | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
cd D:\a\kokkos | |
cmake -BBuild . -DCMAKE_INSTALL_PREFIX=D:\a\install_dir\${{ matrix.exec_model }} ` | |
-DKokkos_ENABLE_COMPLEX_ALIGN=OFF ` | |
-DKokkos_ENABLE_SERIAL=ON ` | |
-DKokkos_ENABLE_${{ matrix.exec_model }}=ON ` | |
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF ` | |
-DCMAKE_CXX_STANDARD=20 ` | |
-DCMAKE_POSITION_INDEPENDENT_CODE=ON ` | |
-DCMAKE_BUILD_TYPE=Debug ` | |
-T clangcl | |
cmake --build ./Build --config Debug --verbose | |
cmake --install ./Build --config Debug --verbose | |
cpptests: | |
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) && github.event.pull_request.draft == false}} | |
timeout-minutes: 30 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest] | |
pl_backend: ["lightning_qubit"] | |
name: C++ Tests (${{ matrix.pl_backend }}, on-${{ matrix.os }}) | |
steps: | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: '3.10' | |
- name: Checkout PennyLane-Lightning | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
python -m pip install cmake build ninja scipy | |
- name: Setup OpenCppCoverage and add to PATH | |
run: | | |
choco install OpenCppCoverage -y | |
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH | |
- name: Build and run unit tests for code coverage | |
run: | | |
cmake -BBuild ` | |
-DBUILD_TESTS=ON ` | |
-DENABLE_OPENMP=OFF ` | |
-DENABLE_PYTHON=OFF ` | |
-DENABLE_GATE_DISPATCHER=OFF ` | |
-DPL_BACKEND=${{ matrix.pl_backend }} ` | |
-DENABLE_WARNINGS=OFF | |
cmake --build .\Build --config RelWithDebInfo | |
mkdir -p .\Build\tests\results | |
$test_bins = Get-ChildItem -Include *.exe -Recurse -Path ./Build/RelWithDebInfo | |
foreach ($file in $test_bins) | |
{ | |
$filename = $file.ToString() -replace '.{4}$' | |
$filename = $filename.Substring($filename.LastIndexOf("\")+1) | |
$test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml" | |
Invoke-Expression $test_call | |
$cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --excluded_modules D:\a\install_dir\* --excluded_modules C:\Windows\System32\* --export_type cobertura:coverage.xml " + $file.ToString() | |
Invoke-Expression $cov_call | |
} | |
Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }} | |
path: .\Build\tests\results\ | |
retention-days: 1 | |
if-no-files-found: error | |
include-hidden-files: true | |
- name: Upload coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-coverage-report | |
path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml | |
retention-days: 1 | |
if-no-files-found: error | |
include-hidden-files: true | |
cpptestswithkokkos: | |
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} | |
needs: [build_dependencies_kokkos, win-set-matrix-x86] | |
strategy: | |
matrix: | |
os: [windows-latest] | |
pl_backend: ["lightning_kokkos"] | |
exec_model: ${{ fromJson(needs.win-set-matrix-x86.outputs.exec_model) }} | |
kokkos_version: ${{ fromJson(needs.win-set-matrix-x86.outputs.kokkos_version) }} | |
timeout-minutes: 30 | |
name: C++ Tests (${{matrix.pl_backend}}, on-${{ matrix.os }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: '3.10' | |
- name: Restoring cached Kokkos | |
id: kokkos-cache | |
uses: actions/cache@v4 | |
with: | |
path: D:\a\install_dir\${{ matrix.exec_model }} | |
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-Debug | |
- name: Install dependencies | |
run: | | |
python -m pip install cmake build ninja | |
- name: Checkout PennyLane-Lightning | |
uses: actions/checkout@v4 | |
- name: Copy cached Kokkos libraries | |
if: steps.kokkos-cache.outputs.cache-hit == 'true' | |
run: | | |
Copy-Item -Path "D:\a\install_dir\${{ matrix.exec_model }}\" ` | |
-Destination "D:\a\pennylane-lightning\pennylane-lightning\Kokkos" -Recurse -Force | |
- name: Enable long paths | |
run: | | |
powershell.exe New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force | |
- name: Setup OpenCppCoverage and add to PATH | |
run: | | |
choco install OpenCppCoverage -y | |
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH | |
- name: Build and run unit tests for code coverage | |
run: | | |
Subst Z: (pwd) | |
Set-Location -Path "Z:\" | |
cmake -BBuild ` | |
-DBUILD_TESTS=ON ` | |
-DENABLE_PYTHON=OFF ` | |
-DENABLE_GATE_DISPATCHER=OFF ` | |
-DCMAKE_PREFIX_PATH=D:\a\pennylane-lightning\pennylane-lightning\Kokkos ` | |
-DENABLE_OPENMP=OFF ` | |
-DPL_BACKEND=${{ matrix.pl_backend }} ` | |
-DENABLE_WARNINGS=OFF -T clangcl | |
cmake --build .\Build --config Debug -- /p:UseMultiToolTask=true /p:EnforceProcessCountAcrossBuilds=true /p:MultiProcMaxCount=2 | |
mkdir -p .\Build\tests\results | |
$test_bins = Get-ChildItem -Include *.exe -Recurse -Path ./Build/Debug | |
foreach ($file in $test_bins) | |
{ | |
$filename = $file.ToString() -replace '.{4}$' | |
$filename = $filename.Substring($filename.LastIndexOf("\")+1) | |
$test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml" | |
Invoke-Expression $test_call | |
$cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --excluded_modules D:\a\install_dir\* --excluded_modules C:\Windows\System32\* --export_type cobertura:coverage.xml " + $file.ToString() | |
Invoke-Expression $cov_call | |
} | |
Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }} | |
path: .\Build\tests\results\ | |
retention-days: 1 | |
if-no-files-found: error | |
include-hidden-files: true | |
- name: Upload coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-coverage-report-${{ matrix.pl_backend }} | |
path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml | |
retention-days: 1 | |
if-no-files-found: error | |
include-hidden-files: true | |
upload-to-codecov-windows: | |
needs: [cpptests, cpptestswithkokkos] | |
name: Upload coverage data to codecov | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download coverage reports | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: windows-coverage* | |
merge-multiple: true | |
- name: Upload to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
verbose: true | |
token: ${{ secrets.CODECOV_TOKEN }} |