원클릭으로
inspect
// Inspect the AD pipeline IR for a Julia function at each Mooncake compilation stage.
// Inspect the AD pipeline IR for a Julia function at each Mooncake compilation stage.
Scrutinise newly added or changed code on the current branch against main. Checks new types, methods, changed signatures, overloads, and helpers for necessity, correctness, clarity, consistency, robustness, and minimality. Reviews new tests for gap coverage, overlap with existing tests, minimality, and use of established testing patterns. Invoke with /scrutinise.
Prune a bug fix or new tests down to the smallest correct diff through multiple elimination passes. Use before committing any fix or test addition.
| name | inspect |
| description | Inspect the AD pipeline IR for a Julia function at each Mooncake compilation stage. |
Inspect IR transformations in Mooncake's AD pipeline for a given function.
using Mooncake, Mooncake.SkillUtils
Ask the user:
sin, 1.0 or a custom functionDo not assume — ask the user to pick.
| Stage | Symbol | Description |
|---|---|---|
| Raw IR | :raw | optimised, type-inferred SSAIR from Julia's compiler |
| Normalised | :normalized | after Mooncake's normalisation passes |
| BBCode | :bbcode | BBCode representation with stable IDs |
| Forward IR | :fwd_ir | generated forward-pass IR |
| Reverse IR | :rvs_ir | generated pullback IR |
| Optimised Forward | :optimized_fwd | forward pass after optimisation |
| Optimised Reverse | :optimized_rvs | pullback after optimisation |
| Stage | Symbol | Description |
|---|---|---|
| Raw IR | :raw | optimised, type-inferred SSAIR from Julia's compiler |
| Normalised | :normalized | after Mooncake's normalisation passes |
| BBCode | :bbcode | inspection-only — forward mode does not use BBCode internally |
| Dual IR | :dual_ir | generated dual-number IR |
| Optimised | :optimized | after optimisation passes |
# Full inspection
ins = inspect_ir(f, args...; mode=:reverse) # or mode=:forward
# View stages
show_ir(ins) # all stages
show_stage(ins, :raw) # one stage
# Diffs between stages
show_diff(ins; from=:raw, to=:normalized)
show_all_diffs(ins)
# World age debugging
show_world_info(ins)
# Write everything to files
write_ir(ins, "/tmp/ir_output")
# Shorthand helpers
ins = inspect_fwd(f, args...) # forward mode
ins = inspect_rvs(f, args...) # reverse mode
ins = quick_inspect(f, args...) # inspect + display immediately
# Options
inspect_ir(f, args...;
mode = :reverse,
optimize = true,
do_inline = true,
debug_mode = false,
)
Inspects Mooncake's internal AD pipeline only. For allocation, world-age, or compiler-boundary debugging, see docs/src/developer_documentation/advanced_debugging.md.