Gradient flow backpropagation validation
Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder
npx -y skills add HolobiomicsLab/asb-skill-collections --skill gradient-flow-backpropagation-validationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 14 stars14 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when after implementing a multi-task fusion module (such as FuseBlock) that combines feature tensors from multiple prediction branches (e.g., isotope, charge, retention-time) and must verify that backpropagation signals flow from the fused representation to each upstream branch.
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
7.0 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
gradient-flow-backpropagation-validation
Summary
Verify that gradients flow correctly through a multi-task learning architecture during backpropagation, ensuring that loss signals from fused feature representations propagate back to all upstream task-specific branches. This validation is critical in multi-dimensional fusion models to confirm that auxiliary task gradients contribute to the shared representation learning.
When to use
Apply this skill after implementing a multi-task fusion module (such as FuseBlock) that combines feature tensors from multiple prediction branches (e.g., isotope, charge, retention-time) and must verify that backpropagation signals flow from the fused representation to each upstream branch. Use it whenever you integrate gradient flow from a unified fused feature representation back to task-specific branches to enable multi-task learning signal propagation.
When NOT to use
- Input tensors are already detached or require_grad=False; no gradients will flow regardless of architecture.
- Model is in evaluation mode (.eval()) or gradients have been explicitly disabled (torch.no_grad() context); backpropagation will not occur.
- Fusion module contains only non-differentiable operations (e.g., argmax, indexing without gradient flow); gradients cannot propagate through such operations.
Inputs
- PyTorch feature tensors from isotope prediction branch
- PyTorch feature tensors from charge prediction branch
- PyTorch feature tensors from retention-time prediction branch
- FuseBlock module (initialized with learnable parameters)
- Scalar loss value computed from fused representation
Outputs
- Gradient tensor for each upstream branch parameter
- Confirmation report (boolean or gradient statistics) indicating gradient flow success
- Computational graph visualization (optional)
How to apply
Implement gradient flow validation by: (1) constructing a minimal PyTorch forward pass through the FuseBlock module with input feature tensors from each branch (isotope, charge, retention-time); (2) computing a scalar loss from the fused output; (3) calling .backward() on the loss; (4) inspecting the .grad attribute of each upstream branch's parameters to confirm non-None gradients with non-zero values; (5) optionally using torch.autograd.grad() or gradient checkpointing utilities to trace the computational graph and verify connectivity from the fused loss back through concatenation/fusion operations to each input branch. The validation passes when all upstream parameters accumulate non-zero gradients, confirming that auxiliary task signals flow bidirectionally into the shared representation.
Related tools
- PyTorch (Implements FuseBlock module, backward pass, and gradient inspection via .grad and torch.autograd.grad())
- IsoFusion (Reference implementation of multi-task learning architecture with FuseBlock component requiring gradient flow validation) — https://github.com/xfcui/IsoFusion
Examples
# PyTorch gradient flow validation for FuseBlock
import torch
from IsoFusion.model import FuseBlock
fuse_block = FuseBlock()
isotope_feat = torch.randn(32, 64, requires_grad=True)
charge_feat = torch.randn(32, 64, requires_grad=True)
rt_feat = torch.randn(32, 64, requires_grad=True)
fused = fuse_block(isotope_feat, charge_feat, rt_feat)
loss = fused.sum()
loss.backward()
assert isotope_feat.grad is not None, "Isotope branch gradient is None"
assert charge_feat.grad is not None, "Charge branch gradient is None"
assert rt_feat.grad is not None, "Retention-time branch gradient is None"
print("Gradient flow validation passed")
Evaluation signals
- All upstream branch parameters (isotope, charge, retention-time) have .grad attributes that are not None after .backward().
- Gradient magnitudes for each branch are non-zero and within reasonable ranges (not NaN, Inf, or identically zero across all iterations).
- Output shape from FuseBlock matches expected unified fused feature representation dimensions before loss computation.
- Loss value decreases across training iterations, indicating that gradients are being used to update parameters in all branches.
- Computational graph trace shows unbroken paths from loss node back through fusion operation to each input branch tensor.
Limitations
- Gradient flow validation only confirms structural connectivity; it does not guarantee that auxiliary tasks meaningfully improve main task performance or that learned feature fusion is optimal.
- Vanishing or exploding gradients may still occur in deeper networks; small non-zero gradients may not effectively train upstream branches.
- Validation is local to the module; it does not account for downstream losses or interaction effects when multiple loss terms are combined in practice.
Evidence
- [other] Integrate gradient flow from the fused representation back to each feature dimension branch to enable multi-task learning signal propagation.: "Integrate gradient flow from the fused representation back to each feature dimension branch to enable multi-task learning signal propagation."
- [other] Validate the module outputs expected shape and verify gradients flow correctly during backpropagation.: "Validate the module outputs expected shape and verify gradients flow correctly during backpropagation."
- [readme] Using the multi-task learning to predict charge, number of isotopes and retention time simultaneously, the auxiliary task can help improve the learning performance of the main task: "Using the multi-task learning to predict charge, number of isotopes and retention time simultaneously, the auxiliary task can help improve the learning performance of the main task"
- [other] Apply a series of fully connected layers to produce a unified fused feature representation.: "Apply a series of fully connected layers to produce a unified fused feature representation."
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.