Skip to content

Visualization

CARL’s result and chain objects render themselves. Everything is text by default — opt into PNG output with pip install 'mmar-carl[viz]'.

result = chain.execute(context)
print(result.format_token_pie()) # "text" | "mermaid" | "png"
print(result.format_prompt_completion_breakdown())
print(result.format_profiling_table()) # per-step cost / latency / cache
print(result.format_cost_by_model(pricing={"qwen/qwen3-8b": (0.00002, 0.00006)}))

Also handy: result.token_usage_by_step, result.partial_outputs, result.get_partial_final_output().

print(chain.to_mermaid()) # the DAG
print(chain.to_mermaid_critical_path(result)) # highlight the critical path
print(chain.to_mermaid_heatmap(result, metric="tokens")) # "tokens" | "latency" | "cost"

ChainVisualizer is a fluent facade that buffers several views into one output:

from mmar_carl import ChainVisualizer
ChainVisualizer(result, chain=chain).token_pie().gantt().heatmap(metric="tokens").print()

It also accepts evolution_result= to fold in evolution charts.

ReasoningResult, EvolutionResult, DatasetEvaluationReport, CostEstimate, and ChainVisualizer all implement _repr_markdown_ — type the object bare in a notebook cell and it renders a status banner + tables + Mermaid, no print().