Skip to content

Commit 3b77f89

Browse files
committed
fix
1 parent 2d2628c commit 3b77f89

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/debug_utils.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,24 +438,26 @@ function check_model_and_trace(
438438
rng::Random.AbstractRNG,
439439
model::Model;
440440
varinfo=VarInfo(),
441-
context=SamplingContext(rng),
442441
error_on_failure=false,
443442
kwargs...,
444443
)
445444
# Execute the model with the debug context.
446445
debug_context = DebugContext(
447-
model, context; error_on_failure=error_on_failure, kwargs...
446+
model,
447+
SamplingContext(rng, model.context);
448+
error_on_failure=error_on_failure,
449+
kwargs...,
448450
)
451+
debug_model = DynamicPPL.contextualize(model, debug_context)
449452

450453
# Perform checks before evaluating the model.
451-
issuccess = check_model_pre_evaluation(debug_context, model)
454+
issuccess = check_model_pre_evaluation(debug_context, debug_model)
452455

453456
# Force single-threaded execution.
454-
debug_model = DynamicPPL.contextualize(model, debug_context)
455457
DynamicPPL.evaluate_threadunsafe!!(debug_model, varinfo)
456458

457459
# Perform checks after evaluating the model.
458-
issuccess &= check_model_post_evaluation(debug_context, model)
460+
issuccess &= check_model_post_evaluation(debug_context, debug_model)
459461

460462
if !issuccess && error_on_failure
461463
error("model check failed")

0 commit comments

Comments
 (0)