Code Monkey home page Code Monkey logo

Comments (4)

arjunkaruvally avatar arjunkaruvally commented on June 1, 2024

This is for RVISampler that is taking the most time in all the other samplers

ncalls | tottime | percall | cumtime | percall | filename:lineno(function)
1000 | 5.279 | 0.005279 | 5.279 | 0.005279 | ~:0(<method 'run_backward' of 'torch._C._EngineBase' objects>)
1 | 2.654 | 2.654 | 28.69 | 28.69 | RVISampler.py:53(solve)
49000 | 1.168 | 2.383e-05 | 1.73 | 3.531e-05 | baselines.py:40(__call__)
147000 | 1.111 | 7.555e-06 | 1.111 | 7.555e-06 | ~:0(<built-in method torch._C.addmm>)
49000 | 0.7808 | 1.593e-05 | 0.7808 | 1.593e-05 | ~:0(<built-in method torch._C._nn.softmax>)
294000/49000 | 0.7505 | 1.532e-05 | 7.852 | 0.0001602 | module.py:351(__call__)
99000 | 0.7432 | 7.507e-06 | 1.436 | 1.451e-05 | ~:0(<built-in method apply>)
172522 | 0.7212 | 4.18e-06 | 0.7212 | 4.18e-06 | ~:0(<built-in method numpy.core.multiarray.array>)
49000 | 0.6603 | 1.348e-05 | 1.536 | 3.134e-05 | distributions.py:147(log_prob)
49000 | 0.6353 | 1.297e-05 | 1.945 | 3.97e-05 | random_walk.py:86(step)
49000 | 0.5935 | 1.211e-05 | 4.842 | 9.882e-05 | base.py:92(step)
249000 | 0.521 | 2.092e-06 | 0.521 | 2.092e-06 | ~:0(<method 'copy_' of 'torch._C.FloatTensorBase' objects>)
394951 | 0.5169 | 1.309e-06 | 1.429 | 3.618e-06 | _utils.py:6(_type)
6500 | 0.4307 | 6.627e-05 | 0.4953 | 7.62e-05 | analytic_posterior.py:48(pdf)
690000 | 0.3995 | 5.79e-07 | 0.548 | 7.943e-07 | variable.py:64(__getattr__)
55020 | 0.3922 | 7.129e-06 | 0.3922 | 7.129e-06 | ~:0(<method 'reduce' of 'numpy.ufunc' objects>)
147000 | 0.3843 | 2.614e-06 | 0.3843 | 2.614e-06 | ~:0(<method 't' of 'torch._C._VariableBase' objects>)
1234461 | 0.3797 | 3.076e-07 | 0.3797 | 3.076e-07 | ~:0(<built-in method builtins.getattr>)
147951 | 0.3473 | 2.348e-06 | 0.3473 | 2.348e-06 | ~:0(<built-in method torch._C.from_numpy>)
147000 | 0.3407 | 2.318e-06 | 2.497 | 1.699e-05 | linear.py:54(forward)
247000 | 0.3313 | 1.341e-06 | 0.6787 | 2.748e-06 | _utils.py:83(_import_dotted_name)
147000 | 0.3151 | 2.144e-06 | 2.013 | 1.369e-05 | functional.py:822(linear)
99000 | 0.3033 | 3.063e-06 | 0.3033 | 3.063e-06 | ~:0(<built-in method torch._C.ones>)
49000 | 0.2929 | 5.978e-06 | 7.607 | 0.0001553 | policies.py:49(forward)
149000 | 0.2749 | 1.845e-06 | 0.2749 | 1.845e-06 | ~:0(<method 'view' of 'torch._C.FloatTensorBase' objects>)
49000 | 0.2474 | 5.048e-06 | 3.471 | 7.083e-05 | container.py:65(forward)```

from better-sampling.

zafarali avatar zafarali commented on June 1, 2024

Ok so as expected backward() takes the most time. Let's leave that out for now.
Doesn't doesn't look like we can make that faster though. torch.ones() call is necessary to make the output the same size.

Places to look:
random_walk.step, analytic_posterior.pdf Like you identified this line keeps creating new lists everytime it is called

if not (x in range(-c, c+1, 1) and term in range(0, T+1)):
return 0
else:
return (1/(2*c))*comb(T, term)*(p**term)*((1-p)**(T-term))

A quick way to make this faster is to use self.support which already has created range(c, c+1)
The logic for the conditional term in range(0, T+1)) is that i need it to be <T+1 and >0 but also an integer. Maybe a way to check this is to check if it's an integer then we do not need to create the list.

I'm not sure where random_walk.step can be improved but given that it called analytic_posterior.pdf improving that should make it faster as well.

from better-sampling.

arjunkaruvally avatar arjunkaruvally commented on June 1, 2024

My thoughts exactly...

from better-sampling.

arjunkaruvally avatar arjunkaruvally commented on June 1, 2024

Resolved by PR #22

  • Profilers are attached and some performance issues are fixed

from better-sampling.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.