Created
July 15, 2024 19:41
-
-
Save tlrmchlsmth/fee30cb75a80ff8841736f08f908abb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pdb | |
import traceback | |
import inspect | |
def function_in_stack(function_name): | |
stack = traceback.extract_stack() | |
for frame in stack: | |
if frame.name == function_name: | |
return True | |
return False | |
# Using this to insert breakpoints when running on actual data. | |
# Useful when e.g. comparing hidden states for correctness. | |
# If profile_run is in our stack trace, we're profiling for KV cache usage | |
# If initialize_cache is in our stack trace, we're creating CUDA graphs. | |
if not function_in_stack("profile_run") or function_in_stack("initialize_cache"): | |
pdb.set_trace() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment