今回NVIDIAの量子コンピュータSDKを利用する際のcuQuantum23.10がアップデートされましたので、今回その内容を確認したいと思います。
こちらのソフトウェア開発キットにおいては主に3つのパートに分かれています。1つはcuStateVecと呼ばれる状態ベクトルシュミレーターと呼ばれるシュレーターです。こちらは伝統的なシュミレーターとなっていまして、cuQuantumのコアパートとなっています。もう1つは、cuTensorNetと呼ばれる新しいシミュレーターとなっていまして、こちらは伝統的なものとは違って新しいものとなっていて使い方は少しコツが必要です。最後がそれら2つのシュミレーターを操作するためのPythonのラッパーとなっていて、こちらはcuQuantum Pythonと言う名前で更新がされています。主にこの3つが更新されていますので確認したいと思います。
リリースノート
https://docs.nvidia.com/cuda/cuquantum/latest/cuquantum_sdk_release_notes.html#cuquantum-sdk-v23-10
こちらにあります。
cuStateVecは1.5.0です。
https://docs.nvidia.com/cuda/cuquantum/latest/custatevec/release_notes.html#custatevec-v1-5-0
¶
cuStateVec v1.5.0- Added new API:
- Migration of sub state vectors (see Host state vector migration and custatevecSubSVMigratorMigrate())
- Improved performance/functionality:
- Improved the performance of custatevecApplyPauliRotation().
- Resolved issues:
- Fixed an issue that custatevecMultiDeviceSwapIndexBits() accepted wrong index bit positions specified to the indexBitSwaps argument. If the indexBitSwaps argument is properly given, the function works properly.
まずはcuStateVecです。一つは新しいAPIのようです。大事ですね。二つ目はパフォーマンスの向上です。三つ目はイシューの解決なので、三つ目は飛ばして前の二つを見ます。
APIに関しては、結構大きなアップデートです。最近NVIDIAはCPUにも参入していて、Grace CPUをリリースしています。そうしたGraceにも対応したリリースに見えます。
まずは概要の解説が下記のサイトにあります。
https://docs.nvidia.com/cuda/cuquantum/latest/custatevec/host_state_vector_migration.html
ホスト状態ベクトルの移行について
cuStateVecライブラリはcustatevecSubSVMigrator APIを提供し、ユーザーがホストCPUメモリとデバイスGPUメモリを組み合わせてシミュレーションの規模を拡大できるようになったようです。Grace HopperのCPUもGPUも効率的に使え、さらに量子コンピュータのシミュレーションが高速になりそうな気がします。
custatevecSubSVMigrator API
custatevecSubSVMigrator APIは、CPU(ホスト)上に割り当てられた状態ベクトルと、さらにGPU(デバイス)上に割り当てられた状態ベクトルを移行するためのユーティリティです。このAPIを使うことで、CPUメモリを活用して状態ベクトルを収容することができます。また、CPUとGPUの両方のメモリを利用して単一の状態ベクトルを割り当てることで、シミュレーションされる量子ビットの数を最大化することもできます。
なんか、APIはこちらに
cuTensorNetは2.3.0です。
https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/release_notes.html#cutensornet-v2-3-0
¶
cuTensorNet v2.3.0- New functionalities:
- New high-level APIs for defining tensor network operators and computing their expectation values over user-defined tensor network states.
- See the introduction at High-level tensor network specification and processing.
- New high-level APIs for computing arbitrary slices of tensor network states.
- New high-level APIs for computing the Matrix-Product-State (MPS) factorization of a given tensor network state.
- New truncation option CUTENSORNET_TENSOR_SVD_CONFIG_DISCARDED_WEIGHT_CUTOFF for tensor SVD computation.
- Bugs fixed:
- Fix a bug when the automatic distributed contraction path optimization is invoked with the TIME as a cost function to ensure the optimal path is chosen.
- Fix a bug for potentially inconsistent library handles management when cutensornetWorkspaceComputeSVDSizes(), cutensornetWorkspaceComputeQRSizes() and cutensornetWorkspaceComputeGateSplitSizes() are called.
- Fix a bug for cutensornetTensorQR() when the combined matrix row/column extent of the input tensor equals 1.
- Fix a performance bug when the tensor network contraction path finder is run by multiple processes on the same node.
- Other changes:
- Complex-valued gradients computed with the experimental API cutensornetComputeGradientsBackward() are complex conjugated now, as compared to what would be returned in the previous release.
2番目はバグ修正として、最初と最後が気になります。
量子分野およびその他の分野で遭遇するテンソルネットワークの仕様と処理を簡素化するために、cuTensorNetはユーザーが与えられたテンソルネットワーク状態を徐々に構築し、その後その特性を計算するための高レベルAPI関数のセットを提供します。
主に、スライシングやMPSの分解などでのAPIの提供があるようです。SVDに関しては新しい分解のオプションが。
最後のOther changesはかなり気になる機能です。複素数における勾配の計算がExperimentalで出ています。機械学習などで勾配を求める際には、量子コンピュータの場合には複素数ですので一般のライブラリなどでは非対応の場合もありますので。
最後にcuQuantum Pythonを見ます。
https://docs.nvidia.com/cuda/cuquantum/latest/python/release_notes.html#cuquantum-python-v23-10-0
¶
cuQuantum Python v23.10.0- Add new APIs and functionalities:
- For low-level APIs, please refer to the release notes of cuStateVec v1.5.0 and cuTensorNet v2.3.0.
- The function cuquantum.contract() now works like a native PyTorch operator as far as autograd is concerned, if the input operands are PyTorch tensors. This is an experimental feature.
- A new, experimental method cuquantum.Network.gradients() is added for computing the gradients of the network with respect to the input operands.
- If the gradients are complex-valued, the convention follows that of PyTorch’s.
- Added a new attribute cuquantum.cutensornet.tensor.SVDMethod.discarded_weight_cutoff to allow SVD truncation based on discarded weight.
- The cuquantum.Network constructor and its reset_operands() method now accept an optional stream argument.
- Bugs fixed:
- Fix potential data corruption when reset_operands() is called when the provided operands don’t outlive the contraction operation.
- For the case of using CPU arrays (from NumPy/PyTorch) as input operands for contraction, the internal streams were not be properly ordered.
- The methods autotune(), contract() and the standalone function contract() allow passing the pointer address for the stream argument, as promised in the docs.
- The attribute dtypes for cuquantum.cutensornet.MarginalAttribute.OPT_NUM_HYPER_SAMPLES and cuquantum.cutensornet.SamplerAttribute.OPT_NUM_HYPER_SAMPLES are fixed.
- Other changes:
- If Python logging is enabled, cuTensorNet’s run-time (instead of build-time) version is reported.
- For passing PyTorch tensors to contraction APIs, the tensor flags .is_conj() and .requires_grad are now taken into account, unless a user explicitly overwrites them with the qualifiers argument.
今回もバグ修正以外を見ます。当然ですが、cuStateVecとcuTensorNet関連のAPIの話がありました。また、PyTorchのTensorにも対応したようです。Torch Tensorのようなオブジェクトで自動微分情報が設定されててもいけるようです。あとは、先ほどcuStateVecやcuTensorNetでふれた内容をサポートしてます。
どうでしょう。結構大きな変更はCPUとGPUに関してGrace Hopperを意識したアップデート、PyTorchなどの既存機械学習フレームワークとの互換性を考えて複素数の微分ができるようになっていて、勾配計算が楽になりそうです。以上です。