Repository navigation
v0.5.0 — models start settled, Linear and Sequential, nine activations
The largest release so far. Models now start settled and match NAM Core from the first sample, two more architectures and five more activations load, and a batch of files that used to load wrongly, or bring the process down, are handled. It is a breaking release: read Breaking before upgrading.
Breaking
The parsed types are #[non_exhaustive] (#81). Error, ModelConfig, ActivationSpec, GatingMode, NamModel and every config struct inside it. Downstream code has to:
- give a
matchon one of the enums a wildcard arm; - end a pattern on one of the structs, or on
ActivationSpec::Named, in..; - get config values by parsing a
.namfile. A struct literal no longer compiles outside the crate.
Field access is unchanged. This is what lets a new architecture, error or config key arrive in a 0.5.x from now on, as Linear and Sequential would not have been able to.
Model::from_nam and Model::reset now prewarm (#70). A model comes back settled against silence, as NAM Core's does, so the first block is clean and the output matches NAM Core from the first sample. Compared with 0.4.1 this changes the samples a model used to spend on its startup transient: the receptive field for a WaveNet, and up to about half a second for an LSTM whose stored state is not already settled. Model::from_nam_without_prewarm and Model::reset_without_prewarm give the zero-filled start that 0.4.1 gave. reset does not run the model again: it copies back the state captured at load, and stays allocation-free.
File versions are checked (#83). A file whose version is outside 0.5.0 to 0.7.x, the range NAM Core loads, fails with the new Error::UnsupportedVersion. Until now such a file loaded if its config happened to parse.
MSRV is 1.77 (#80). The 1.71 that 0.4.1 declared stopped being true when thiserror raised its own floor.
Added
- Linear (#87): NAM's impulse response as a model. Mono, convolved directly at the file's own sample rate. It also runs as a container submodel and as a WaveNet's
condition_dsp. - Sequential (#91): complete models in series in one file, such as an amp model followed by an impulse response. A chain always starts settled.
- Five more activations (#58, thanks to @JustinLakra): Hardtanh, Softsign, SiLU, Hardswish and Fasttanh, as a layer's activation, as a gate's, and in the post-stack head. That makes nine of NAM Core's eleven.
- Prewarm control (#70):
Model::prewarm(),Model::prewarm_samples(), and the two opt-outs above.WaveNetandLstmgainprewarmandprewarm_samplestoo. - Loaders for a file already in memory (#74):
NamModel::from_slice(&[u8])andNamModel::from_reader(impl Read). - Slimmable controls (#76):
size_breakpoints()for snapping a dial to the submodel boundaries, andselect_and_reset()/set_slim_size_and_reset(), which reset the incoming submodel before it takes over, as NAM Core does.selectandset_slim_sizeare unchanged. head_dilation(#84) on a layer array's head, which NAM Core v0.6.0 reads.
Performance
The LSTM is faster again (#96, thanks to @sreichholf): the cell is vectorized, and process_buffer dispatches to an AVX2 build at run time, as the WaveNet already did. Output is bit-identical to before.
LSTM, process_buffer, µs/sample |
0.4.1 | 0.5.0 |
|---|---|---|
| 3 × 18 (trained) | 1.41 | 0.80 |
| 2 × 16 (trained) | 0.93 | 0.36 |
| 1 × 8 | 0.26 | 0.09 |
128-sample blocks on a 2.1 GHz Xeon cloud vCPU. process_sample gains too.
The repository also has a benchmark against NAM Core itself on the same models, input and blocks (#93, also @sreichholf): tests/oracle/bench.sh.
Fixed
Wrong output with no error:
layer1x1_post_filmwas applied only under BLENDED gating. It is now applied under every gating mode, as the trainer and NAM Core v0.6.0 do (#69).- A file that set
head_dilationabove 1 ran as if it were 1 (#84). - A layer array using the older
gatedkey together with asecondary_activationran that activation as the gate, where NAM Core always uses a Sigmoid there (#97).
Loading:
- A crafted
.namcould panic or abort the whole process inModel::from_nam: an oversized dilation, a convolution with no channels, an LSTM with weightless layers, layer arrays that do not fit together. These now returnError::ConfigTooLargeorError::UnsupportedFeaturebefore anything is allocated (#77). - A WaveNet whose
condition_dspis at another sample rate used to load and run the nested model at the wrong rate. It is refused, as NAM Core refuses it (#89). secondary_activationis read only where NAM Core reads it: on a layer thatgating_modegates. An ungated layer with an empty or unknown name there now loads; a gated layer withnullthere is now refused (#97).- An LSTM stating
"sample_rate": -1, NAM Core's value for an unknown rate, is prewarmed as one that states none (#92). - On 32-bit x86 without SSE2 the fast
tanhandsigmoidwere wrong by up to 0.17. Those targets now usestd's (#82).
Compatibility
Output against 0.4.1. The opening samples after a load or a reset differ, because the model now starts settled. After that the output is the same as 0.4.1's, except for files that one of the fixes above applies to.
Parity. The claim is now two bounds against the reference, both from the first sample: an error-to-signal ratio of at most 1e-10, and no sample off by more than 1e-4 times the larger of 1 and the reference's peak (#78). Over 109 real captures the worst error-to-signal ratio is 2.5e-12 and the worst sample is 1.3e-5 off. The C++ oracle is NAM Core v0.6.0 (#67), and its output is now recorded at full f32 precision (#75).
Which files load. Stricter in several places, as above: file versions, a condition_dsp at another sample rate, structurally inconsistent configs, and a null gate activation on a gated layer. That includes one shape the Python trainer exports and NAM Core also refuses, a condition_dsp nested two deep with a rate stated on the first only. Looser in one: junk in secondary_activation on an ungated layer.
Platforms. CI now runs the tests on aarch64 as well as x86-64 (#82), and checks that the library builds on the MSRV (#80).
Not supported yet: the ConvNet architecture, the LeakyHardtanh and PReLU activations, mixed gating modes within one layer array, and multi-channel input. A file that needs one of these fails at load with an error that names it. #33 tracks the remaining gap to NAM Core.
The real-time-safety contract is unchanged: processing, reset and slimmable switching allocate nothing, take no locks and make no system calls, on every architecture.