sandialabs / pyttb

Python Tensor Toolbox
https://pyttb.readthedocs.io
BSD 2-Clause "Simplified" License
26 stars 13 forks source link

197 algorithm profiling #199

Closed DeepBlockDeepak closed 1 year ago

DeepBlockDeepak commented 1 year ago

Preliminary profiler notebook within /profiling, which displays top 10 slowest function calls as they occur in either cp_als() or cp_apr(), depending on which algorithm the user wants to test. The ranks list is looped over to test the functions with tensors of ranks 2,3 and finally 4. The data for the tests is read from /profiling/data/*.tns.

To test

The bottom code block allows you to choose which algorithm to test. At the moment, cp_apr takes ~5m30s while cp_als takes about 10s.

profile(test_files, ranks, 'cp_apr')
profile(test_files, ranks, "cp_als")

:books: Documentation preview :books:: https://pyttb--199.org.readthedocs.build/en/199/

dmdunla commented 1 year ago

@DeepBlockDeepak This is a great start!

Here are some questions/suggestions:

DeepBlockDeepak commented 1 year ago

Thanks!

dmdunla commented 1 year ago

Looking good!

Here are some suggestions:

DeepBlockDeepak commented 1 year ago

Latest commit includes a new file cp_and_tucker_algorithms_profiling_with_gprof2dot.ipynb where the profiling stats are created in a generated sub-directory /profiling/pstats_files.

Example:

To create corresponding .png files for the pstats data:

algorithm=<specific_algorithm_name>
mkdir -p gprof2dot_images/${algorithm}
for file in pstats_files/${algorithm}/*.pstats; do
    gprof2dot -f pstats $file \
        | dot -Tpng -o gprof2dot_images/${algorithm}/$(basename $file .pstats).png
done

This generates the /profiling/gprof2dot_images directory, where the created .png profile visuals are stored. I believe I had to install both graphviz to my system and package install gprof2dot beforehand, a la this introduction.

DeepBlockDeepak commented 1 year ago

The current visual profiling output is the result the pstats from testing with cell 11 : profile(test_files, ranks, "tucker_als").

dmdunla commented 1 year ago

@DeepBlockDeepak Can you add the profiling output with images for all 4 algorithms?

DeepBlockDeepak commented 1 year ago

@dmdunla The images exist inside of /profiling/gprof2dot_images/<algo_name> per each algorithm.