Comments (8)
You have to run with --dynamic-shapes --dynamic-batch-size-only
to actually trigger dynamic shapes in the benchmark suite
from pytorch.
--dynamic-shapes --dynamic-batch-size-only
I had both (scroll to the right of the given command line in the comment).
from pytorch.
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.
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.
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.
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.
ok, well, I never claimed that you would expect a speedup here :)
from pytorch.
The benchmark runs with --dynamic-shapes --dynamic-batch-only
, not just --dynamic-batch-only
. Maybe you need both ?
from pytorch.
Related Issues (20)
- Error in gradient of CTCLoss
- [Bug] Data on CPUs Are Not Synchronized Before Subsequent Operations HOT 4
- TORCH_LIBRARY breaks when passing (unexpanded) macro as namespace argument HOT 1
- custom_op API: better type anntation for Tuple
- Segfault, possibly due to recursion limit
- Fix accuracy regression for cspdarknet53 or flakiness associated with cu121 (and potentially cu124) HOT 1
- dynamo minifier test test_cpu_cuda_module_after_dynamo fail with nn module inlining. HOT 1
- SyntaxError: unterminated string literal (detected at line 1) (<unknown>, line 1) HOT 15
- c++ library written with a lot of errors
- [export] Errors out when unflattening TorchTitan HOT 1
- OneCycleLR Example
- Illegal memory access resulted from pointwise autotuning of a cat-like kernel HOT 3
- DISABLED test_workspace_allocation_error (__main__.CudaGraphTreeTests) HOT 1
- Inductor generates unnecessary allocation + copy operations for custom ops with mutable inputs HOT 11
- Strange clamp assert error when building on Fedora 40/gcc 14 in IndexKernel.hip HOT 1
- Add line number to ` _warn_capture_scalar_outputs():`
- module 'torch.mps' has no attribute 'device' HOT 1
- Key error in index_propagation when looking up dynamic shape vr HOT 8
- RuntimeError: `jit.freeze` fails to find externally assigned attributes
- UNSTABLE inductor / cuda12.4-py3.10-gcc9-sm86 / test (dynamic_inductor_timm) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch.