Speed Bump uses glob patterns to specify which functions to slow down. Each line in a targets file has the format:
module_pattern:qualified_name_pattern
Both patterns use standard glob syntax (*, ?, [...]).
The module pattern matches against the file path of the code object. This is typically the full path to the .py file.
| Pattern | Matches |
|---|---|
* |
Any module |
*/numpy/* |
Any file in a numpy directory |
*transformers* |
Any file with "transformers" in the path |
/home/user/myproject/*.py |
Specific directory |
The qualified name pattern matches against the function's co_qualname, which includes:
- The function name
- Enclosing class names (for methods)
- Enclosing function names (for nested functions)
| Code | Qualified Name |
|---|---|
def foo(): ... |
foo |
class Bar: def baz(self): ... |
Bar.baz |
def outer(): def inner(): ... |
outer.<locals>.inner |
class A: class B: def m(self): ... |
A.B.m |
*:*
Useful for Step 1 analysis: "does Python matter at all?"
*/vllm/worker/model_runner.py:ModelRunner.execute_model
*:ModelRunner.*
Matches ModelRunner.execute_model, ModelRunner.__init__, etc.
*:*attention*
Matches any function with "attention" in its qualified name (case-sensitive).
*/numpy/*:*
Matches all functions in numpy.
Because nested functions include <locals> in their qualified name:
*:*<locals>*
Matches all nested/local functions.
Or to match a specific nested function:
*:*outer.<locals>.inner
*/tests/*:test_*
There's no exclude syntax. If you need to exclude, create a target file with only what you want to include.
# Comments start with #
# Blank lines are ignored
# One pattern per line
*:ModelRunner.*
*/transformers/*:*Attention*
# Whitespace is stripped
*:some_function
If your pattern isn't matching as expected:
-
Check the qualified name by adding a print in your code:
import sys print(my_function.__code__.co_qualname)
-
Check the file path:
print(my_function.__code__.co_filename)
-
Use a broad pattern first, then narrow down:
*:* # matches everything - verify setup works *:*MyClass* # narrow to class *:MyClass.my_method # narrow to method
# All worker operations
*/vllm/worker/*:*
# Model execution
*:ModelRunner.execute_model
# Attention layers
*:*Attention*
# All modeling code
*/transformers/models/*:*
# Specific architecture
*/transformers/models/llama/*:*
# Attention mechanisms
*:*Attention.forward
# Tensor operations (Python side)
*/torch/*:*
# Specific modules
*:Linear.forward
*:Conv2d.forward
# All numpy
*/numpy/*:*
# Core operations
*/numpy/core/*:*