Repository navigation
Only write printed type names into the IR when asked to - #3711
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/37088582797/artifacts/11261497460. |
|
Generated by Claude Code |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3711 +/- ##
==========================================
+ Coverage 75.88% 80.10% +4.21%
==========================================
Files 71 71
Lines 24486 24180 -306
==========================================
+ Hits 18581 19369 +788
+ Misses 5905 4811 -1094 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Generated by Claude Code |
Enzyme writes the printed Julia type next to types it records in the IR: the `enzymejl_parmtype_str` attribute, one `enzymejl_source_type_<T>` metadata kind per type, and `enzymejl_allocart_name`. Nothing reads them; they help when reading IR dumps. Printing a type is slow on Julia 1.12, because `show` looks through module bindings for an alias of the type, and `set_module_types!` and `compile_unhooked_impl` record a type for most instructions of every function in the module. Emit them only when `Enzyme.Compiler.EmitTypeNames[]` is set. On the Enzyme tests of TensorKit.jl this saves 5-15% of the time of each test_reverse call (472 s -> 427 s for 72 calls). Assisted-by: Claude Code (Opus 5.5)
Co-authored-by: Valentin Churavy <v.churavy@gmail.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTwXtqA78uTQz6CYsAJDzb
1739603 to
e42fd02
Compare
Requested by Valentin
Enzyme writes the printed Julia type next to types it records in the IR:
enzymejl_parmtype_strparameter/return attribute (set_module_types!,lower_convention,specsig_function!),enzymejl_source_type_<T>metadata kind per type (compile_unhooked_impl,memcpy_alloca_to_loadstore), which also registers a new metadata kind in the context for every distinct type,enzymejl_allocart_name.Nothing reads these; they only help when reading IR dumps. The C++ side only copies
enzymejl_allocart_namealong withenzymejl_allocartwhen it replaces an alloca, and does nothing if it is missing.Printing a type is slow on Julia 1.12 (
showlooks through module bindings for an alias of the type:make_typealias,jl_get_binding_partition), and Enzyme records a type for most loads, allocas and calls of every function in the module. In a profile of a TensorKit.jltest_reversecall this was the largest single item insidecompile_unhooked_impl.This PR emits the names only when
Enzyme.Compiler.EmitTypeNames[]is set, like the existingDump*debug flags.Measurement
The Enzyme tests of TensorKit.jl (QuantumKitHub/TensorKit.jl#464,
svd_trunc_no_error/lq_compact/qr_compact, Trivial and Z2 sectors, Float64 and ComplexF64, two tensor shapes; 72test_reversecalls, each compiling one new thunk), Julia 1.12.7, both configurations run at the same time:That's 5-15% per call, and all tests passed in both runs.
Tests
Added a test that turns
EmitTypeNames[]on and checks a gradient, so the debug path keeps compiling.optimize,basic,callconvandrooted_argspass locally on 1.12.🤖 Generated with Claude Code