@@ -27,9 +27,9 @@ def qubit_occupation_sv_impl(
2727 Custom implementation of the occupation ❬ψ|nᵢ|ψ❭ for the state vector solver.
2828 """
2929 nqubits = state .n_qudits
30- occupation = torch .zeros (nqubits , dtype = dtype , device = state .vector .device )
30+ occupation = torch .zeros (nqubits , dtype = dtype , device = state .data .device )
3131 for i in range (nqubits ):
32- state_tensor = state .vector .view (2 ** i , 2 , - 1 )
32+ state_tensor = state .data .view (2 ** i , 2 , - 1 )
3333 # nᵢ is a projector and therefore nᵢ == nᵢnᵢ
3434 # ❬ψ|nᵢ|ψ❭ == ❬ψ|nᵢnᵢ|ψ❭ == ❬ψ|nᵢ * nᵢ|ψ❭ == ❬ϕ|ϕ❭ == |ϕ|**2
3535 occupation [i ] = torch .linalg .vector_norm (state_tensor [:, 1 ]) ** 2
@@ -55,8 +55,8 @@ def qubit_occupation_sv_den_mat_impl(
5555 will be <nᵢ> = Tr(ρnᵢ), or [ <n₁>, <n₂>, <n₃> ].
5656 """
5757 nqubits = state .n_qudits
58- occupation = torch .zeros (nqubits , dtype = dtype , device = state .matrix .device )
59- diag_state_tensor = state .matrix .diagonal ()
58+ occupation = torch .zeros (nqubits , dtype = dtype , device = state .data .device )
59+ diag_state_tensor = state .data .diagonal ()
6060 for i in range (nqubits ):
6161 state_tensor = diag_state_tensor .view (2 ** i , 2 , 2 ** (nqubits - i - 1 ))[:, 1 , :]
6262 occupation [i ] = state_tensor .sum ().real
@@ -76,10 +76,10 @@ def correlation_matrix_sv_impl(
7676 TODO: extend to arbitrary two-point correlation ❬ψ|AᵢBⱼ|ψ❭
7777 """
7878 nqubits = state .n_qudits
79- correlation = torch .zeros (nqubits , nqubits , dtype = dtype , device = state .vector .device )
79+ correlation = torch .zeros (nqubits , nqubits , dtype = dtype , device = state .data .device )
8080
8181 for i in range (nqubits ):
82- select_i = state .vector .view (2 ** i , 2 , - 1 )
82+ select_i = state .data .view (2 ** i , 2 , - 1 )
8383 select_i = select_i [:, 1 ]
8484 correlation [i , i ] = torch .linalg .vector_norm (select_i ) ** 2
8585 for j in range (i + 1 , nqubits ): # select the upper triangle
@@ -104,7 +104,7 @@ def correlation_matrix_sv_den_mat_impl(
104104 """
105105 nqubits = state .n_qudits
106106 correlation = torch .zeros (nqubits , nqubits , dtype = dtype )
107- state_diag_matrix = state .matrix .diagonal ()
107+ state_diag_matrix = state .data .diagonal ()
108108 for i in range (nqubits ): # applying ni
109109 shapei = (2 ** i , 2 , 2 ** (nqubits - i - 1 ))
110110 state_diag_ni = state_diag_matrix .view (* shapei )[:, 1 , :]
@@ -127,9 +127,9 @@ def energy_variance_sv_impl(
127127 """
128128 Custom implementation of the energy variance ❬ψ|H²|ψ❭-❬ψ|H|ψ❭² for the state vector solver.
129129 """
130- hstate = hamiltonian * state .vector
130+ hstate = hamiltonian * state .data
131131 h_squared = torch .vdot (hstate , hstate ).real
132- energy = torch .vdot (state .vector , hstate ).real
132+ energy = torch .vdot (state .data , hstate ).real
133133 en_var : torch .Tensor = h_squared - energy ** 2
134134 return en_var .cpu ()
135135
@@ -145,8 +145,8 @@ def energy_variance_sv_den_mat_impl(
145145 Custom implementation of the energy variance tr(ρH²)-tr(ρH)² for the
146146 lindblad equation solver.
147147 """
148- h_dense_matrix = hamiltonian .h_eff (state .matrix ) # Hρ
149- gpu = state .matrix .is_cuda
148+ h_dense_matrix = hamiltonian .h_eff (state .data ) # Hρ
149+ gpu = state .data .is_cuda
150150 h_squared_dense_mat = hamiltonian .expect (
151151 DensityMatrix (h_dense_matrix , gpu = gpu )
152152 ) # tr(ρH²)
@@ -165,7 +165,7 @@ def energy_second_moment_sv_impl(
165165 Custom implementation of the second moment of energy ❬ψ|H²|ψ❭
166166 for the state vector solver.
167167 """
168- hstate = hamiltonian * state .vector
168+ hstate = hamiltonian * state .data
169169 en_2_mom : torch .Tensor = torch .vdot (hstate , hstate ).real
170170 return en_2_mom .cpu ()
171171
@@ -181,8 +181,8 @@ def energy_second_moment_den_mat_impl(
181181 Custom implementation of the second moment of energy tr(ρH²) for the
182182 lindblad equation solver.
183183 """
184- h_dense_matrix = hamiltonian .h_eff (state .matrix ) # Hρ
185- gpu = state .matrix .is_cuda
184+ h_dense_matrix = hamiltonian .h_eff (state .data ) # Hρ
185+ gpu = state .data .is_cuda
186186
187187 return hamiltonian .expect (
188188 DensityMatrix (h_dense_matrix , gpu = gpu )
0 commit comments