Views
No views yet
torch_neuronx.trace (fixed-shape tracing).inf2.xlarge, 1 NeuronCore)torch_neuronx.trace (fixed-shape)| File | Size | Description |
|---|---|---|
encoder.pt | 643 MB | Traced encoder (fixed 3000-frame input) |
decoder.pt | 4 GB | Traced decoder (autoregressive) |
1import torch
2import torch_neuronx
3from transformers import AutoProcessor
4
5processor = AutoProcessor.from_pretrained("Qwen/Qwen3-ASR-1.7B")
6encoder = torch.jit.load("encoder.pt")
7decoder = torch.jit.load("decoder.pt")
8
9# Always pad mel to exactly 3000 frames
10mel = processor(audio, return_tensors="pt").input_features # [1, 128, T]
11if mel.shape[-1] < 3000:
12 mel = torch.nn.functional.pad(mel, (0, 3000 - mel.shape[-1]))
13feature_lens = torch.tensor([3000]) # always 3000, not actual length
14
15encoder_out = encoder(mel, feature_lens)
16# ... autoregressive decode with decoderfeature_lens: Must always be torch.tensor([3000]) — actual length causes shape mismatch during tracing.NEURON_RT_VISIBLE_CORES=1,NEURON_RT_NUM_CORES=1 to use Core 1 alongside an LLM on Core 0.aqidd/qwen3-8b-int8-inf2 (LLM on Core 0) for a single inf2.xlarge serving both:1# LLM on Core 0
2NEURON_RT_VISIBLE_CORES=0 NEURON_RT_NUM_CORES=1 vllm serve Qwen/Qwen3-8B ...
3
4# ASR on Core 1
5NEURON_RT_VISIBLE_CORES=1 NEURON_RT_NUM_CORES=1 python3 asr_server.py