evangelistalab / forte

http://www.evangelistalab.org
GNU Lesser General Public License v3.0
51 stars 30 forks source link

Problem with FCIIntegral #38

Closed lcyyork closed 7 years ago

lcyyork commented 7 years ago

We are trying to run a CI-NO computation on octatetraene. Here is the input.

import forte

memory 1 gb

molecule {
0 1
    H   0.971328   1.220141   0.000000
    H  -0.971328  -1.220141   0.000000
    H  -2.098090   0.984719   0.000000
    H   2.098090  -0.984719   0.000000
    H  -0.146884   3.418505   0.000000
    H   0.146884  -3.418505   0.000000
    H  -2.193473   4.766086   0.000000
    H   2.193473  -4.766086   0.000000
    H  -3.225698   3.230501   0.000000
    H   3.225698  -3.230501   0.000000
    C   0.000000   0.721498   0.000000
    C   0.000000  -0.721498   0.000000
    C   1.125020  -1.479523   0.000000
    C  -1.125020   1.479523   0.000000
    C   1.121077  -2.928812   0.000000
    C  -1.121077   2.928812   0.000000
    C   2.237388  -3.682282   0.000000
    C  -2.237388   3.682282   0.000000

no_reorient
}

set {
  docc           [13,2,2,12]
  basis          def2-tzvp
  scf_type       df
  df_basis_scf   def2-tzvp-jkfit
  df_basis_mp2   def2-tzvp-jkfit
  maxiter        100
  e_convergence  12
}
set forte {
  job_type             nojob
  cino                 true
  CINO_THRESHOLD       0.99
  cino_roots_per_irrep [1,0,0,1]
  int_type             df
}
E,wfn = energy('forte',return_wfn=True)

However this job will fail after the DF integrals are computed. When I run lldb, here is the error I get:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL
    frame #0: 0x000000010c465433 forte.so`std::__1::__split_buffer<double, std::__1::allocator<double>&>::__construct_at_end(unsigned long) + 131
forte.so`std::__1::__split_buffer<double, std::__1::allocator<double>&>::__construct_at_end:
->  0x10c465433 <+131>: vmovsd %xmm0, (%rax)
    0x10c465437 <+135>: movq   0x10(%rcx), %rax
    0x10c46543b <+139>: addq   $0x8, %rax
    0x10c46543f <+143>: movq   %rax, 0x10(%rcx)

and back trace

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL
  * frame #0: 0x000000010c465433 forte.so`std::__1::__split_buffer<double, std::__1::allocator<double>&>::__construct_at_end(unsigned long) + 131
    frame #1: 0x000000010c465348 forte.so`std::__1::vector<double, std::__1::allocator<double> >::__append(unsigned long) + 648
    frame #2: 0x000000010c444e4b forte.so`std::__1::vector<double, std::__1::allocator<double> >::resize(unsigned long) + 123
    frame #3: 0x000000010c6b1e84 forte.so`psi::forte::FCIIntegrals::startup() + 132
    frame #4: 0x000000010c6b1d26 forte.so`psi::forte::FCIIntegrals::FCIIntegrals(std::__1::shared_ptr<psi::forte::ForteIntegrals>, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >) + 1894
    frame #5: 0x000000010c6b1f45 forte.so`psi::forte::FCIIntegrals::FCIIntegrals(std::__1::shared_ptr<psi::forte::ForteIntegrals>, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >) + 21
    frame #6: 0x000000010c1017b7 forte.so`std::__1::shared_ptr<psi::forte::FCIIntegrals> std::__1::shared_ptr<psi::forte::FCIIntegrals>::make_shared<std::__1::shared_ptr<psi::forte::ForteIntegrals>&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >(std::__1::shared_ptr<psi::forte::ForteIntegrals>&&&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >&&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >&&) + 3735
    frame #7: 0x000000010c68f6d2 forte.so`psi::forte::CINO::CINO(std::__1::shared_ptr<psi::Wavefunction>, psi::Options&, std::__1::shared_ptr<psi::forte::ForteIntegrals>, std::__1::shared_ptr<psi::forte::MOSpaceInfo>) + 2258
    frame #8: 0x000000010c690d4d forte.so`psi::forte::CINO::CINO(std::__1::shared_ptr<psi::Wavefunction>, psi::Options&, std::__1::shared_ptr<psi::forte::ForteIntegrals>, std::__1::shared_ptr<psi::forte::MOSpaceInfo>) + 29
    frame #9: 0x000000010c295bc8 forte.so`std::__1::shared_ptr<psi::forte::CINO> std::__1::shared_ptr<psi::forte::CINO>::make_shared<std::__1::shared_ptr<psi::Wavefunction>&, psi::Options&, std::__1::shared_ptr<psi::forte::ForteIntegrals>&, std::__1::shared_ptr<psi::forte::MOSpaceInfo>&>(std::__1::shared_ptr<psi::Wavefunction>&&&, psi::Options&&&, std::__1::shared_ptr<psi::forte::ForteIntegrals>&&&, std::__1::shared_ptr<psi::forte::MOSpaceInfo>&&&) + 3464
    frame #10: 0x000000010c27f18c forte.so`psi::forte::forte_old_methods(std::__1::shared_ptr<psi::Wavefunction>, psi::Options&, std::__1::shared_ptr<psi::forte::ForteIntegrals>, std::__1::shared_ptr<psi::forte::MOSpaceInfo>, int) + 2428
    frame #11: 0x000000010c2edc20 forte.so`forte + 1776
    frame #12: 0x00000001022a6a30 core.so`py_psi_plugin(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction>) + 624
    frame #13: 0x00000001022a8357 core.so`std::__1::shared_ptr<psi::Wavefunction> pybind11::detail::argument_loader<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction> >::call_impl<std::__1::shared_ptr<psi::Wavefunction>, std::__1::shared_ptr<psi::Wavefunction> (*&)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction>), 0ul, 1ul>(std::__1::shared_ptr<psi::Wavefunction> (*&&&)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction>), pybind11::detail::index_sequence<0ul, 1ul>) + 71
    frame #14: 0x00000001022a81b3 core.so`void pybind11::cpp_function::initialize<std::__1::shared_ptr<psi::Wavefunction> (*&)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction>), std::__1::shared_ptr<psi::Wavefunction>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction>, pybind11::name, pybind11::scope, pybind11::sibling, char [62]>(std::__1::shared_ptr<psi::Wavefunction> (*&&&)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction>), std::__1::shared_ptr<psi::Wavefunction> (*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<psi::Wavefunction>), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, char const (&) [62])::'lambda'(pybind11::detail::function_record*, pybind11::handle, pybind11::handle, pybind11::handle)::operator()(pybind11::detail::function_record*, pybind11::handle, pybind11::handle, pybind11::handle) const + 131
    frame #15: 0x000000010216e4a4 core.so`pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 884
    frame #16: 0x000000010012e302 libpython2.7.dylib`PyEval_EvalFrameEx + 3730
    frame #17: 0x00000001001377dc libpython2.7.dylib`PyEval_EvalCodeEx + 2092
    frame #18: 0x00000001000c0c1b libpython2.7.dylib`function_call + 347
    frame #19: 0x0000000100097761 libpython2.7.dylib`PyObject_Call + 97
    frame #20: 0x000000010012ecea libpython2.7.dylib`PyEval_EvalFrameEx + 6266
    frame #21: 0x00000001001377dc libpython2.7.dylib`PyEval_EvalCodeEx + 2092
    frame #22: 0x0000000100137988 libpython2.7.dylib`fast_function + 296
    frame #23: 0x000000010012e38a libpython2.7.dylib`PyEval_EvalFrameEx + 3866
    frame #24: 0x00000001001377dc libpython2.7.dylib`PyEval_EvalCodeEx + 2092
    frame #25: 0x0000000100137856 libpython2.7.dylib`PyEval_EvalCode + 54
    frame #26: 0x00000001001564e9 libpython2.7.dylib`PyRun_StringFlags + 121
    frame #27: 0x0000000100133ff3 libpython2.7.dylib`PyEval_EvalFrameEx + 27523
    frame #28: 0x00000001001377dc libpython2.7.dylib`PyEval_EvalCodeEx + 2092
    frame #29: 0x0000000100137856 libpython2.7.dylib`PyEval_EvalCode + 54
    frame #30: 0x00000001001563d4 libpython2.7.dylib`PyRun_FileExFlags + 164
    frame #31: 0x0000000100157709 libpython2.7.dylib`PyRun_SimpleFileExFlags + 409
    frame #32: 0x000000010016b1ca libpython2.7.dylib`Py_Main + 2938
    frame #33: 0x0000000100000f14 python`start + 52

I am confused why this is happening in the startup() function of FCIIntegral which just resize some std vector. Could this be related to the recently added json.hpp? Thanks.

fevangelista commented 7 years ago

The json.hpp file is not included or compiled. Let me see what I get on my machine.

fevangelista commented 7 years ago

I don't this is a bug. I think you are running out of resources. On my computer the code is failing here:

void FCIIntegrals::startup() {

    nmo2_ = nmo_ * nmo_;
    nmo3_ = nmo_ * nmo_ * nmo_;
    nmo4_ = nmo_ * nmo_ * nmo_ * nmo_;

    oei_a_.resize(nmo2_);
    oei_b_.resize(nmo2_);
    tei_aa_.resize(nmo4_); <--
    tei_ab_.resize(nmo4_);
    tei_bb_.resize(nmo4_);

In this example there are 308 MOs, so forte is trying to allocate an array with 8,999,178,496 elements. That's about 67GB. There is no way we can store three of these on the cluster.

lcyyork commented 7 years ago

Ah, I see. It could be active is not specified and it takes everything as active.

fevangelista commented 7 years ago

That's exactly what's happening in this calculation.

lcyyork commented 7 years ago

Although this is still somewhat strange because Cici told me the same input works previously, like last week. So I guess the simplest fix is to put "active [0,0,0,0]" to the input. @xiaohaiguicc

xiaohaiguicc commented 7 years ago

The input worked before with cc-pvdz basis. But after I changed the basis to def2, it didn't work at all.

lcyyork commented 7 years ago

@xiaohaiguicc My bad, active [0,0,0,0] will not work because all orbitals should be considered as active. I am not sure if there is a better solution, but I think you can either modify the CI solver to make it generate useful two-electron integral (from DF 3-index integral) on the fly, or implement more efficient CIS according to http://vergil.chemistry.gatech.edu/notes/cis/cis.pdf. In either way, the full two-electron integrals should not be stored.