Skip to content

Why is PyTensor with 'NUMBA' mode compilation is much slower than numba-jitted calculation? #1545

Answered by ricardoV94
kratsg asked this question in Q&A
Discussion options

You must be logged in to vote

I edited your file:

#!/usr/bin/env python3
"""
Timing comparison script for pytensor/mode Gaussian implementations vs numba-stats.

Compares PyTensor Gaussian PDF evaluation performance across different modes:
- FAST_RUN (default optimized mode)
- JAX (if available)
- NUMBA (if available)

Also compares against numba-stats norm.pdf as baseline.
"""

import time
import timeit
import numpy as np
from contextlib import contextmanager
from pytensor.compile.function import function
import pytensor.tensor as pt
import math

# Import numba-stats for comparison
try:
    from numba_stats import norm as numba_norm
    HAS_NUMBA_STATS = True
except ImportError:
    HAS_NUMBA_STATS = False
    print("…

Replies: 2 comments 15 replies

Comment options

You must be logged in to vote
14 replies
@kratsg
Comment options

@kratsg
Comment options

@ricardoV94
Comment options

@ricardoV94
Comment options

Answer selected by kratsg
@kratsg
Comment options

@kratsg
Comment options

@ricardoV94
Comment options

@kratsg
Comment options

Comment options

You must be logged in to vote
1 reply
@kratsg
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants