{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/gaoxiang/pytorch-dev/pytorchdev/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n", " from ._conv import register_converters as _register_converters\n", "WARNING:root:Unable to import NeuroChemAEV, please check your pyNeuroChem installation.\n" ] } ], "source": [ "import h5py\n", "import torch\n", "from selected_system import mols, mol_file\n", "from ani_benchmark import ANIBenchmark\n", "import pandas\n", "import os\n", "import tqdm\n", "from IPython.display import display\n", "import itertools\n", "tqdm.monitor_interval = 0" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "torch.set_num_threads(1)\n", "fm = h5py.File(os.path.join('../',mol_file), \"r\")\n", "\n", "benchmarks = {\n", " 'C': ANIBenchmark(device=torch.device(\"cpu\")),\n", "}\n", "\n", "if torch.cuda.is_available():\n", " benchmarks.update({\n", " 'G': ANIBenchmark(device=torch.device(\"cuda\")),\n", " })" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of atoms: 20\n", "Running benchmark on molecule COC(=O)c1ccc([N+](=O)[O-])cc1\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "9ff5dae10b0e4a85b250095cc1c40f64", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=4), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C,1C,BG,1G,B
aev0.7007810.5378881.0955910.022238
energy0.4226040.1834950.5646540.002251
force1.2537970.5611751.2836220.010574
forward1.1233850.7213831.6602450.024489
total2.3771821.2825582.9438660.035064
\n", "
" ], "text/plain": [ " C,1 C,B G,1 G,B\n", "aev 0.700781 0.537888 1.095591 0.022238\n", "energy 0.422604 0.183495 0.564654 0.002251\n", "force 1.253797 0.561175 1.283622 0.010574\n", "forward 1.123385 0.721383 1.660245 0.024489\n", "total 2.377182 1.282558 2.943866 0.035064" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "number of atoms: 50\n", "Running benchmark on molecule O=[N+]([O-])c1ccc(NN=Cc2ccc(C=NNc3ccc([N+](=O)[O-])cc3[N+](=O)[O-])cc2)c([N+](=O)[O-])c1\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "dbb459e25032453e9d6d5a8dc84a08de", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=4), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C,1C,BG,1G,B
aev1.6807582.9102541.1206380.033106
energy0.5469130.4069570.4743910.002537
force3.6377972.1899241.4957400.036373
forward2.2276713.3172101.5950290.035643
total5.8654695.5071353.0907690.072016
\n", "
" ], "text/plain": [ " C,1 C,B G,1 G,B\n", "aev 1.680758 2.910254 1.120638 0.033106\n", "energy 0.546913 0.406957 0.474391 0.002537\n", "force 3.637797 2.189924 1.495740 0.036373\n", "forward 2.227671 3.317210 1.595029 0.035643\n", "total 5.865469 5.507135 3.090769 0.072016" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "number of atoms: 10\n", "Running benchmark on molecule N#CCC(=O)N\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4e04277c06f5497384bed8e910669212", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=4), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C,1C,BG,1G,B
aev0.4209290.1497691.0816060.006245
energy0.2881240.0935770.4467440.002521
force0.7556100.2163971.2184330.007300
forward0.7090540.2433461.5283490.008766
total1.4646630.4597432.7467820.016067
\n", "
" ], "text/plain": [ " C,1 C,B G,1 G,B\n", "aev 0.420929 0.149769 1.081606 0.006245\n", "energy 0.288124 0.093577 0.446744 0.002521\n", "force 0.755610 0.216397 1.218433 0.007300\n", "forward 0.709054 0.243346 1.528349 0.008766\n", "total 1.464663 0.459743 2.746782 0.016067" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "number of atoms: 4,5,6\n", "Running benchmark on molecule C\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "65906ab1bdf1470aaf7515189c163f09", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=4), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C,1C,BG,1G,B
aev0.2075800.0172710.7750320.004428
energy0.1493500.0489530.2195760.001350
force0.3908660.1213470.7689560.005004
forward0.3569310.0662250.9946080.005778
total0.7477960.1875721.7635650.010781
\n", "
" ], "text/plain": [ " C,1 C,B G,1 G,B\n", "aev 0.207580 0.017271 0.775032 0.004428\n", "energy 0.149350 0.048953 0.219576 0.001350\n", "force 0.390866 0.121347 0.768956 0.005004\n", "forward 0.356931 0.066225 0.994608 0.005778\n", "total 0.747796 0.187572 1.763565 0.010781" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "number of atoms: 100\n", "Running benchmark on molecule CC(C)C[C@@H](C(=O)O)NC(=O)C[C@@H]([C@H](CC1CCCCC1)NC(=O)CC[C@@H]([C@H](Cc2ccccc2)NC(=O)OC(C)(C)C)O)O\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "bb3a02673cc14b468839c8b3a0e84edc", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=4), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C,1C,BG,1G,B
aev6.93307111.3863941.2268020.118203
energy1.0044000.8489590.5176540.001794
force8.2068866.6062111.8274980.108411
forward7.93747212.2353541.7444560.119997
total16.14435718.8415653.5719540.228409
\n", "
" ], "text/plain": [ " C,1 C,B G,1 G,B\n", "aev 6.933071 11.386394 1.226802 0.118203\n", "energy 1.004400 0.848959 0.517654 0.001794\n", "force 8.206886 6.606211 1.827498 0.108411\n", "forward 7.937472 12.235354 1.744456 0.119997\n", "total 16.144357 18.841565 3.571954 0.228409" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "number of atoms: 305\n", "Running benchmark on molecule [H]/N=C(/N)\\NCCC[C@H](C(=O)N[C@H]([C@@H](C)O)C(=O)N[C@H](Cc1ccc(cc1)O)C(=O)NCCCC[C@@H](C(=O)NCCCC[C@@H](C(=O)NCC(=O)O)NC(=O)[C@H](CCCCNC(=O)[C@@H](Cc2ccc(cc2)O)NC(=O)[C@@H]([C@@H](C)O)NC(=O)[C@@H](CCCN/C(=N\\[H])/N)N)NC(=O)[C@@H](Cc3ccc(cc3)O)NC(=O)[C@@H]([C@@H](C)O)NC(=O)[C@@H](CCCN/C(=N\\[H])/N)N)NC(=O)[C@@H](Cc4ccc(cc4)O)NC(=O)[C@@H]([C@@H](C)O)NC(=O)[C@@H](CCCN/C(=N\\[H])/N)N)N\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0a01e82e74094812b0a041a95e42ae38", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=4), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "cuda runtime error (2) : out of memory at /home/gaoxiang/pytorch/aten/src/THC/generic/THCStorage.cu:58\n", "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C,1C,BG,1G,B
aev22.46283238.6296161.459434NaN
energy2.6982512.4198600.525845NaN
force21.11294820.7884183.065523NaN
forward25.16108341.0494761.985280NaN
total46.27403161.8378955.050802NaN
\n", "
" ], "text/plain": [ " C,1 C,B G,1 G,B\n", "aev 22.462832 38.629616 1.459434 NaN\n", "energy 2.698251 2.419860 0.525845 NaN\n", "force 21.112948 20.788418 3.065523 NaN\n", "forward 25.161083 41.049476 1.985280 NaN\n", "total 46.274031 61.837895 5.050802 NaN" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "for i in mols:\n", " print('number of atoms:', i)\n", " smiles = mols[i]\n", " for s in smiles:\n", " print('Running benchmark on molecule', s)\n", " key = s.replace('/', '_')\n", " coordinates = torch.from_numpy(fm[key][()])\n", " coordinates = coordinates[:200]\n", " species = fm[key].attrs['species'].split()\n", " results = {}\n", " for b,m in tqdm.tqdm_notebook(list(itertools.product(benchmarks, ['1','B']))):\n", " bench = benchmarks[b]\n", " coordinates = coordinates.type(bench.aev_computer.dtype)\n", " try:\n", " if m == '1':\n", " result = bench.oneByOne(coordinates, species)\n", " elif m == 'B':\n", " result = bench.inBatch(coordinates, species)\n", " else:\n", " raise ValueError('BUG here')\n", " result['forward'] = result['aev'] + result['energy']\n", " result['total'] = result['forward'] + result['force']\n", " except RuntimeError as e:\n", " print(e)\n", " result = {'aev': None, 'energy': None, 'force': None, 'total': None }\n", " results[b + ',' + m] = result\n", " df = pandas.DataFrame(results)\n", " display(df)\n", " break" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }