I am trying to plot a graph using a number_input form the user. Everything works well but when I change the value of the num_input the graph reloads. I tried putting every variable in a session state but doesn’t change the fact that the entire graph reloads.

Reloading is expected behavior. Streamlit reruns your whole script with every user interaction and session state is merely a tool to have to memory from previous runs of the script. If you want to optimize performance, you can use caching.

There can be some fiddling to get caching set in the best possible way. If you are having any difficulty with that, could you provide your code to give a basis for more specific advice?