Skip to content

Commit 61cdd97

Browse files
committed
refactor(speechlm2): scope portable PEE support to serving
Signed-off-by: Piotr Żelasko <pzelasko@nvidia.com>
1 parent 84619ff commit 61cdd97

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

nemo/collections/asr/models/sortformer_diar_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ def forward_streaming_step(
10041004
spkcache_fifo_chunk_pre_encode_embs = self.sortformer_modules.concat_embs(
10051005
[streaming_state.spkcache, streaming_state.fifo, chunk_pre_encode_embs],
10061006
dim=1,
1007-
# A Sortformer nested in phPEE can retain Lightning's cached
1007+
# A Sortformer nested in ParallelExpertEncoder can retain Lightning's cached
10081008
# construction device after its parent moves. Activations are
10091009
# authoritative for streaming lengths and masks.
10101010
device=chunk_pre_encode_embs.device,

nemo/collections/asr/modules/parallel_expert_encoder.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,14 @@ def __init__(self, cfg: DictConfig, trainer: Optional[Trainer] = None):
278278
chunk_size_seconds=self._cfg.get("chunk_size_seconds", None),
279279
sync_max_audio_length=self._cfg.get("sync_max_audio_length", False),
280280
)
281+
# Preserve the architecture-only bundle configuration for consolidated
282+
# SpeechLM checkpoint export and serving reconstruction.
283+
self.encoder._bundle_config = _clone_config(self._cfg)
284+
self.encoder._bundle_config.diar_normalize_type = self.encoder.diar_normalize_type
285+
self.encoder._bundle_config.speaker_feature_config_version = _SPEAKER_FEATURE_CONFIG_VERSION
286+
self.encoder._bundle_config.speaker_feature_mode = self.encoder.speaker_feature_mode
287+
self.encoder._bundle_config.speaker_activity_threshold = self.encoder.speaker_activity_threshold
288+
self.encoder._bundle_config.sync_max_audio_length = self.encoder.sync_max_audio_length
281289

282290
@staticmethod
283291
def _validate_bundle_schema(cfg: DictConfig) -> None:
@@ -375,6 +383,21 @@ def load_from_nemo(
375383
)
376384
return bundle.encoder
377385

386+
@classmethod
387+
def from_inline_config(
388+
cls,
389+
cfg: Union[DictConfig, dict],
390+
*,
391+
map_location: Union[str, torch.device] = "cpu",
392+
) -> ParallelExpertEncoder:
393+
"""Construct the encoder architecture without loading standalone weights.
394+
395+
Consolidated SpeechLM checkpoints supply the encoder tensors from their
396+
root state dictionary after constructing it from this embedded config.
397+
"""
398+
shell = cls(cfg=OmegaConf.create(cfg), trainer=None)
399+
return shell.encoder.to(map_location)
400+
378401
@classmethod
379402
def save_to_nemo(
380403
cls,
@@ -445,6 +468,7 @@ class ParallelExpertEncoder(nn.Module):
445468
:class:`TransformerEncoder` used by Transformer AED ASR checkpoints.
446469
"""
447470

471+
supports_external_speaker_targets = True
448472
supports_sequence_packed_output = True
449473

450474
def __init__(

tests/collections/speechlm2/test_vllm_plugin.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ def test_full_stack_asr_exports_grouped_encoder_dependencies():
5555
from nemo.collections.asr.models import ASRModel, SortformerEncLabelModel
5656
from nemo.collections.asr.modules import (
5757
ConvASRDecoder,
58-
GGEMMTransformerEncoder,
59-
MoETransformerEncoder,
6058
ParallelExpertEncoder,
6159
TransformerEncoder,
6260
)
@@ -81,8 +79,6 @@ def test_full_stack_asr_exports_grouped_encoder_dependencies():
8179
for dependency in (
8280
SortformerEncLabelModel,
8381
ConvASRDecoder,
84-
GGEMMTransformerEncoder,
85-
MoETransformerEncoder,
8682
TransformerEncoder,
8783
ParallelExpertEncoder,
8884
ParallelExpertEncoderPT,

0 commit comments

Comments
 (0)