Repository navigation
Refactor Conformer blocks to reuse shared feed-forward modules - #1309
Merged
Merged
Conversation
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.
Summary
Refactor all four Conformer block variants to compose the shared
FeedForwardModuleinstead of maintaining their own FFN implementations. Normalization, half-scaled residuals, attention/convolution ordering and streaming cache ownership remain with the Conformer blocks.Validation
An independent NumPy reference exercises complete blocks with nonzero attention, convolution and FFN weights, masks, biases, multiple batches and streaming caches. All four block variants pass 12 default-path cases on each of CPU, CUDA and Vulkan. Before/after outputs and returned caches are numerically identical; graph signatures and workspace sizes also match. Changed-input and original-input restoration checks pass.
Sequential warmed block benchmarks found no reproducible material regression: CPU +0.74%, CUDA −0.51%. Vulkan initially measured +3.10%; a longer reverse-order check measured −1.72%. These are component measurements, not end-to-end model RTF.
Caller A/B validation on CPU, CUDA and Vulkan produced identical outputs across 120 measured requests, unchanged sampled peak VRAM, and passed short-input, supplied-word, long→short→long and error-recovery checks.
Known numerical limitation: the additional squared-ReLU Vulkan diagnostic exceeds its absolute-error gate (0.000844 versus 0.0005), although cosine is 0.9999999924. This reproduces exactly with the unchanged main FFN implementation; default Conformer cases pass without relaxing tolerances. The existing Vulkan pitch-logit parity shortfall is likewise unchanged by this refactor.
On the updated main base, the parallel Debug build of the server and encoder module test passed, and the encoder module suite passed again.