Giter Site home page Giter Site logo

Comments (8)

ezyang avatar ezyang commented on June 12, 2024 1

You have to run with --dynamic-shapes --dynamic-batch-size-only to actually trigger dynamic shapes in the benchmark suite

from pytorch.

aorenste avatar aorenste commented on June 12, 2024 1

--dynamic-shapes --dynamic-batch-size-only

I had both (scroll to the right of the given command line in the comment).

from pytorch.

eellison avatar eellison commented on June 12, 2024 1

When I run:

python benchmarks/dynamo/huggingface.py --performance --training --amp --backend aot_eager --device cuda --only BertForQuestionAnswering 
 --print-compilation-time --dynamic-batch-only

And add

    def __del__(self):
        print(self.cache_info())

to FakeTensorMode I see:

DispatchCacheInfo(hits=19258, misses=189, bypasses={'symbolic shape': 22386, 'dynamic output shape': 1, 'CompositeImplicitAutograd': 697, 'non-fake tensor': 54, 'non-FakeTensor output': 51}, size=189)

I also see that in the above benchmark without dynamic-batch-only disabling fake tensor cache causes 5 seconds slowdown. It's possible you're only looking at sym_types inputs but not fake tensor inputs with symints. About half of the ops are bypassed due to symints so I would expect a couple seconds of improvement.

from pytorch.

aorenste avatar aorenste commented on June 12, 2024 1

So it turns out that the perf measurements work a lot better when you store them with += instead of =. Once I do that the symint stuff pops out as quite a bit more expensive (significant percentage of the dispatch time for some of the benchmarks)

from pytorch.

aorenste avatar aorenste commented on June 12, 2024

I'm not sure if this would be worth it. I instrumented the existing cache and ran:

python benchmarks/dynamo/torchbench.py --performance --inference --amp --backend inductor --disable-cudagraphs --device cuda

From what I can tell the time spent in the FakeTensorMode dispatch of ops that were not cached because they contained any kind of sym expr was tiny. Of 151s spent in dispatch 0.003s were cache bypassed due to containing a SymInt, SymFloat, or SymBool.

Is there a better benchmark I should use to measure the potential of this change?

from pytorch.

aorenste avatar aorenste commented on June 12, 2024

You have to run with --dynamic-shapes --dynamic-batch-size-only to actually trigger dynamic shapes in the benchmark suite

I used --dynamic-batch-only because --dynamic-batch-size-only wasn't accepted.

Running:

python benchmarks/dynamo/torchbench.py --performance --inference --amp --backend inductor --disable-cudagraphs --device cuda --dynamic-shapes --dynamic-batch-only

Gives a total time of 338s (so slower) but still only 0.045s in dispatching w/ Sym types. Still fairly insignificant. Or I'm measuring it poorly.

from pytorch.

ezyang avatar ezyang commented on June 12, 2024

ok, well, I never claimed that you would expect a speedup here :)

from pytorch.

eellison avatar eellison commented on June 12, 2024

The benchmark runs with --dynamic-shapes --dynamic-batch-only, not just --dynamic-batch-only. Maybe you need both ?

from pytorch.

Related Issues (20)

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.