Repository navigation
Add Axon.capture - #643
Merged
Merged
Add Axon.capture#643
Conversation
Chapaman
marked this pull request as draft
August 14, 2026 23:44
Chapaman
marked this pull request as ready for review
August 17, 2026 21:06
polvalente
requested review from
polvalente
and
a balanced review from Copilot
October 7, 2026 22:14
polvalente
approved these changes
Oct 7, 2026
There was a problem hiding this comment.
🟡 Changes recommended
Graph truncation, output rewiring, parameter naming, input validation, and test coverage have unresolved issues.
6 open findings
What changed in this PR
Adds Axon.capture/2 for reusing and composing existing model graphs, optionally truncated at a named layer.
Changes:
- Adds the documented capture API.
- Resolves layer and input names.
- Rewires captured graphs to replacement inputs.
| File | Description |
|---|---|
lib/axon.ex |
Implements model capture, truncation, validation, and graph rewiring. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+4569
to
+4572
| merged_nodes = | ||
| Enum.reduce(new_inputs_map, nodes, fn {_k, %Axon{nodes: new_nodes}}, acc_nodes -> | ||
| Map.merge(new_nodes, acc_nodes) | ||
| end) |
| {node_id, %{node | parent: updated_parents}} | ||
| end) | ||
|
|
||
| %Axon{output: output_id, nodes: updated_nodes} |
|
|
||
| """ | ||
| @doc type: :graph | ||
| def capture(%Axon{} = axon, opts \\ []) when is_list(opts) do |
| "Available layers: #{inspect(available)}" | ||
| end | ||
|
|
||
| %Axon{axon | output: target_id} |
Comment on lines
+4540
to
+4541
| %{} = inputs_map -> | ||
| inputs_map |
Comment on lines
+4486
to
+4488
| fn new_inputs -> | ||
| rewire_inputs(truncated, input_name_to_id, new_inputs) | ||
| end |
Each pairing of one or many inputs with a tensor or a container output should keep the same values after the inputs are replaced.
polvalente
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Continues #626