2021年8月17日火曜日

Trip to Gumunden and Attersee

 ちょっとした夏休みの旅行ということで、2泊3日でグムンデンとアッター湖に行ってきました。
グムンデンは妻が食器を見たいということで、Gmundner Keramic を目標に、アッター湖はクリムトに興味があるとのことで Gustav Klimt Zentrumに。

食事は、初日の夕方はイワナを食べに、トラウン湖の西湖岸のGegrillte Steckerlfische Trawöger-Dorfnerにいき(食事は魚しか選択肢がない)、
二日目は私の要望で、Brot und Weinで(ハウスワインが超おすすめ。食事は日替わり3種類)。
GmundenからGustav Klimt Zentumは電車だと遠いのでタクシーを使いました。20分弱で40ユーロ。

宿はGumundenにある、Ferienwohnun Gailer。AirBnBみたいな感じで、一部屋をそのまま借りました。8月5日はGumndenのお祭り?(https://www.mondscheinbummel.at/)で、ちょっと盛り上がっておりました。

トラウン湖もアッター湖も非常に水が綺麗でいい意味で裏切られました。もう一度行くなら泳いでもいいかもしれない。



トラウン湖

イワナ

 Brot und Wein

Klimt Zentrumの庭

宿近くの橋からトラウン川とKasbergを望む




2021年8月8日日曜日

Intall Octave with amdblis and amdlibflame with Spack

 spack install octave+hdf5+fftw ^hdf5~mpi ^fftw~mpi ^amdblis threads=openmp ^amdlibflame threads=openmp

To enable threading you need to set OMP_NUN_THREADS=4 (e.g. with 4 cores).

2021年8月2日月曜日

Using pyplot@Plots on Julia@spack

 Using pyplot@Plots on Julia installed via spack is a bit complicated.


We first need to setup Python environment
(actually, you may want to use conda provided by Julia, so, you may do
Julia> ENV["PYTHON"]=""
)

as described in the following link;
https://github.com/JuliaPy/PyCall.jl

and then,

Julia> using Plots
Julia> pyplot()


2021年7月12日月曜日

Phase estimation

 Since we have the inverse QFFT, we can move to the phase estimation.

In the example, we are going to estimate the eigenvalues of the following matrix:
.

This matrix (or operator) can be written as a tensor product of 
and
.



.

This matrix is obviously unitary and can be used as the U operator in the diagram.
This matrix must be used with a control qubit, and I created a new "operation" matrixOperation in the following code.
The results agree with the example, and it seems that no need to repeat the measurement many times. The following table shows the number of measured bit strings out of 1,000 trials.


BTW, MS-Q# has QFT function which is "Adjoint"able (invertible), and the results are completely identical to mine. And also, I realize that the R1 gate should also take Adjoint, and I should use it instead of multiplying -1.0 to theta.

namespace phaseEstimation {
    open Microsoft.Quantum.Canon;
    open Microsoft.Quantum.Intrinsic;
    open Microsoft.Quantum.Convert;
    open Microsoft.Quantum.Arrays;
    open Microsoft.Quantum.Measurement;
    open Microsoft.Quantum.Math;
    open Microsoft.Quantum.Arithmetic as Arithmetic;
    
    @EntryPoint()
    operation SayHello() : Unit {
        let nQubit = 3; // Number of control qubits
        let maxNum = PowI(2,nQubit);
        mutable counts = new Int[maxNum];
        mutable theta  = new Double[maxNum];
        mutable revSeq = new Int[nQubit];

        for iQubit in 0..(nQubit-1){
            set theta w/= iQubit <- calcTheta(IntAsDouble(iQubit+1));
        }

        for iQubit in 0..(nQubit-1){
            set revSeq w/= iQubit <- nQubit-1-iQubit;
        }
        for trial in 1..1000 {
        use  (resultBits,vec) = (Qubit[nQubit],Qubit[2]) {
            ApplyToEach(Reset,resultBits); // Zero-clear the control qubits
            ApplyToEach(H,resultBits);

            //X(vec[0]);
            //X(vec[1]);

            for iQubit in 0..(nQubit-1){
                (Controlled matrixOperation)([resultBits[iQubit]],(iQubit,vec));
            }

            // Start Inverse QFFT
            let numLoopSwap = Floor(IntAsDouble(nQubit)*0.5);

            for iQubit in revSeq{
                for jQubit in 0..(nQubit-1)-iQubit-1{
                    let kQubit = revSeq[(nQubit-1)-jQubit];
                    let controlQubit = nQubit-kQubit-1;
                    let rotationIndex= nQubit-(kQubit+iQubit)-1;
                    (Controlled R1)([resultBits[controlQubit]],(-1.0*theta[rotationIndex],resultBits[iQubit]));
                }
                H(resultBits[iQubit]);
            }
            //for iQubit in 0..(numLoopSwap-1) {
            //    SWAP(resultBits[iQubit],resultBits[nQubit-1-iQubit]);
            //}              
            //let register = Arithmetic.BigEndian(resultBits);
            //(Adjoint QFT)(register);         
            let res = MultiM(resultBits);
            let bit = ResultArrayAsInt(res);
            set counts w/= bit <- counts[bit]+ 1;
            ResetAll(resultBits);
            ResetAll(vec);
        }
        }
        for j in 0..(maxNum-1)  {
           Message(IntAsString(counts[j]));
        }
    }
    function calcTheta(l : Double) : Double {
        return 2.0*PI()/(PowD(2.0,l));
    }
    operation matrixOperation(iQubit : Int, q : Qubit[]): Unit is Ctl{
       //Message(IntAsString(iQubit)+" "+IntAsString(PowI(2,iQubit)));
        for i in 0..(PowI(2,iQubit)-1){
            S(q[0]);
            T(q[1]);
        }
        return ();
    }
}

2021年6月27日日曜日

コロナウイルス

流石にちょっとぐらい理解しておいたほうが良いかなと思ってネットを巡っていたら良い資料が見つかったので。 

新型コロナウイルスのウイルス学的特徴

https://www.eiken.co.jp/uploads/modern_media/literature/P11-18.pdf

2021年6月25日金曜日

Compile spack packages for generic X86_64

 It seems that Spack automatically generates very optimized binaries (probably with something like gcc -march=native).

This is usually a good thing, but if a cluster consists of several generations of CPUs, this would cause a problem. In my case, the front node is newer than compute nodes, and the spack modules die on compute nodes.

To avoid this, you may want to add the following in ./etc/spack/defaults/packages.yaml.

Then the compiled binaries are for generic x86_64.

packages:
  all:
    target: [x86_64]

Appended on 30/July/2021
It should be better to have a user level configuration rather than changing the global file 
(the global config file will be overwritten with git pull or you will be complained).
$ cat ~/.spack/packages.yaml
packages:
  all:
    target: [x86_64]
https://spack.readthedocs.io/en/latest/configuration.html

2021年6月22日火曜日

Profiling Oct-file

Since Oct file of Octave is used to get a speedup, I think profiling of oct-files is useful, but I have not been able to do so. Oct-file is an executable binary called by Octave, and so, the profilers might be confused.

Recently, I have just found that "Intel Advisor" can get the information of my oct file. In addition, it really gives me the advice to get better performance.

We just need to launch Octave script to get the performance, namely you need to specify the following on Intel Advisor,
Binary: octave or octave-cli,
Option: an Octave script that calls your Oct-file.

That's it!