Skip to content

BD + ABC bug (Pytensor input shape) #7

@Jean-Baptiste-Camps

Description

@Jean-Baptiste-Camps

Here's another one.

Config,

model:
  name: BirthDeathPoisson
  config:
    n_init: 1000
    Nact: 1000
    Ninact: 1000
    max_pop: 100000

# Ground truth for scoring and generation
params:
  LDA: 0.0
  lda: 0.009
  gamma: 0.000
  mu: 0.003

inference:
  name: PyMC
  config:
    draws: 5
    chains: 4
    random_seed: 42
    epsilon: 1
    sum_stat: "identity"
    distance: "gaussian"

Result:

BirthDeathPoisson
Initializing SMC sampler...
Sampling 4 chains in 4 jobs
Chain 0 ⠼ -:--:-- / 0:00:43 Stage: 0 Beta: 0
Chain 1 ⠴ -:--:-- / 0:00:43 Stage: 0 Beta: 0
Chain 0 ⠴ -:--:-- / 0:00:47 Stage: 0 Beta: 0
Chain 1 ⠴ -:--:-- / 0:00:47 Stage: 0 Beta: 0
Chain 0 ⠏ -:--:-- / 0:00:54 Stage: 0 Beta: 0
Chain 1 ⠏ -:--:-- / 0:00:54 Stage: 0 Beta: 0
Chain 0 ⠸ -:--:-- / 0:00:54 Stage: 0 Beta: 0
Chain 1 ⠸ -:--:-- / 0:00:54 Stage: 0 Beta: 0
Chain 0 ⠼ -:--:-- / 0:00:54 Stage: 0 Beta: 0
Chain 1 ⠼ -:--:-- / 0:00:54 Stage: 0 Beta: 0
Chain 2 ⠼ -:--:-- / 0:00:54 Stage: 0 Beta: 0
Chain 3 ⠼ -:--:-- / 0:00:54 Stage: 0 Beta: 0
concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "simMAtree/env/lib/python3.12/site-packages/pytensor/compile/function/types.py", line 1037, in __call__
    outputs = vm() if output_subset is None else vm(output_subset=output_subset)
              ^^^^
ValueError: Input dimension mismatch: (input[%i].shape[%i] = %lld, input[%i].shape[%i] = %lld)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.12/concurrent/futures/process.py", line 264, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/pymc/smc/sampling.py", line 316, in _sample_smc_int
    smc._initialize_kernel()
  File "simMAtree/env/lib/python3.12/site-packages/pymc/smc/kernels.py", line 253, in _initialize_kernel
    likelihoods = [self.likelihood_logp_func(sample) for sample in self.tempered_posterior]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/pytensor/compile/function/types.py", line 1047, in __call__
    raise_with_op(
  File "simMAtree/env/lib/python3.12/site-packages/pytensor/link/utils.py", line 526, in raise_with_op
    raise exc_value.with_traceback(exc_trace)
  File "simMAtree/env/lib/python3.12/site-packages/pytensor/compile/function/types.py", line 1037, in __call__
    outputs = vm() if output_subset is None else vm(output_subset=output_subset)
              ^^^^
ValueError: Input dimension mismatch: (input[%i].shape[%i] = %lld, input[%i].shape[%i] = %lld)
Apply node that caused the error: Composite{sqr((i0 - i1))}(s{[1.8520000 ... 85965e-01]}, Simulator_s_rv{"(),(),()->()"}.out)
Toposort index: 8
Inputs types: [TensorType(float64, shape=(13,)), TensorType(float64, shape=(13,))]
Inputs shapes: [(13,), (6,)]
Inputs strides: [(8,), (8,)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Sum{axes=None}(Composite{sqr((i0 - i1))}.0)]]

HINT: Re-running with most PyTensor optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the PyTensor flag 'optimizer=fast_compile'. If that does not work, PyTensor optimizations can be disabled with 'optimizer=None'.
HINT: Use the PyTensor flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "simMAtree/env/bin/simmatree", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/click/core.py", line 1442, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/click/core.py", line 1363, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/click/core.py", line 1830, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/click/core.py", line 1226, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/click/core.py", line 794, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/click/decorators.py", line 46, in new_func
    return f(get_current_context().obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/src/__main__.py", line 47, in infer_command
    inference(
  File "simMAtree/env/lib/python3.12/site-packages/src/cli/inference.py", line 47, in inference
    inference_data = backend.run_inference(model=model, data=stats)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/src/inference/pymc_backend.py", line 58, in run_inference
    idata = pm.sample_smc(
            ^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/pymc/smc/sampling.py", line 193, in sample_smc
    results = run_chains(chains, progressbar, params, random_seed, kernel_kwargs, cores)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/pymc/smc/sampling.py", line 405, in run_chains
    return tuple(cloudpickle.loads(r.result()) for r in done)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "simMAtree/env/lib/python3.12/site-packages/pymc/smc/sampling.py", line 405, in <genexpr>
    return tuple(cloudpickle.loads(r.result()) for r in done)
                                   ^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
ValueError: Input dimension mismatch: (input[%i].shape[%i] = %lld, input[%i].shape[%i] = %lld)
Apply node that caused the error: Composite{sqr((i0 - i1))}(s{[1.8520000 ... 85965e-01]}, Simulator_s_rv{"(),(),()->()"}.out)
Toposort index: 8
Inputs types: [TensorType(float64, shape=(13,)), TensorType(float64, shape=(13,))]
Inputs shapes: [(13,), (6,)]
Inputs strides: [(8,), (8,)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Sum{axes=None}(Composite{sqr((i0 - i1))}.0)]]

HINT: Re-running with most PyTensor optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the PyTensor flag 'optimizer=fast_compile'. If that does not work, PyTensor optimizations can be disabled with 'optimizer=None'.
HINT: Use the PyTensor flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions