[BUG] Inactive layer1x1 drops the activation from the WaveNet residual path
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- machine-learning
Research direction
Start in NAM/wavenet/model.cpp at _Layer::Process and inspect the inactive-layer1x1 branch in both the Eigen and NAM_USE_INLINE_GEMM paths. Compare its residual handling with nam/models/wavenet/_layer_array.py, lines 755–773, where the trainer adds post_activation to x. Done means the core output matches the trainer for an inactive layer1x1 model, including the reported residual-path comparison.
Written by the indexing model from the issue text.
Description
Summary
When a WaveNet layer has "layer1x1": {"active": false} (.nam 0.7 format), the core passes the residual input through unchanged instead of adding the layer's activation output to it. The trainer (neural-amp-modeler) computes x + post_activation in that case, so the core's output diverges from the trainer's for such models.
Where
- Core (
main@ 0b3d3c97b0, also v0.5.4):NAM/wavenet/model.cpp,_Layer::Process…inactive-layer1x1branch (around line 385):// If layer1x1 is inactive, residual connection is just the input (identity) ...memcpy(... input.data() ...) // NAM_USE_INLINE_GEMM path this->_output_next_layer.leftCols(num_frames).noalias() = input.leftCols(num_frames); // Eigen path - Trainer (
main@ 0072676419):nam/models/wavenet/_layer_array.py, lines ~755–773:
i.e. withlayer_output = post_activation if self._layer1x1 is not None: layer_output = self._layer1x1(layer_output) ... residual = x[:, :, -layer_output.shape[2]:] + layer_outputlayer1x1inactive the residual isx + post_activation, notx.
Impact
On a model exported by neural-amp-modeler 0.13.0 with layer1x1 inactive on one layer array, the core's output differed from the trainer's PyTorch output (pad_start=True) by up to ~0.4 on that array and ~1.9e-3 at the model output. With the residual add restored, the core matches the trainer to ~6e-8.
Suggested fix
In the inactive branch, add the activation output (the bottleneck rows of _z) to the input instead of copying it, in both the Eigen path and the NAM_USE_INLINE_GEMM path, e.g. for the Eigen path:
this->_output_next_layer.leftCols(num_frames).noalias() =
input.leftCols(num_frames) + this->_z.topRows(bottleneck).leftCols(num_frames);
(Assuming bottleneck == channels is required when layer1x1 is inactive, as the residual shapes imply.)
- Dominant language
- C++
- Stars
- 969
- Forks
- 185
- Avg merge
- 36m
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sdatkinson/NeuralAmpModelerCore
-
[BUG] Hardtanh ignores min_val/max_val from the .nam configPossibly taken @andrenepomuceno claimed this 18 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sdatkinson/NeuralAmpModelerCore#342 ·
Maintainers usually reply within 1 day
-
get_dsp() aborts the process on well-formed JSON that is not a NAM modelPossibly taken @guicybercode claimed this 25 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sdatkinson/NeuralAmpModelerCore#328 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sdatkinson/NeuralAmpModelerCore#305 · 1 comment ·
Maintainers usually reply within 1 day
-
Build on FreeBSD: "minor" and "major" in get_dsp.h cause build errorPossibly taken @Helshr claimed this 50 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
sdatkinson/NeuralAmpModelerCore#304 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
sdatkinson/NeuralAmpModelerCore#327 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in sdatkinson/NeuralAmpModelerCore
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
FriendsofECCE/ECCE#336 · 1 comment ·
-
Real literal with a 'd' exponent and a kind suffix (1.0d0_4) is accepted; the suffix is ignoredOpenerror not reported low priority semantics
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
bitcoin-core/gui-qml#1030 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day