fixed moonshine state resetting and gemma3 4b layernorm loading#317
Conversation
Signed-off-by: Karen Mosoyan <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR addresses Moonshine cache/state reset correctness and improves compatibility when loading Gemma3 4B layernorm weights, alongside a couple of related runtime behavior tweaks.
Changes:
- Add an additional output norm key pattern (
model.language_model.norm.weight) to support Gemma3 4B layernorm loading. - Fix Moonshine cache reset by invalidating and clearing persistent encoder-related node IDs (including
last_encoder_post_norm_node_and per-layer encoder K/V persistent nodes). - Update graph persistent invalidation semantics and remove Moonshine-specific trailing silence padding in the transcribe FFI path.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| python/src/weight_patterns.py | Extends output norm name matching to recognize an additional HF weight key. |
| cactus/models/model_moonshine.cpp | Ensures Moonshine reset clears/invalidates persistent nodes so encoder-derived cached nodes don’t survive across resets. |
| cactus/kernel/kernel_conv.cpp | Changes Apple Accelerate conv1d weight staging order. |
| cactus/graph/graph_builder.cpp | invalidate_persistent() now also removes IDs from the persistent-preservation set. |
| cactus/ffi/cactus_transcribe.cpp | Removes Moonshine waveform trailing-silence insertion before passing audio to the model. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| void CactusGraph::invalidate_persistent(size_t persistent_node_id) { | ||
| populated_node_ids_.erase(persistent_node_id); | ||
| persistent_node_ids_.erase(persistent_node_id); | ||
| } |
There was a problem hiding this comment.
invalidate_persistent() now also removes the node ID from persistent_node_ids_, which changes soft_reset() behavior (invalidated nodes will no longer be preserved across resets). There doesn’t appear to be test coverage for this contract; please add a unit test that creates a persistent node, executes to populate it, calls invalidate_persistent(), then soft_reset(), and asserts the invalidated node is no longer preserved / addressable (and can be safely recreated).
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
Signed-off-by: Karen Mosoyan <[email protected]>
No description provided.