Skip to content

Computing expval and var with LightningTensor using quimb MPS #4700

Computing expval and var with LightningTensor using quimb MPS

Computing expval and var with LightningTensor using quimb MPS #4700

Workflow file for this run

name: Testing (Windows)
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:
concurrency:
group: tests_windows-${{ github.ref }}
cancel-in-progress: true
jobs:
win-set-matrix-x86:
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.2.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: Kokkos core (${{ 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) }}
timeout-minutes: 30
name: C++ tests (Windows)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
pl_backend: ["lightning_qubit"]
steps:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v3
- 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_LAPACK=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@v3
if: always()
with:
name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }}
path: .\Build\tests\results\
if-no-files-found: error
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: windows-coverage-report
path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
if-no-files-found: error
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 (Windows, Kokkos)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'
- 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@v3
if: always()
with:
name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }}
path: .\Build\tests\results\
if-no-files-found: error
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: windows-coverage-report
path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
if-no-files-found: error
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@v3
with:
name: windows-coverage-report
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}