Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- docs/af3_spatial_design.md +118 -0
- docs/baseline_experiments.md +257 -0
- docs/paper_outline.md +453 -0
- docs/qa_training_smoke.md +83 -0
- docs/qwen3_env.md +77 -0
- docs/qwen3_h20_ddp_curriculum.md +281 -0
- docs/seld233_implementation.md +417 -0
- docs/seld233_scaffold.md +224 -0
- docs/seld233_validation.md +56 -0
- docs/spatial_beats_design.md +511 -0
- docs/spatial_encoder_plan.md +417 -0
- docs/spatial_qwen3_design.md +821 -0
- docs/spur_seld_handover.md +312 -0
- docs/unified_foa_fsd63_dataset.md +255 -0
- runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/epoch_metrics.jsonl +1 -0
- runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/processor/processor_config.json +35 -0
- runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/processor/tokenizer_config.json +34 -0
- runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/train_args.json +75 -0
- runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/valid_predictions/epoch_001.jsonl +0 -0
- runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/valid_predictions/epoch_001.score.json +202 -0
- runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/valid_predictions/epoch_001.scored.jsonl +0 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/epoch_metrics.jsonl +1 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/processor/processor_config.json +35 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/processor/tokenizer_config.json +34 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/train_args.json +75 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/valid_predictions/epoch_001.score.json +202 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/valid_predictions/epoch_001.scored.jsonl +0 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/epoch_metrics.jsonl +3 -0
- runs/qwen3_curriculum/easy/stage3_beats_lora/train_args.json +75 -0
- runs/qwen3_full_v4_easy/stage_encoder_lora/epoch_metrics.jsonl +1 -0
- runs/qwen3_full_v4_easy/stage_encoder_lora/processor/processor_config.json +35 -0
- runs/qwen3_full_v4_easy/stage_encoder_lora/processor/tokenizer_config.json +34 -0
- runs/qwen3_full_v4_easy/stage_encoder_lora/train_args.json +75 -0
- runs/qwen3_full_v4_easy/stage_encoder_lora/valid_predictions/epoch_001.jsonl +0 -0
- runs/qwen3_full_v4_easy/stage_encoder_lora/valid_predictions/epoch_001.score.json +202 -0
- runs/qwen3_full_v4_easy/stage_encoder_lora/valid_predictions/epoch_001.scored.jsonl +0 -0
- runs/stage2_lower_lr/epoch_metrics.jsonl +1 -0
- runs/stage2_lower_lr/processor/added_tokens.json +25 -0
- runs/stage2_lower_lr/processor/chat_template.jinja +7 -0
- runs/stage2_lower_lr/processor/merges.txt +0 -0
- runs/stage2_lower_lr/processor/preprocessor_config.json +31 -0
- runs/stage2_lower_lr/processor/special_tokens_map.json +32 -0
- runs/stage2_lower_lr/processor/tokenizer_config.json +218 -0
- runs/stage2_lower_lr/processor/vocab.json +0 -0
- runs/stage2_lower_lr/train_args.json +68 -0
- runs/stage2_lower_lr/valid_predictions/epoch_001.jsonl +32 -0
- runs/v13d_easy_llmqa_af3/stage1_projector/epoch_metrics.jsonl +2 -0
- runs/v13d_easy_llmqa_af3/stage1_projector/processor/chat_template.jinja +6 -0
- runs/v13d_easy_llmqa_af3/stage1_projector/processor/processor_config.json +23 -0
- runs/v13d_easy_llmqa_af3/stage1_projector/processor/tokenizer_config.json +20 -0
docs/af3_spatial_design.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AF3 + Spatial-BEATs 设计说明
|
| 2 |
+
|
| 3 |
+
本目录下的四份新文件实现了把 Spatial-Qwen 的 Spatial 接入范式迁移到
|
| 4 |
+
NVIDIA Audio Flamingo 3 (AF3) 上。
|
| 5 |
+
|
| 6 |
+
## 核心结论
|
| 7 |
+
|
| 8 |
+
| 维度 | Spatial-Qwen | Spatial-AF3 |
|
| 9 |
+
|---|---|---|
|
| 10 |
+
| Base LLM hidden | 3584 | **3584**(相同,projector 无需调) |
|
| 11 |
+
| 基座 | Qwen2.5-Omni Thinker/Talker | AF3 = Whisper Enc + **Qwen2-7B Dec** |
|
| 12 |
+
| Spatial 注入机制 | `inputs_embeds.masked_scatter` | 同 |
|
| 13 |
+
| 占位符 | `<\|spatial\|>` | `<spatial>`(新加,token id=151672) |
|
| 14 |
+
| RoPE 定制 | 需要(M-RoPE 3 段) | **不需要**(AF3 用标准 1D RoPE) |
|
| 15 |
+
| Audio 占位符 | `<\|AUDIO\|>` | `<sound>`(AF3 原生) |
|
| 16 |
+
| LoRA 前缀 | `thinker.model` | `language_model.model` |
|
| 17 |
+
|
| 18 |
+
## 新增文件
|
| 19 |
+
|
| 20 |
+
| 路径 | 作用 |
|
| 21 |
+
|---|---|
|
| 22 |
+
| `spatial_qwen/model/modeling_spatial_af3.py` | `AudioFlamingo3SpatialForConditionalGeneration`:AF3 子类,新增 `spatial_beats_encoder` + `spatial_beats_projector`,重写 `forward` 按 `<sound>` → `<spatial>` 两次 `masked_scatter` 注入 |
|
| 23 |
+
| `spatial_qwen/model/processing_spatial_af3.py` | `AudioFlamingo3SpatialProcessor`:AF3 Processor 子类,接受 FOA 4ch,W 通道走 Whisper、全 4 通道送给 BEATs,扩展 `<spatial>` 占位符 |
|
| 24 |
+
| `train_spatial_af3_qa.py` | 三阶段训练入口(projector_only / encoder_lora / beats_lora),重用 `train_spatial_beats_qa.py` 里所有与模型无关的工具 |
|
| 25 |
+
| `scripts/bench_test_generate_af3.py` | test split 生成脚本,predictions.jsonl 与 Qwen 路径完全同格式,可直接喂给 `score_test_predictions.py` |
|
| 26 |
+
| `shell/launch_train_spatial_af3_qa.sh` | 启动脚本,默认环境变量 + 分布式包装 |
|
| 27 |
+
|
| 28 |
+
## 关键设计决策
|
| 29 |
+
|
| 30 |
+
### 1. transformers fork 依赖
|
| 31 |
+
AF3 需要 NVIDIA 本地 fork(版本 5.0.0rc1,在 spur env 的 4.52.0 下不兼容)。
|
| 32 |
+
训练脚本在 `main()` 起始就把 fork 路径插到 `sys.path` 最前面(`ensure_af3_on_path`),
|
| 33 |
+
确保后续所有 `import transformers.*` 走 fork 版。
|
| 34 |
+
|
| 35 |
+
启动脚本也会导出 `PYTHONPATH`,并强烈建议**独立 conda env**(`af3`),见 shell 脚本 comment。
|
| 36 |
+
|
| 37 |
+
### 2. FOA → Whisper 只喂 W 通道
|
| 38 |
+
AF3 的 Whisper encoder 是单声道的,无法直接吃 4ch FOA。Processor 内部对 FOA 样本取
|
| 39 |
+
W(第一声道)送给 Whisper,同时把全 4 通道保留给 Spatial-BEATs encoder。
|
| 40 |
+
|
| 41 |
+
### 3. 不子类化 `AudioFlamingo3Config`
|
| 42 |
+
`AutoConfig.from_pretrained` 通过 `model_type` 字符串做 registry 查找;
|
| 43 |
+
子类化会导致 registry 冲突。改用**运行时往 config 对象上 attach 字段**的方式
|
| 44 |
+
(与 Qwen 路径的 `tc.spatial_beats_*` 完全同模式)。
|
| 45 |
+
|
| 46 |
+
### 4. `<sound>` 与 `<spatial>` 两次独立 masked_scatter
|
| 47 |
+
`forward()` 里先跑 AF3 原生的 `<sound>` 注入(抄自 parent),再跑 `<spatial>` 注入。
|
| 48 |
+
两次操作写入不同的 token 位,互不干扰。
|
| 49 |
+
|
| 50 |
+
### 5. KV-cache decode 时跳过空间编码器
|
| 51 |
+
`prepare_inputs_for_generation` 只在 `cache_position[0] == 0`(prefill)时把
|
| 52 |
+
`spatial_audio` / `spatial_tokens` 挂上,decode 阶段剥离,避免每解码一个 token
|
| 53 |
+
就重跑一遍 BEATs(那会让 generate 变得无法用)。
|
| 54 |
+
|
| 55 |
+
### 6. Checkpoint 格式与 Qwen 完全一致
|
| 56 |
+
`trainable_state_dict` + optimizer + scheduler + metrics,`score_test_predictions.py`
|
| 57 |
+
不需要任何改动。
|
| 58 |
+
|
| 59 |
+
## 使用方法
|
| 60 |
+
|
| 61 |
+
### 1. 准备环境
|
| 62 |
+
```bash
|
| 63 |
+
# 建议独立 env,避免和 Spatial-Qwen 的 transformers 4.52 冲突
|
| 64 |
+
conda create -n af3 python=3.10 -y
|
| 65 |
+
conda activate af3
|
| 66 |
+
cd /apdcephfs_cq10/.../model/transformers && pip install -e .
|
| 67 |
+
pip install peft torch numpy soundfile tensorboard tqdm
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### 2. 训练
|
| 71 |
+
```bash
|
| 72 |
+
conda activate af3
|
| 73 |
+
bash shell/launch_train_spatial_af3_qa.sh
|
| 74 |
+
# 只跑 stage2
|
| 75 |
+
START_STAGE=2 bash shell/launch_train_spatial_af3_qa.sh
|
| 76 |
+
# 也要跑 stage3(BEATs 解冻)
|
| 77 |
+
START_STAGE=3 RUN_STAGE3=1 bash shell/launch_train_spatial_af3_qa.sh
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
### 3. 评测(test split)
|
| 81 |
+
```bash
|
| 82 |
+
torchrun --nproc_per_node=8 scripts/bench_test_generate_af3.py \
|
| 83 |
+
--run-dir runs/v13d_easy_llmqa_af3/stage2_encoder_lora \
|
| 84 |
+
--checkpoint-tags best \
|
| 85 |
+
--qa-root /apdcephfs_cq10/.../easy_filtered \
|
| 86 |
+
--split test
|
| 87 |
+
python scripts/score_test_predictions.py \
|
| 88 |
+
--predictions-jsonl runs/v13d_easy_llmqa_af3/stage2_encoder_lora/bench/test/best/predictions.jsonl \
|
| 89 |
+
--azimuth-threshold-deg 20 --elevation-threshold-deg 10
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## 已知 gotcha / 待验证项
|
| 93 |
+
|
| 94 |
+
1. **Processor 的 `save_pretrained()`**:`AudioFlamingo3Processor` 可能不支持
|
| 95 |
+
额外的 spatial 字段持久化;训练时已 try/except。读回时 `AutoProcessor` 不会
|
| 96 |
+
恢复 `spatial_token` 设置,**评测脚本每次重新构造 processor 是正确做法**。
|
| 97 |
+
|
| 98 |
+
2. **`resize_token_embeddings` 初始化**:新增的 `<spatial>` embedding 行随机初始化。
|
| 99 |
+
与 Qwen 路径一致;实际推理时会被 BEATs 投影立即覆盖,所以随机值无影响。
|
| 100 |
+
|
| 101 |
+
3. **BEATs → AF3 可能需要独立的 projector 初始化**:AF3 embed 分布与
|
| 102 |
+
Qwen2.5-Omni 不同,从 Spatial-Qwen easy 训好的 projector 热启动可能不稳定。
|
| 103 |
+
首次训练建议**从头 stage1**,跑 ~1 epoch 看 loss 曲线。
|
| 104 |
+
|
| 105 |
+
4. **长音频 vs `max_audio_len=600`**:AF3 processor 默认支持最长 600s(20 个 30s
|
| 106 |
+
窗口),但 Spatial-Qwen 的约定是 20s / 16kHz。我们保持 20s 上限(见
|
| 107 |
+
`spatial_audio_max_seconds=20.0`),`<sound>` 的 token 数对应 ~375 个 token。
|
| 108 |
+
|
| 109 |
+
## 冒烟测试
|
| 110 |
+
|
| 111 |
+
建议第一次跑先做 128 个样本的小规模验证:
|
| 112 |
+
```bash
|
| 113 |
+
torchrun --nproc_per_node=1 train_spatial_af3_qa.py \
|
| 114 |
+
--max-train-samples 128 --max-valid-samples 32 \
|
| 115 |
+
--epochs 1 --projector-only \
|
| 116 |
+
--qa-root /apdcephfs_cq10/.../easy_filtered \
|
| 117 |
+
--output-dir runs/af3_smoke
|
| 118 |
+
```
|
docs/baseline_experiments.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Simple Spatial Token Baseline Experiments
|
| 2 |
+
|
| 3 |
+
This document defines two lightweight spatial-token baselines for comparing
|
| 4 |
+
against the current SELD233-based spatial encoder in the Qwen spatial QA setup.
|
| 5 |
+
|
| 6 |
+
## Goal
|
| 7 |
+
|
| 8 |
+
The current strong model path is:
|
| 9 |
+
|
| 10 |
+
```text
|
| 11 |
+
FOA audio -> DCASE/SELD233 feature bridge -> SELD233 backbone -> spatial adapter
|
| 12 |
+
-> 2.5 Hz spatial tokens -> projector -> Qwen LLM
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
For 20 s audio with task `235`, the expected rate is:
|
| 16 |
+
|
| 17 |
+
```text
|
| 18 |
+
feature frames: 100 Hz, hop_len=160
|
| 19 |
+
SELD frames: 10 Hz, feature_to_seld_ratio=10
|
| 20 |
+
spatial tokens: 2.5 Hz, downsample_factor=4
|
| 21 |
+
20 s segment: 50 spatial tokens
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
Every baseline below must match the same spatial token rate and prompt contract:
|
| 25 |
+
|
| 26 |
+
```text
|
| 27 |
+
<|AUDIO|><|spatial|>
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
The comparison should answer whether the full SELD233 encoder is actually
|
| 31 |
+
needed, or whether simpler spatial cues already explain most of the QA gains.
|
| 32 |
+
|
| 33 |
+
## Baseline A: Raw FOA Intensity Vector Tokens
|
| 34 |
+
|
| 35 |
+
Use only the FOA intensity-vector channels as spatial input.
|
| 36 |
+
|
| 37 |
+
The existing feature bridge already computes baseline-compatible features:
|
| 38 |
+
|
| 39 |
+
```text
|
| 40 |
+
[B, 7, T_feat, F]
|
| 41 |
+
channels 0..3: W/X/Y/Z log-mel
|
| 42 |
+
channels 4..6: FOA intensity-vector features
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
For task `235`, `F=128`. The IV baseline should use channels `4..6` only.
|
| 46 |
+
|
| 47 |
+
Do not use full frequency averaging as the primary baseline. It is too lossy:
|
| 48 |
+
it collapses `[3, F]` IV structure into only 3 numbers per frame before the
|
| 49 |
+
0.4 s temporal pooling step. Keep it only as a lower-bound sanity check.
|
| 50 |
+
|
| 51 |
+
Recommended default token construction:
|
| 52 |
+
|
| 53 |
+
```text
|
| 54 |
+
IV features: [B, 3, T_feat, F]
|
| 55 |
+
frequency pooling: pool F into 8 or 16 mel bands -> [B, 3, T_feat, F_band]
|
| 56 |
+
temporal pooling: average every 40 feature frames -> [B, T_spat, 3 * F_band]
|
| 57 |
+
optional window statistics: concat mean/std/max over each 0.4 s window
|
| 58 |
+
token MLP: 3 * F_band * N_stats -> D_token, where D_token matches the current spatial token dim
|
| 59 |
+
projector: reuse the existing spatial projector into Qwen hidden size
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
For 20 s clips this gives:
|
| 63 |
+
|
| 64 |
+
```text
|
| 65 |
+
T_feat=2000
|
| 66 |
+
T_spat=ceil(2000 / 40)=50
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
This is a valid low-capacity baseline. It gives the LLM explicit FOA direction
|
| 70 |
+
cues without using the trained SELD233 temporal encoder.
|
| 71 |
+
|
| 72 |
+
Suggested IV variants:
|
| 73 |
+
|
| 74 |
+
- `iv_3d`: mean over all frequency bins, then temporal pool to 2.5 Hz. Use this
|
| 75 |
+
only as a very weak lower bound.
|
| 76 |
+
- `iv_band8`: pool the 128 mel bins into 8 bands, then temporal pool to 2.5 Hz.
|
| 77 |
+
This is the recommended first baseline.
|
| 78 |
+
- `iv_band16`: pool into 16 bands. Use this if `iv_band8` is too weak.
|
| 79 |
+
- `iv_band8_stats`: pool into 8 bands and concatenate mean/std over the 0.4 s
|
| 80 |
+
temporal window. Use this if source activity changes inside the window matter.
|
| 81 |
+
|
| 82 |
+
Important controls:
|
| 83 |
+
|
| 84 |
+
- Normalize IV features with the same frontend normalization when possible.
|
| 85 |
+
- Verify FOA axis convention before interpreting azimuth/elevation results.
|
| 86 |
+
- Keep the IV MLP small, otherwise it stops being a "simple feature" baseline.
|
| 87 |
+
- Report parameter count separately from the main SELD233 spatial branch.
|
| 88 |
+
- Report `iv_3d` separately from band-preserving IV. They answer different
|
| 89 |
+
questions: `iv_3d` tests whether almost no spatial detail is enough; band IV
|
| 90 |
+
tests whether simple spatial features are enough.
|
| 91 |
+
|
| 92 |
+
## Baseline B: CNN Neural IV Tokens
|
| 93 |
+
|
| 94 |
+
Train a small CNN to convert audio-derived spatial features into token vectors.
|
| 95 |
+
|
| 96 |
+
Recommended input:
|
| 97 |
+
|
| 98 |
+
```text
|
| 99 |
+
FOA feature tensor [B, 7, T_feat, F]
|
| 100 |
+
or IV-only tensor [B, 3, T_feat, F]
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
Recommended architecture:
|
| 104 |
+
|
| 105 |
+
```text
|
| 106 |
+
2D CNN over time-frequency
|
| 107 |
+
temporal downsampling to 2.5 Hz
|
| 108 |
+
MLP projection to D_token
|
| 109 |
+
existing spatial projector to Qwen hidden size
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
The CNN should be deliberately small. A reasonable first version is:
|
| 113 |
+
|
| 114 |
+
```text
|
| 115 |
+
Conv2d(C_in -> 32, kernel=3, padding=1)
|
| 116 |
+
GELU
|
| 117 |
+
Conv2d(32 -> 64, kernel=3, stride=(4, 2), padding=1)
|
| 118 |
+
GELU
|
| 119 |
+
frequency pooling
|
| 120 |
+
temporal pooling/resampling to T_spat
|
| 121 |
+
MLP(64 -> D_token)
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
This baseline answers a different question from raw IV:
|
| 125 |
+
|
| 126 |
+
```text
|
| 127 |
+
Can a shallow trainable spatial frontend learn enough for QA without the
|
| 128 |
+
pretrained SELD233 backbone?
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
To avoid making this an unfair hidden strong encoder, keep the CNN shallow and
|
| 132 |
+
train it only under the same QA supervision used by the other spatial QA runs.
|
| 133 |
+
|
| 134 |
+
## Required Negative Controls
|
| 135 |
+
|
| 136 |
+
These controls are needed to interpret the baseline results.
|
| 137 |
+
|
| 138 |
+
- `audio_only`: base Qwen with no spatial tokens.
|
| 139 |
+
- `zero_spatial`: keep `<|spatial|>` placeholders but feed zero vectors.
|
| 140 |
+
- `shuffled_spatial`: feed valid spatial tokens from another sample in the batch
|
| 141 |
+
or from another file with the same length.
|
| 142 |
+
- `iv_shuffled`: same as raw IV baseline, but shuffle IV tokens across samples.
|
| 143 |
+
|
| 144 |
+
If `zero_spatial` or `shuffled_spatial` performs close to the real spatial
|
| 145 |
+
baseline, the model is mostly exploiting prompt/answer priors rather than the
|
| 146 |
+
spatial tokens.
|
| 147 |
+
|
| 148 |
+
## Optional Upper Bounds
|
| 149 |
+
|
| 150 |
+
These are not required for the first baseline pass, but they are useful if the
|
| 151 |
+
results remain ambiguous.
|
| 152 |
+
|
| 153 |
+
- `oracle_angle_bin`: feed label-derived angle-bin IDs as tokens. This estimates
|
| 154 |
+
whether the LLM can use perfect discrete spatial information.
|
| 155 |
+
- `oracle_active_time`: feed label-derived active-time bins. This estimates
|
| 156 |
+
the ceiling for the simplified v4 time questions.
|
| 157 |
+
- `direct_probe`: train a small classifier on frozen spatial tokens for
|
| 158 |
+
azimuth/elevation bin and active-at-time tasks. This separates encoder quality
|
| 159 |
+
from LLM generation quality.
|
| 160 |
+
|
| 161 |
+
## Training Matrix
|
| 162 |
+
|
| 163 |
+
Run all baselines on `qa_pairs_v4` first. It avoids direct continuous angle and
|
| 164 |
+
time regression, which was too brittle for causal LM text generation.
|
| 165 |
+
|
| 166 |
+
Recommended first-pass matrix:
|
| 167 |
+
|
| 168 |
+
```text
|
| 169 |
+
audio_only
|
| 170 |
+
zero_spatial
|
| 171 |
+
shuffled_spatial
|
| 172 |
+
iv_tokens
|
| 173 |
+
iv_tokens + shuffled control
|
| 174 |
+
cnn_neural_iv
|
| 175 |
+
SELD233 stage3 model
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
Use the same QA data, LoRA target modules, learning rate range, and checkpoint
|
| 179 |
+
selection rule where possible. For spatial-token baselines, start with:
|
| 180 |
+
|
| 181 |
+
```text
|
| 182 |
+
train adapter/token frontend + projector + LLM LoRA
|
| 183 |
+
freeze Qwen base weights
|
| 184 |
+
freeze or omit SELD233 backbone
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
If the raw IV baseline is competitive with the full SELD233 branch, the current
|
| 188 |
+
model may not be using the SELD233 temporal encoder effectively. If the CNN
|
| 189 |
+
baseline is competitive but raw IV is not, then a lightweight trainable frontend
|
| 190 |
+
may be enough for the QA task. If all simple baselines fail but SELD233 improves,
|
| 191 |
+
the pretrained SELD encoder is adding useful structure.
|
| 192 |
+
|
| 193 |
+
## Metrics
|
| 194 |
+
|
| 195 |
+
For `qa_pairs_v4`, report metrics by task and question class.
|
| 196 |
+
|
| 197 |
+
Core metrics:
|
| 198 |
+
|
| 199 |
+
```text
|
| 200 |
+
azimuth bin choice accuracy
|
| 201 |
+
elevation bin choice accuracy
|
| 202 |
+
active-at-time yes/no accuracy
|
| 203 |
+
active-at-time balanced accuracy
|
| 204 |
+
time-bin choice accuracy
|
| 205 |
+
distance tolerance accuracy
|
| 206 |
+
count accuracy
|
| 207 |
+
source identification accuracy
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
Do not rely only on overall exact match. For yes/no and multiple-choice tasks,
|
| 211 |
+
also compare against the class-prior baseline and random baseline:
|
| 212 |
+
|
| 213 |
+
```text
|
| 214 |
+
yes/no random baseline: 50%
|
| 215 |
+
4-way choice random baseline: 25%
|
| 216 |
+
class-prior baseline: majority label accuracy in the test split
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
## Implementation Notes
|
| 220 |
+
|
| 221 |
+
The clean implementation point is to add a pluggable spatial-token source before
|
| 222 |
+
the existing projector path:
|
| 223 |
+
|
| 224 |
+
```text
|
| 225 |
+
--spatial-token-source seld233 | iv | cnn_iv | zero | shuffled
|
| 226 |
+
```
|
| 227 |
+
|
| 228 |
+
All token sources should return:
|
| 229 |
+
|
| 230 |
+
```text
|
| 231 |
+
spatial_tokens: [B, T_spat, D_token]
|
| 232 |
+
spatial_token_lengths: [B]
|
| 233 |
+
```
|
| 234 |
+
|
| 235 |
+
That keeps the existing tokenizer, placeholder expansion, RoPE modal order, and
|
| 236 |
+
Qwen spatial injection path unchanged.
|
| 237 |
+
|
| 238 |
+
Precomputing token caches is acceptable and probably preferable for the first
|
| 239 |
+
baseline pass:
|
| 240 |
+
|
| 241 |
+
```text
|
| 242 |
+
precompute_iv_spatial_tokens.py
|
| 243 |
+
precompute_cnn_iv_spatial_tokens.py
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
The training script can then load these as `spatial_tokens` directly, bypassing
|
| 247 |
+
the SELD233 backbone while preserving the same LLM-side path.
|
| 248 |
+
|
| 249 |
+
## Main Risks
|
| 250 |
+
|
| 251 |
+
- Raw IV tokens may encode direction but not source identity. Source-specific
|
| 252 |
+
questions still require the audio branch and LLM to select the right event.
|
| 253 |
+
- CNN Neural IV can become a strong encoder if it is too wide or too deep.
|
| 254 |
+
- Choice QA can overestimate spatial reasoning if distractors are weak. Use the
|
| 255 |
+
v4 distractor design and keep the negative controls.
|
| 256 |
+
- Active-at-time QA must be balanced; otherwise a majority-class yes/no model can
|
| 257 |
+
look good without using spatial or temporal evidence.
|
docs/paper_outline.md
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Spatial-Qwen: Paper Outline (NeurIPS 2025)
|
| 2 |
+
|
| 3 |
+
> **Working Title**: Spatial-Qwen: Enhancing Large Audio-Language Models with SELD-Pretrained Spatial Encoders for Spatial Audio Understanding
|
| 4 |
+
>
|
| 5 |
+
> **Core Claim**: Injecting a SELD-pretrained spatial encoder as an independent spatial token modality into Qwen2.5-Omni significantly improves spatial audio QA.
|
| 6 |
+
>
|
| 7 |
+
> **Data Policy**: Primary experiments use real data only (STARSS23). Simulated data excluded from main results due to real-sim domain gap; discussed in limitations.
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
## KEY BACKGROUND: Closest Existing Work - SPUR (arXiv 2511.06606)
|
| 13 |
+
|
| 14 |
+
A very similar paper already exists (UMD + Dolby). MUST cite and differentiate in Related Work:
|
| 15 |
+
|
| 16 |
+
- **Method**: FOA -> Banded Covariance (SSCV) -> Conv3D -> Transformer -> MLP -> injected into LALM audio encoder branch
|
| 17 |
+
- **Benchmark SPUR-Set**: 6 spatial reasoning skills, 12K QA pairs, primarily synthetic data
|
| 18 |
+
- **Results**: Qwen-2.5-Omni w/ SPUR avg=7.38/10; GPT-4o avg=4.50; BAT avg=2.48
|
| 19 |
+
|
| 20 |
+
**Key differences from our work**:
|
| 21 |
+
|
| 22 |
+
| Dimension | SPUR | Spatial-Qwen (ours) |
|
| 23 |
+
|-----------|------|---------------------|
|
| 24 |
+
| Spatial encoder | SSCV covariance + Conv3D (scratch) | SELD-pretrained encoder (task-aligned) |
|
| 25 |
+
| Injection method | Into audio encoder branch (mixed with semantics) | Independent spatial modality (separated) |
|
| 26 |
+
| Training data | Mostly synthetic + some real | All real STARSS23 recordings |
|
| 27 |
+
| QA scale | 12K QA, 6 task types | ~178K QA, 12 task types (larger, finer) |
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## Existing Experimental Numbers
|
| 32 |
+
|
| 33 |
+
| System | Real Test F | AngE | SELD Score |
|
| 34 |
+
|--------|------------|------|-----------|
|
| 35 |
+
| DCASE baseline (not finetuned) | ~0.35 | ~24 deg | ~0.44 |
|
| 36 |
+
| Task 235 (real only, finetuned) | 0.3705 | 23.6 deg | 0.4562 |
|
| 37 |
+
|
| 38 |
+
Spatial-BEATs (ov1_local_spatial, valid set):
|
| 39 |
+
- class_acc=39.85%, azi_mae=23.52 deg, ele_mae=9.65 deg, dist_mae=0.475
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## 1. Abstract (~250 words)
|
| 44 |
+
|
| 45 |
+
**P1 - Problem**: Sound is 3D. Real-world auditory scenes contain multiple sources from different directions and distances. Existing LALMs process mono/stereo input, cannot perceive spatial information (azimuth, elevation, distance), and perform near-random on spatial audio understanding tasks.
|
| 46 |
+
|
| 47 |
+
**P2 - Method**: We propose Spatial-Qwen, injecting a SELD-pretrained spatial encoder as an independent spatial token modality into Qwen2.5-Omni, giving the LALM spatial awareness. We also propose SpatialAudioQA - the first large-scale spatial reasoning benchmark based on real FOA recordings (12 task types, ~178K QA pairs).
|
| 48 |
+
|
| 49 |
+
**P3 - Results**: (fill in after experiments) Comparison vs audio-only baseline; ablation validates spatial token effectiveness.
|
| 50 |
+
|
| 51 |
+
**P4 - Significance**: Spatial-Qwen bridges the gap between the SELD community (precise localization) and the LALM community (natural language understanding), opening new directions for spatial audio understanding.
|
| 52 |
+
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## 2. Introduction (~1 page)
|
| 56 |
+
|
| 57 |
+
### 2.1 Opening: Spatial perception is core to auditory intelligence
|
| 58 |
+
|
| 59 |
+
- Human binaural system naturally localizes sound sources (azimuth, elevation, distance) for navigation, communication, safety
|
| 60 |
+
- FOA (First-Order Ambisonics) is the standard format for capturing 3D soundfields, used by DCASE, VR/AR, robotics
|
| 61 |
+
- Applications: robot sound source tracking, AR/VR immersive audio navigation, hearing aids, autonomous driving
|
| 62 |
+
|
| 63 |
+
### 2.2 The gap between two communities
|
| 64 |
+
|
| 65 |
+
**Left side - SELD community has localization but no reasoning**:
|
| 66 |
+
- SELDNet, Spatial-AST etc. precisely output azimuth/elevation/distance coordinates
|
| 67 |
+
- But output is structured coordinates, cannot answer natural language questions:
|
| 68 |
+
- "Is there someone approaching from my left?"
|
| 69 |
+
- "Which sound is closest to me?"
|
| 70 |
+
- "How many sources are active between 5-10 seconds?"
|
| 71 |
+
|
| 72 |
+
**Right side - LALM community can reason but is spatially blind**:
|
| 73 |
+
- Qwen2-Audio, SALMONN, LTU etc. are strong at semantic understanding but process mono/stereo, discarding spatial cues
|
| 74 |
+
- Near-random on spatial questions (SPUR paper: GPT-4o only 4.50/10)
|
| 75 |
+
- Existing benchmarks (MMAU, AIR-Bench, AudioBench) contain NO spatial reasoning tasks
|
| 76 |
+
|
| 77 |
+
### 2.3 Limitations of prior work
|
| 78 |
+
|
| 79 |
+
- **BAT** (ICML 2024): binaural signal + LLaMA-2, limited by HRTF, poor generalization
|
| 80 |
+
- **SPUR** (arXiv 2511.06606): similar goal but injects into audio encoder branch (mixes with semantics), primarily synthetic data, small scale (12K QA)
|
| 81 |
+
- **SpatialVLM/SpatialBot**: successful in vision domain but no audio equivalent
|
| 82 |
+
|
| 83 |
+
### 2.4 Our approach
|
| 84 |
+
|
| 85 |
+
- **Key insight**: SELD-pretrained encoder MHSA hidden states already encode rich temporal spatial information, ideal as spatial token source
|
| 86 |
+
- **Solution**: Dual-path parallel - W channel to original audio encoder; 4ch FOA to SELD encoder -> 2.5 Hz spatial tokens -> injected at spatial token positions in LLM
|
| 87 |
+
- **Design principle**: Spatial and semantic paths completely separate, no interference
|
| 88 |
+
|
| 89 |
+
### 2.5 Contributions
|
| 90 |
+
|
| 91 |
+
1. **Spatial-Qwen framework**: First method to inject SELD-pretrained spatial encoder as independent spatial token modality into LALM
|
| 92 |
+
2. **SpatialAudioQA Benchmark**: ~178K QA, 12 task types, all based on real FOA recordings (STARSS23)
|
| 93 |
+
3. **Systematic comparison**: DCASE SELD encoder vs. Spatial-BEATs comprehensive encoder comparison
|
| 94 |
+
4. **Ablation study**: Rigorous validation of spatial token effectiveness (audio-only / zero-spatial / shuffled-spatial), and impact on general audio understanding (MMAU)
|
| 95 |
+
5. **Open source**: Code, benchmark data, pretrained weights
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
|
| 99 |
+
## 3. Related Work (~1 page)
|
| 100 |
+
|
| 101 |
+
### 3.1 Large Audio Language Models (LALMs)
|
| 102 |
+
|
| 103 |
+
| Paper | Year/Venue | Key Contribution | Relation to Our Work |
|
| 104 |
+
|-------|-----------|-----------------|---------------------|
|
| 105 |
+
| AudioPaLM | 2023 arXiv | PaLM-2 + AudioLM tokens | Pioneer audio LLM |
|
| 106 |
+
| Pengi | NeurIPS 2023 | CLAP + GPT-2 unified generation | audio-text baseline |
|
| 107 |
+
| LTU | ICLR 2024 | OpenAQA 1.9M QA | QA generation reference |
|
| 108 |
+
| SALMONN | ICLR 2024 | Dual encoder (Whisper+BEATs)->Q-Former->LLM | Most related architecture |
|
| 109 |
+
| Qwen2-Audio | 2024 arXiv | 7B multi-task | Our base model predecessor |
|
| 110 |
+
| Qwen2.5-Omni | 2025 arXiv | Full multimodal, TMRoPE | Our direct base model |
|
| 111 |
+
| WavLLM | EMNLP 2024 | Dual encoder + LoRA routing | Related dual-path design |
|
| 112 |
+
| Audio Flamingo 3 | Interspeech 2024 | Few-shot, in-context learning | SPUR paper base model |
|
| 113 |
+
| BAT | ICML 2024 | Binaural + LLaMA-2, spatial QA | Most direct prior work |
|
| 114 |
+
|
| 115 |
+
Core argument: All above methods lack FOA spatial awareness. Our paper fills this gap.
|
| 116 |
+
|
| 117 |
+
### 3.2 Audio QA Benchmarks
|
| 118 |
+
|
| 119 |
+
| Paper | Year/Venue | Coverage | Missing |
|
| 120 |
+
|-------|-----------|---------|-------|
|
| 121 |
+
| MMAU | NeurIPS 2024 | 27 audio reasoning types, 10K questions | No spatial localization tasks |
|
| 122 |
+
| AIR-Bench | ACL 2024 | Audio instruction following, 20 types | No spatial tasks |
|
| 123 |
+
| AudioBench | 2024 | 26 dataset universal eval | No spatial tasks |
|
| 124 |
+
| Dynamic-SUPERB | ICASSP 2024 | 55-task collaborative benchmark | No spatial tasks |
|
| 125 |
+
| SPUR-Set | 2024 arXiv | 6 spatial reasoning skills, 12K QA | Mostly synthetic, small scale |
|
| 126 |
+
|
| 127 |
+
Core argument: SpatialAudioQA is the first real-FOA-based, large-scale (~178K), multi-task spatial audio reasoning benchmark.
|
| 128 |
+
|
| 129 |
+
### 3.3 Sound Event Localization and Detection (SELD)
|
| 130 |
+
|
| 131 |
+
| Paper | Year/Venue | Key Contribution |
|
| 132 |
+
|-------|-----------|----------------|
|
| 133 |
+
| SELDNet | JSTSP 2019 | CRNN jointly SED+DOA, foundational |
|
| 134 |
+
| ACCDOA | ICASSP 2021 | Activity-Coupled Cartesian DOA |
|
| 135 |
+
| Multi-ACCDOA | ICASSP 2022 | ADPIT loss, 3-track multi-source (directly used) |
|
| 136 |
+
| STARSS23 | NeurIPS 2023 D&B | Real-scene FOA + 3D annotations (our dataset) |
|
| 137 |
+
| DCASE 2024 Task 3 | DCASE 2024 | Added distance estimation (our encoder source) |
|
| 138 |
+
| Spatial-AST | ICASSP 2023 | ViT for SELD |
|
| 139 |
+
| ELSA | 2024 | FOA-text contrastive learning |
|
| 140 |
+
|
| 141 |
+
Core argument: SELD produces precise coordinates but cannot answer natural language. Our work converts SELD encoder hidden states to LLM spatial tokens, bridging the two communities.
|
| 142 |
+
|
| 143 |
+
### 3.4 Spatial Understanding in Multimodal LLMs
|
| 144 |
+
|
| 145 |
+
| Paper | Year/Venue | Key Contribution |
|
| 146 |
+
|-------|-----------|----------------|
|
| 147 |
+
| SpatialVLM | CVPR 2024 | Visual spatial QA, most architecturally similar |
|
| 148 |
+
| SpatialBot | 2024 | RGB-D encoder + LLM spatial reasoning |
|
| 149 |
+
| SpatialRGPT | NeurIPS 2024 | Spatial region tokens + VLM depth QA |
|
| 150 |
+
| 3D-VisTA | ICCV 2023 | 3D point cloud + text alignment, spatial QA |
|
| 151 |
+
| SPUR | 2024 arXiv | FOA + covariance + Conv3D -> LALM (closest prior) |
|
| 152 |
+
|
| 153 |
+
Core argument: Visual spatial token injection proven effective (SpatialVLM). Our work extends this paradigm to acoustic spatial domain.
|
| 154 |
+
|
| 155 |
+
---
|
| 156 |
+
|
| 157 |
+
## 4. Method (~2 pages)
|
| 158 |
+
|
| 159 |
+
### 4.1 System Overview
|
| 160 |
+
|
| 161 |
+
MUST include architecture figure (Fig. 1)
|
| 162 |
+
|
| 163 |
+
Architecture: Dual-path FOA input. Path A: W-channel mono -> Qwen Audio Encoder (~25Hz) -> Audio Tokens via AUDIO placeholder. Path B: 4ch FOA -> Spatial Encoder (DCASE/BEATs) -> Spatial Tokens [B,50,D_llm] via spatial placeholder. Both injected into Qwen2.5-Omni Thinker LLM.
|
| 164 |
+
|
| 165 |
+
Content to write:
|
| 166 |
+
- Formalization: given FOA waveform x in R^{T x 4} + question q, output text answer a
|
| 167 |
+
- Dual-path parallel: Path A preserves original audio encoder; Path B adds independent spatial path
|
| 168 |
+
- Token injection: tokenizer expands spatial placeholder to T_spat tokens, thinker forward uses masked_scatter
|
| 169 |
+
|
| 170 |
+
### 4.2 SpatialAudioQA Benchmark
|
| 171 |
+
|
| 172 |
+
#### 4.2.1 Data Source
|
| 173 |
+
|
| 174 |
+
- Base data: STARSS23 real-scene FOA recordings (Sony + Tampere University)
|
| 175 |
+
- Coverage: home, office, public indoor spaces
|
| 176 |
+
- Annotations: per-frame azimuth/elevation/distance + 29 sound classes
|
| 177 |
+
- Segmentation: 20s sliding window, event-aware sampling, scene-based train/val/test split
|
| 178 |
+
|
| 179 |
+
#### 4.2.2 QA Generation Strategy (v6c)
|
| 180 |
+
|
| 181 |
+
12 task types (Table 3):
|
| 182 |
+
|
| 183 |
+
| Task | Description | Answer Format | Example |
|
| 184 |
+
|------|-------------|--------------|-------|
|
| 185 |
+
| identify_source_by_location | Identify source given direction | 4-way MC | "What sound is to your left front?" |
|
| 186 |
+
| estimate_azimuth_bin | Estimate azimuth bin | 4-way MC | "In which direction is the speech?" |
|
| 187 |
+
| estimate_elevation_bin | Estimate elevation | 4-way MC | "Is the footstep above or below you?" |
|
| 188 |
+
| estimate_distance | Estimate distance | numeric (meters) | "How far is the speaker?" |
|
| 189 |
+
| detect_source_active_at_time | Activity at given time | yes/no | "Is music playing at t=5s?" |
|
| 190 |
+
| count_sources | Number of active sources | integer | "How many sounds active at t=8s?" |
|
| 191 |
+
| detect_motion | Is source moving | yes/no | "Is the footstep source moving?" |
|
| 192 |
+
| classify_event_time_bin | Active time period | 4-way MC | "When is the door knock?" |
|
| 193 |
+
| classify_motion | Describe movement | short text | "Describe the movement of the speech source." |
|
| 194 |
+
| compare_azimuth | Compare two source directions | MC | "Is the phone left or right of the speech?" |
|
| 195 |
+
| compare_elevation | Compare two source elevations | MC | "Which sound is higher: A or B?" |
|
| 196 |
+
| compare_distance | Compare two source distances | MC | "Is music closer or farther than speech?" |
|
| 197 |
+
|
| 198 |
+
Total: ~178K QA pairs across all task types.
|
| 199 |
+
|
| 200 |
+
### 4.3 Spatial Encoders
|
| 201 |
+
|
| 202 |
+
#### 4.3.1 DCASE SELD Encoder (Task 235)
|
| 203 |
+
|
| 204 |
+
Architecture:
|
| 205 |
+
- Backbone: CNN -> bidirectional GRU -> Multi-Head Self-Attention (MHSA) -> FNN output heads
|
| 206 |
+
- Input: FOA 7-channel features [B, 7, T_feat, 128] (4ch log-mel + 3ch intensity vectors)
|
| 207 |
+
- Pretrained: DCASE 2024 Task 3, Multi-ACCDOA + ADPIT loss, STARSS23 real data
|
| 208 |
+
- Spatial token source: final MHSA hidden states [B, T_seld, 128] (NOT ACCDOA head)
|
| 209 |
+
|
| 210 |
+
Why MHSA hidden (not detection head):
|
| 211 |
+
- Scene-level, temporally ordered, dense representation
|
| 212 |
+
- Retains full class and spatial information, richer than ACCDOA 3D vectors
|
| 213 |
+
- Better suited as LLM conditioning signal
|
| 214 |
+
|
| 215 |
+
Spatial Adapter: 10 Hz -> 2.5 Hz grouped mean pooling (factor=4); LayerNorm -> Linear(128->256) -> GELU -> Linear(256->256); output [B, T_spat, 256], max 50 tokens for 20s
|
| 216 |
+
|
| 217 |
+
Projector: MLP: LayerNorm -> Linear(256->512) -> GELU -> Linear(512->4096)
|
| 218 |
+
|
| 219 |
+
#### 4.3.2 Spatial-BEATs Encoder (ov1_local_spatial)
|
| 220 |
+
|
| 221 |
+
Architecture: FOA [B,4,T] -> foa_feat [B,7,T_f,128]; W-channel BEATs patch embedding + 7ch SpatialDeltaPatchAdapter -> BEATs trunk -> frequency_pool -> TemporalResampler (2.5Hz) -> semantic_embeddings [B,T_s,768]; LocalSpatialEncoder -> fused_embeddings = LayerNorm(semantic+local) [B,T_s,768]
|
| 222 |
+
|
| 223 |
+
LLM Bridge: LayerNorm -> 1-layer TransformerEncoder -> Linear(768->1536) -> GELU -> Linear(1536->4096) -> llm_spatial_tokens [B,T_s,4096]
|
| 224 |
+
|
| 225 |
+
| Property | DCASE SELD | Spatial-BEATs |
|
| 226 |
+
|----------|-----------|---------------|
|
| 227 |
+
| Backbone | CRNN + MHSA | BEATs Transformer |
|
| 228 |
+
| Pretraining objective | SELD Multi-ACCDOA | DOA/distance/classification |
|
| 229 |
+
| Pretraining data | STARSS23 (real) | Simulated FOA |
|
| 230 |
+
| Token source | MHSA hidden [B,T,128] | fused_embeddings [B,T,768] |
|
| 231 |
+
| Token dimension | 128->256->4096 | 768->1536->4096 |
|
| 232 |
+
| Token rate | 2.5 Hz | 2.5 Hz |
|
| 233 |
+
| Parameters | ~5M | ~90M |
|
| 234 |
+
|
| 235 |
+
### 4.4 Token Injection Mechanism
|
| 236 |
+
|
| 237 |
+
- Qwen2_5OmniSpatialProcessor: expands spatial token placeholder to T_spat tokens in prompt
|
| 238 |
+
- Thinker _resolve_spatial_tokens() -> projector -> masked_scatter to replace embeddings
|
| 239 |
+
- RoPE: spatial tokens encoded with TMRoPE in [text, audio, spatial] order
|
| 240 |
+
- Inference: inject only during prefill, not repeated during decode
|
| 241 |
+
|
| 242 |
+
### 4.5 Training
|
| 243 |
+
|
| 244 |
+
Three-stage training strategy:
|
| 245 |
+
|
| 246 |
+
| Stage | Frozen | Trainable | Purpose |
|
| 247 |
+
|-------|--------|-----------|-------|
|
| 248 |
+
| Stage 1: spatial_only | SELD encoder + LLM | Adapter + Projector | Establish mapping |
|
| 249 |
+
| Stage 2: adapter_lora | SELD encoder | Adapter + Projector + LoRA | QA fine-tuning (main experiment) |
|
| 250 |
+
| Stage 3: spatial_lora | nothing | SELD tail + Adapter + Projector + LoRA | Joint optimization |
|
| 251 |
+
|
| 252 |
+
Training config: SpatialAudioQA v6c train set; LoRA rank=8 alpha=16; AdamW lr=3e-5 cosine+5% warmup; batch=1/GPU grad_accum=8 (effective 64); audio=20s 16kHz FOA 4ch
|
| 253 |
+
|
| 254 |
+
---
|
| 255 |
+
|
| 256 |
+
## 5. Evaluation Metrics
|
| 257 |
+
|
| 258 |
+
### 5.1 Spatial QA Metrics
|
| 259 |
+
|
| 260 |
+
| Task type | Main metric | Notes |
|
| 261 |
+
|-----------|------------|------|
|
| 262 |
+
| Multiple-choice | Accuracy | vs. random baseline 25% |
|
| 263 |
+
| Yes/No | Balanced Accuracy | prevent class imbalance |
|
| 264 |
+
| Distance estimation | MAE (m) + Tolerance Acc (within 0.5m) | |
|
| 265 |
+
| Counting | Accuracy | exact integer match |
|
| 266 |
+
| Motion detection | F1 | |
|
| 267 |
+
| Overall | Weighted Avg Accuracy | |
|
| 268 |
+
| SRS | Acc minus shuffled_Acc | pure spatial reasoning excluding text priors |
|
| 269 |
+
|
| 270 |
+
### 5.2 SELD Encoder Quality (appendix or section 4.3)
|
| 271 |
+
|
| 272 |
+
- F-score (20 deg tolerance), AngE, SELD Error (composite), ER20
|
| 273 |
+
|
| 274 |
+
### 5.3 MMAU Regression Test
|
| 275 |
+
|
| 276 |
+
Validate that adding spatial encoder does not hurt general audio understanding. Report MMAU Overall Score.
|
| 277 |
+
|
| 278 |
+
---
|
| 279 |
+
|
| 280 |
+
## 6. Results (~1.5 pages)
|
| 281 |
+
|
| 282 |
+
### 6.1 Main QA Results (Table 1)
|
| 283 |
+
|
| 284 |
+
| System | Spatial Encoder | Azi Acc | Ele Acc | Dist MAE | Active@T BAcc | Count Acc | Overall | SRS |
|
| 285 |
+
|--------|----------------|---------|---------|----------|--------------|-----------|---------|-----|
|
| 286 |
+
| Qwen2.5-Omni (audio-only) | None | ~25% | ~25% | - | ~50% | - | - | 0 |
|
| 287 |
+
| + Zero Spatial | zeros | ~25% | ~25% | - | ~50% | - | - | ~0 |
|
| 288 |
+
| + Shuffled Spatial | DCASE (shuffled) | ~25% | ~25% | - | ~50% | - | - | ~0 |
|
| 289 |
+
| + DCASE Encoder S2 (Ours) | DCASE Task 235 | XX% | XX% | X.Xm | XX% | XX% | XX% | +XX% |
|
| 290 |
+
| + DCASE Encoder S3 | DCASE Task 235 | XX% | XX% | X.Xm | XX% | XX% | XX% | +XX% |
|
| 291 |
+
| + Spatial-BEATs | Spatial-BEATs | XX% | XX% | X.Xm | XX% | XX% | XX% | +XX% |
|
| 292 |
+
|
| 293 |
+
(Experimental numbers to be filled in)
|
| 294 |
+
|
| 295 |
+
Key arguments:
|
| 296 |
+
1. audio-only ~= random -> LLM has no spatial awareness
|
| 297 |
+
2. zero/shuffled ~= random -> improvement comes from spatial token information, not text priors
|
| 298 |
+
3. DCASE encoder significantly improves -> SELD pretraining transfers effectively to QA
|
| 299 |
+
|
| 300 |
+
### 6.2 Ablation Studies (Table 2)
|
| 301 |
+
|
| 302 |
+
**Ablation A: Spatial Token Validity (essential)**
|
| 303 |
+
|
| 304 |
+
| Variant | Overall Acc | SRS |
|
| 305 |
+
|---------|------------|-----|
|
| 306 |
+
| audio_only | ~random | 0 |
|
| 307 |
+
| zero_spatial | ~random | ~0 |
|
| 308 |
+
| shuffled_spatial | ~random | ~0 |
|
| 309 |
+
| iv_band8 (raw IV tokens) | ? | ? |
|
| 310 |
+
| cnn_iv (lightweight CNN) | ? | ? |
|
| 311 |
+
| DCASE Encoder S2 (Ours) | best | +XX% |
|
| 312 |
+
|
| 313 |
+
**Ablation B: Encoder Comparison**
|
| 314 |
+
|
| 315 |
+
| Encoder | Params | QA Overall | SELD F | AngE |
|
| 316 |
+
|---------|--------|------------|--------|------|
|
| 317 |
+
| Raw IV tokens | ~0.5M | - | N/A | N/A |
|
| 318 |
+
| CNN-IV | ~2M | - | N/A | N/A |
|
| 319 |
+
| DCASE SELD (frozen, S1) | ~5M | - | 0.37 | 23.6 deg |
|
| 320 |
+
| DCASE SELD (finetune S2) | ~5M | - | - | - |
|
| 321 |
+
| Spatial-BEATs (frozen) | ~90M | - | - | 23.5 deg |
|
| 322 |
+
|
| 323 |
+
**Ablation C: MMAU Regression** - proves independent spatial path does not hurt general audio capability.
|
| 324 |
+
|
| 325 |
+
**Ablation D: Speed & Parameters** - DCASE ~5M params adds small overhead; Spatial-BEATs ~90M moderate.
|
| 326 |
+
|
| 327 |
+
### 6.3 QA Analysis (qualitative)
|
| 328 |
+
|
| 329 |
+
1. Task difficulty stratification: single-source (azimuth) vs. complex (multi-source comparison)
|
| 330 |
+
2. Error analysis: azimuth confusion during overlap; distance error histogram; accuracy by sound class
|
| 331 |
+
3. Success case examples (2-3 QA examples)
|
| 332 |
+
4. SRS analysis: pure spatial reasoning excluding text priors
|
| 333 |
+
|
| 334 |
+
---
|
| 335 |
+
|
| 336 |
+
## 7. Conclusion (~0.5 page)
|
| 337 |
+
|
| 338 |
+
**P1 - Summary**: Spatial-Qwen is the first framework to inject SELD-pretrained encoder as independent spatial token modality into LALM, significantly outperforming audio-only baseline on real FOA spatial QA without degrading general audio understanding.
|
| 339 |
+
|
| 340 |
+
**P2 - Benchmark contribution**: SpatialAudioQA provides the largest real-scene spatial audio reasoning benchmark to date, 12 task types ~178K QA.
|
| 341 |
+
|
| 342 |
+
**P3 - Limitations**: Simulated/real domain gap (log-mel mean shift ~0.4-0.5); evaluation limited to STARSS23 indoor scenes; Spatial-BEATs sim pretraining quality.
|
| 343 |
+
|
| 344 |
+
**P4 - Future work**: Improve sim data quality; extend to outdoor/dynamic scenes; spatial reasoning in multi-turn dialogue.
|
| 345 |
+
|
| 346 |
+
---
|
| 347 |
+
|
| 348 |
+
## 8. Broader Impacts (NeurIPS required section)
|
| 349 |
+
|
| 350 |
+
Positive impacts: hearing-impaired assistive technology; VR/AR immersive experience; robot sound source navigation
|
| 351 |
+
|
| 352 |
+
Potential risks: Spatial audio surveillance (privacy concerns); validated only on STARSS23 distribution.
|
| 353 |
+
|
| 354 |
+
---
|
| 355 |
+
|
| 356 |
+
## 9. Figure and Table Plan
|
| 357 |
+
|
| 358 |
+
| # | Type | Content | Location |
|
| 359 |
+
|---|------|---------|--------|
|
| 360 |
+
| Fig. 1 | Architecture | Dual-path FOA -> dual encoder -> LLM injection | Section 4.1 |
|
| 361 |
+
| Fig. 2 | Data | SpatialAudioQA task distribution + example QA | Section 4.2 |
|
| 362 |
+
| Fig. 3 | Ablation | audio-only/zero/shuffled/ours bar chart | Section 6.2 |
|
| 363 |
+
| Fig. 4 | Analysis | Per-task accuracy radar + error distribution | Section 6.3 |
|
| 364 |
+
| Table 1 | Main results | All systems, all QA tasks | Section 6.1 |
|
| 365 |
+
| Table 2 | Ablation | Encoder comparison + token validity | Section 6.2 |
|
| 366 |
+
| Table 3 | Dataset stats | SpatialAudioQA 12 task distribution | Section 4.2 |
|
| 367 |
+
| Table 4 | Encoder comparison | DCASE vs. BEATs architecture comparison | Section 4.3 |
|
| 368 |
+
|
| 369 |
+
---
|
| 370 |
+
|
| 371 |
+
## 10. Reference List
|
| 372 |
+
|
| 373 |
+
### Must cite (by importance)
|
| 374 |
+
|
| 375 |
+
1. Qwen2.5-Omni Technical Report, Qwen Team, arXiv 2025 - our base model
|
| 376 |
+
2. SPUR, arXiv 2511.06606, UMD+Dolby 2024 - closest prior work, MUST cite and differentiate
|
| 377 |
+
3. STARSS23, Shimada & Politis et al., NeurIPS 2023 D&B, arXiv 2306.09196 - our dataset
|
| 378 |
+
4. Multi-ACCDOA, Shimada et al., ICASSP 2022 - DCASE encoder training paradigm
|
| 379 |
+
5. SELDNet, Adavanne et al., JSTSP 2019 - SELD foundation
|
| 380 |
+
6. ACCDOA, Shimada et al., ICASSP 2021 - encoder output representation
|
| 381 |
+
7. DCASE 2024 Task 3, Politis et al. - encoder pretraining task
|
| 382 |
+
8. BEATs, Chen et al., ICML 2023, arXiv 2212.09199 - Spatial-BEATs backbone
|
| 383 |
+
9. SALMONN, Tang et al., ICLR 2024, arXiv 2310.13289 - dual encoder LALM architecture
|
| 384 |
+
10. BAT, Zheng et al., ICML 2024, arXiv 2402.01591 - binaural spatial audio LLM
|
| 385 |
+
11. MMAU, Sakshi et al., NeurIPS 2024, arXiv 2406.09148 - benchmark comparison
|
| 386 |
+
12. SpatialVLM, Chen et al., CVPR 2024, arXiv 2406.13537 - visual spatial token paradigm
|
| 387 |
+
|
| 388 |
+
### Strongly recommended
|
| 389 |
+
|
| 390 |
+
13. Qwen2-Audio, Chu et al., arXiv 2407.10759, 2024
|
| 391 |
+
14. LTU, Gong et al., ICLR 2024, arXiv 2305.10790
|
| 392 |
+
15. Pengi, Deshmukh et al., NeurIPS 2023, arXiv 2305.11834
|
| 393 |
+
16. AIR-Bench, Yang et al., ACL 2024, arXiv 2402.07729
|
| 394 |
+
17. AudioPaLM, Rubenstein et al., arXiv 2306.12925, 2023
|
| 395 |
+
18. SpatialRGPT, Cheng et al., NeurIPS 2024
|
| 396 |
+
19. SpatialBot, Cai et al., arXiv 2024
|
| 397 |
+
20. Audio Flamingo 3, Kong et al., Interspeech 2024, arXiv 2402.01831
|
| 398 |
+
21. LoRA, Hu et al., ICLR 2022, arXiv 2106.09685
|
| 399 |
+
|
| 400 |
+
### Optional
|
| 401 |
+
|
| 402 |
+
22. WavLLM, Shao et al., EMNLP 2024, arXiv 2404.15708
|
| 403 |
+
23. Hearing Anything Anywhere, Ma et al., CVPR 2024, arXiv 2406.07532
|
| 404 |
+
24. Spatial-AST, Shao et al., ICASSP 2023, arXiv 2211.01246
|
| 405 |
+
25. 3D-VisTA, Zhu et al., ICCV 2023, arXiv 2308.04352
|
| 406 |
+
26. Dynamic-SUPERB, Huang et al., ICASSP 2024, arXiv 2309.09510
|
| 407 |
+
27. AudioBench, Wang et al., 2024, arXiv 2406.16020
|
| 408 |
+
|
| 409 |
+
---
|
| 410 |
+
|
| 411 |
+
## 11. NeurIPS 2025 Format Reminders
|
| 412 |
+
|
| 413 |
+
- Page limit: body <= 9 pages (including figures/tables), references excluded
|
| 414 |
+
- Format: use official neurips_2025.sty
|
| 415 |
+
- Anonymous: double-blind; no author info, affiliations, acknowledgments
|
| 416 |
+
- References: alphabetical order
|
| 417 |
+
- Must include Broader Impacts section
|
| 418 |
+
- Appendix: hyperparameters, training details, dataset details (no page limit)
|
| 419 |
+
|
| 420 |
+
---
|
| 421 |
+
|
| 422 |
+
## 12. Writing Strategy Notes
|
| 423 |
+
|
| 424 |
+
### Narrative thread
|
| 425 |
+
|
| 426 |
+
1. Spatial perception is core to auditory intelligence -> but ignored by LALM community
|
| 427 |
+
2. SELD has precise localization, LALM has language understanding -> the two do not connect
|
| 428 |
+
3. Solution: SELD encoder hidden states as spatial tokens -> bridge the two communities
|
| 429 |
+
4. SpatialAudioQA provides rigorous large-scale evaluation framework
|
| 430 |
+
5. Ablation rigorously proves: spatial tokens are working, not prompting bias
|
| 431 |
+
|
| 432 |
+
### Handling simulated data
|
| 433 |
+
|
| 434 |
+
- Main experiments use only real data (STARSS23)
|
| 435 |
+
- Appendix A.1 Domain Gap Analysis: simulated-real gap (log-mel mean shift ~0.4-0.5)
|
| 436 |
+
|
| 437 |
+
### Key experiments to run (priority order)
|
| 438 |
+
|
| 439 |
+
| Experiment | Priority | Est. time |
|
| 440 |
+
|------------|----------|----------|
|
| 441 |
+
| audio-only Qwen2.5-Omni on SpatialAudioQA | P0 | 1 day |
|
| 442 |
+
| zero-spatial / shuffled-spatial ablation | P0 | 0.5 day |
|
| 443 |
+
| DCASE encoder Stage 2 (adapter_lora) | P0 | 2-3 days |
|
| 444 |
+
| IV tokens baseline | P1 | 1 day |
|
| 445 |
+
| MMAU regression test | P1 | 0.5 day |
|
| 446 |
+
| DCASE encoder Stage 3 (spatial_lora) | P2 | 2 days |
|
| 447 |
+
| Spatial-BEATs Stage B | P2 | 2-3 days |
|
| 448 |
+
| CNN-IV baseline | P3 | 1 day |
|
| 449 |
+
|
| 450 |
+
---
|
| 451 |
+
|
| 452 |
+
Document version: v2.0, 2025-04-15
|
| 453 |
+
Sources: DCASE/spur-qwen/BEATs docs, SPUR paper arXiv 2511.06606, literature survey
|
docs/qa_training_smoke.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SELD233 QA Dataloader Smoke
|
| 2 |
+
|
| 3 |
+
## Purpose
|
| 4 |
+
Validate that QA `jsonl` records and 20-second FOA audio can be packed into the
|
| 5 |
+
new `audio + spatial + text` input format used by the SELD233 spatial branch.
|
| 6 |
+
|
| 7 |
+
The smoke script:
|
| 8 |
+
- loads `train.jsonl` and `valid.jsonl`
|
| 9 |
+
- reads FOA waveforms from `audio_path`
|
| 10 |
+
- builds prompts in the form `<|AUDIO|><|spatial|>\n{prompt}\n{answer}`
|
| 11 |
+
- creates `labels` that supervise answer tokens only
|
| 12 |
+
- prints batch tensor shapes and multimodal placeholder counts
|
| 13 |
+
- optionally loads the full Qwen model and runs one no-grad forward
|
| 14 |
+
|
| 15 |
+
## Script
|
| 16 |
+
- [train_seld233_qa_smoke.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni/training-qwen-omni/train_seld233_qa_smoke.py)
|
| 17 |
+
|
| 18 |
+
## Dataloader-Only Smoke
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
/data/home/schmittzhu/miniconda3/envs/spur/bin/python \
|
| 22 |
+
/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni/training-qwen-omni/train_seld233_qa_smoke.py \
|
| 23 |
+
--dataloader-only \
|
| 24 |
+
--max-train-samples 4 \
|
| 25 |
+
--max-valid-samples 2 \
|
| 26 |
+
--batch-size 2
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
Expected outputs include:
|
| 30 |
+
- `input_ids`
|
| 31 |
+
- `input_features`
|
| 32 |
+
- `spatial_audio`
|
| 33 |
+
- `labels`
|
| 34 |
+
- per-sample `audio_tokens`, `spatial_tokens`, and supervised answer token counts
|
| 35 |
+
|
| 36 |
+
## Full Forward Smoke
|
| 37 |
+
|
| 38 |
+
Run this on a GPU machine. CPU loading of the 7B model is possible but very
|
| 39 |
+
slow.
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
/data/home/schmittzhu/miniconda3/envs/spur/bin/python \
|
| 43 |
+
/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni/training-qwen-omni/train_seld233_qa_smoke.py \
|
| 44 |
+
--smoke-forward \
|
| 45 |
+
--max-train-samples 1 \
|
| 46 |
+
--max-valid-samples 1 \
|
| 47 |
+
--batch-size 1 \
|
| 48 |
+
--device cuda:0 \
|
| 49 |
+
--dtype bfloat16
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
If the forward succeeds, the script prints:
|
| 53 |
+
- `loss`
|
| 54 |
+
- `logits shape`
|
| 55 |
+
|
| 56 |
+
## Single-Step Training Smoke
|
| 57 |
+
|
| 58 |
+
Run this on a GPU machine if you want to verify that one backward pass and one
|
| 59 |
+
optimizer step complete successfully. This smoke test freezes the whole model
|
| 60 |
+
except the newly added spatial adapter and spatial projector.
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
/data/home/schmittzhu/miniconda3/envs/spur/bin/python \
|
| 64 |
+
/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni/training-qwen-omni/train_seld233_qa_smoke.py \
|
| 65 |
+
--smoke-backward \
|
| 66 |
+
--max-train-samples 1 \
|
| 67 |
+
--max-valid-samples 1 \
|
| 68 |
+
--batch-size 1 \
|
| 69 |
+
--device cuda:0 \
|
| 70 |
+
--dtype bfloat16
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
If the step succeeds, the script prints:
|
| 74 |
+
- `trainable_parameters`
|
| 75 |
+
- `loss`
|
| 76 |
+
- `gradient_norm_samples`
|
| 77 |
+
|
| 78 |
+
## Notes
|
| 79 |
+
- This QA loader currently expects 4-channel FOA audio only.
|
| 80 |
+
- It assumes 16 kHz audio and crops any longer clip to the first 20 seconds.
|
| 81 |
+
- The current QA dataset already points to 20-second prepared audio, so the
|
| 82 |
+
first batches should produce `500` audio tokens and `50` spatial tokens per
|
| 83 |
+
sample.
|
docs/qwen3_env.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Qwen3-Omni-MoE Environment Notes
|
| 2 |
+
|
| 3 |
+
## Conda env: `spur-qwen3` (cloned from `spur` on 2026-05-10)
|
| 4 |
+
|
| 5 |
+
```
|
| 6 |
+
python : 3.10.19
|
| 7 |
+
torch : 2.10.0+cu128 (CUDA 12.8)
|
| 8 |
+
torchaudio : 2.10.0
|
| 9 |
+
transformers: 5.0.0.dev0 (editable install from local fork)
|
| 10 |
+
huggingface_hub: 1.14.0
|
| 11 |
+
tokenizers : 0.22.2
|
| 12 |
+
peft : 0.18.1
|
| 13 |
+
deepspeed : 0.19.0
|
| 14 |
+
flash_attn : NOT installed (use sdpa attn_impl)
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
## Critical paths
|
| 18 |
+
|
| 19 |
+
- **transformers fork (live, editable)**:
|
| 20 |
+
`/apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers/`
|
| 21 |
+
Installed via `pip install -e .` in spur-qwen3. Both training & bench code import directly from this.
|
| 22 |
+
- **Snapshot of fork before any modifications**:
|
| 23 |
+
`/apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers.snapshot-pre-qwen3/`
|
| 24 |
+
- **Qwen3-Omni-30B-A3B-Instruct weights**:
|
| 25 |
+
`/apdcephfs_cq12/share_302080740/model/Qwen3-Omni-30B-A3B-Instruct/` (66 GB, 15 safetensors)
|
| 26 |
+
|
| 27 |
+
## Loading caveats (fork bugs we must work around)
|
| 28 |
+
|
| 29 |
+
1. **Top-level `Qwen3OmniMoeConfig.from_pretrained(MODEL)` crashes** on
|
| 30 |
+
`code_predictor_config.use_sliding_window` AttributeError (fork bug). Workaround:
|
| 31 |
+
parse `config.json` raw and instantiate `Qwen3OmniMoeThinkerConfig(**raw["thinker_config"])`
|
| 32 |
+
directly. We never need the talker, so this is fine.
|
| 33 |
+
2. **`AutoProcessor.from_pretrained` crashes** on missing video_processor mapping. Workaround:
|
| 34 |
+
load `AutoTokenizer` + `AutoFeatureExtractor` separately and assemble a
|
| 35 |
+
`Qwen3OmniMoeProcessor(image_processor=..., video_processor=None, feature_extractor=..., tokenizer=..., chat_template=...)`.
|
| 36 |
+
3. flash-attn not installed → use `attn_implementation="sdpa"` everywhere (already what we do for Qwen2.5).
|
| 37 |
+
|
| 38 |
+
## Qwen3 Thinker config fingerprint (for sanity check)
|
| 39 |
+
|
| 40 |
+
```
|
| 41 |
+
hidden_size = 2048 (Qwen2.5: 4096) ← projector output dim must change
|
| 42 |
+
num_hidden_layers = 48 (Qwen2.5: 28)
|
| 43 |
+
num_experts = 128
|
| 44 |
+
num_experts_per_tok = 8
|
| 45 |
+
mrope_section = (24, 20, 20) (Qwen2.5: (16, 24, 24))
|
| 46 |
+
mrope_interleaved = True (Qwen2.5: not interleaved)
|
| 47 |
+
audio_token_id = 151675 (Qwen2.5: 151646)
|
| 48 |
+
image_token_id = 151655
|
| 49 |
+
video_token_id = 151656
|
| 50 |
+
audio_encoder = qwen3_omni_moe_audio_encoder (Whisper-flavor, 128 mel)
|
| 51 |
+
sampling_rate = 16000
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## To activate
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
source /opt/conda/etc/profile.d/conda.sh
|
| 58 |
+
conda activate spur-qwen3
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
Existing Qwen2.5 / IV / AF3 work continues to use plain `spur` env unchanged.
|
| 62 |
+
|
| 63 |
+
## Memory budget for 30B-A3B on 8× 40GB A100
|
| 64 |
+
|
| 65 |
+
- BF16 weights ≈ 60 GB total. Single card cannot hold the full model.
|
| 66 |
+
- ZeRO-3 with optimizer + param offload: ~60/8 ≈ 7.5 GB shard + ~10 GB activations + LoRA buffers ≈ 22 GB/card. Fits with margin.
|
| 67 |
+
- LoRA targets `attention {q,k,v,o}_proj` only — expert MLPs (`SparseMoeBlock`) are NOT touched.
|
| 68 |
+
- Router aux loss is disabled (`router_aux_loss_coef=0.0`, `output_router_logits=False`) so training signal is pure LM loss; matters because we only LoRA the attention path.
|
| 69 |
+
|
| 70 |
+
## DeepSpeed ZeRO-3 integration status
|
| 71 |
+
|
| 72 |
+
- `configs/ds_zero3_qwen3.json` is committed (CPU offload optimizer + param, BF16, auto-batch).
|
| 73 |
+
- `train_spatial_beats_qa_qwen3.py` does **NOT** yet wire `deepspeed.initialize` — TODO. Until that's wired:
|
| 74 |
+
- **Stage1 projector_only on 8× 40GB**: try `BATCH_SIZE=1 GRAD_ACCUM_STEPS=8` with plain DDP. If the 30B forward OOMs in one card (likely), set `--device-map auto` via the trainer's `args.device_map` plumbing (single replica, no DDP) and drop NPROC=1.
|
| 75 |
+
- **Stage2/3 LoRA with optimizer state**: requires DS ZeRO-3 — add the `deepspeed.initialize(model, config_path=...)` call site in the trainer before that stage kicks off.
|
| 76 |
+
- Expected work to wire DS into trainer (1–2 days): replace `optimizer.step()` / `loss.backward()` with `engine.step()` / `engine.backward(loss)`, replace `DistributedDataParallel` wrap with `engine`. The rest of the loop (data, valid, ckpt) is unchanged.
|
| 77 |
+
|
docs/qwen3_h20_ddp_curriculum.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Qwen3-Omni H20 DDP 训练改动记录
|
| 2 |
+
|
| 3 |
+
本文档记录将 Spatial-BEATs + Qwen3-Omni-30B-A3B-Instruct 训练从 8×A100-40G + `device_map=auto` 迁移到 8×H20-95G + 标准 DDP 的所有改动,包含:环境差异、代码修复、新增 shell 脚本,以及 easy → medium → hard 三难度课程化训练的入口。
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. 背景
|
| 8 |
+
|
| 9 |
+
| 项目 | 旧环境 (spur-qwen3) | 新环境 (qwen3) |
|
| 10 |
+
|------|--------------------|----------------|
|
| 11 |
+
| GPU | 8 × A100 40 GB | 8 × H20 95 GB |
|
| 12 |
+
| CUDA driver | 12.2 | 12.9 |
|
| 13 |
+
| PyTorch | 2.10.0+cu128 | **2.9.0+cu128** |
|
| 14 |
+
| Python | 3.10.19 | **3.12.13** |
|
| 15 |
+
| transformers | 5.0.0.dev0(editable,远程 fork) | 5.0.0(site-packages) |
|
| 16 |
+
| flash_attn | 未安装,使用 sdpa | **2.8.3,使用 flash_attention_2** |
|
| 17 |
+
| accelerate | — | 1.13.0 |
|
| 18 |
+
| deepspeed | 0.19.0 | 0.19.0 |
|
| 19 |
+
| peft | 0.18.1 | 0.18.1 |
|
| 20 |
+
|
| 21 |
+
关键差异:
|
| 22 |
+
- **30B BF16 ≈ 60 GB**,旧 A100-40G 单卡不够 → 必须用 `device_map=auto`(accelerate 单进程多卡分片)。
|
| 23 |
+
- 新 H20-95G **单卡可以容纳完整模型** → 可以走原生 DDP,每卡一份 replica,吞吐快 3-5×。
|
| 24 |
+
- flash_attn 在新环境已可用 → 切到 `flash_attention_2` 进一步省显存、加速。
|
| 25 |
+
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
## 2. 关键路径
|
| 29 |
+
|
| 30 |
+
| 用途 | 路径 |
|
| 31 |
+
|------|------|
|
| 32 |
+
| 项目根 | `/apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/zzy/Spatial-Qwen` |
|
| 33 |
+
| Qwen3 模型权重 | `/apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/model_warehouse/Qwen3-Omni-30B-A3B-Instruct/`(66 GB,15 个 safetensors) |
|
| 34 |
+
| transformers fork | `/apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/zzy/transformers/src` |
|
| 35 |
+
| BEATs ckpt | `/apdcephfs_cq10/share_1603164/.../spatial_beats_ov1_unified_v13d_exp/03_ov123_top4/best.pt` |
|
| 36 |
+
| BEATs repo | `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats` |
|
| 37 |
+
| QA 数据根目录 | `/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced/` |
|
| 38 |
+
|
| 39 |
+
> ⚠️ QA 数据和 BEATs ckpt 在 `apdcephfs_cq10`(异地网络盘),跨区域 IO 比较慢。首次加载 train.jsonl 约 3 min,30B 模型 from_pretrained 约 15-20 min。
|
| 40 |
+
|
| 41 |
+
### conda 环境激活
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
source /root/miniconda3/etc/profile.d/conda.sh
|
| 45 |
+
conda activate qwen3
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
旧文档(`docs/qwen3_env.md`)里写的 `/opt/conda/etc/profile.d/conda.sh` 在本机不存在,conda 实际安装在 `/root/miniconda3`。
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
## 3. 代码改动
|
| 53 |
+
|
| 54 |
+
### 3.1 `train_spatial_beats_qa_qwen3.py` —— 修复 DDP 模式下模型未上 GPU 的 bug
|
| 55 |
+
|
| 56 |
+
**问题**:`_build_model_qwen3()` 只处理了 `device_map=auto` 的模块放置(去掉 accelerate hooks 后把 spatial 模块 pin 到 cuda:0)。当 `device_map=None`(DDP 模式)时,由于 `from_pretrained(low_cpu_mem_usage=True)` 把权重加载到 CPU,函数从未调用 `model.to(args.device)`,导致后续 `DDP(model, device_ids=[local_rank], ...)` 报 device 不匹配。Qwen2.5 的基线 `build_model()` 是有 `model.to(args.device)` 的,但 Qwen3 的 monkey-patch 替换没镜像这一分支。
|
| 57 |
+
|
| 58 |
+
**修复**:在 `_build_model_qwen3()` 末尾、`return model` 之前添加:
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
# DDP mode: move entire model to local GPU. ``from_pretrained`` loads to
|
| 62 |
+
# CPU when ``low_cpu_mem_usage=True`` is set without a device_map; DDP
|
| 63 |
+
# later wraps with device_ids=[local_rank] which requires the params to
|
| 64 |
+
# already live on that device. (The base trainer's build_model does this
|
| 65 |
+
# via ``model.to(args.device)``; the Qwen3 monkey-patched replacement
|
| 66 |
+
# forgot to mirror that branch.)
|
| 67 |
+
if device_map is None:
|
| 68 |
+
model.to(args.device)
|
| 69 |
+
_trainer.rank0_print(
|
| 70 |
+
f"[build_model_qwen3] DDP mode: moved model to {args.device}"
|
| 71 |
+
)
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
**验证**:smoke test 中日志出现 `[build_model_qwen3] DDP mode: moved model to cuda:0`,DDP wrap 成功,全部 8 ranks 进入训练循环,loss 在 1.0–3.0 之间正常下降。
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
### 3.2 `shell/launch_train_spatial_beats_qwen3.sh` —— 增加 `MAX_TRAIN_SAMPLES` / `MAX_VALID_SAMPLES` 转发
|
| 79 |
+
|
| 80 |
+
底层 trainer (`train_spatial_beats_qa.py`) 本身支持 `--max-train-samples` / `--max-valid-samples` 这两个参数用于 smoke test,但旧的 shell 脚本没把环境变量透传过去。在 `common_args=(...)` 之后追加:
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
# Smoke / debug knobs: cap dataset size if requested (defaults: full split).
|
| 84 |
+
if [[ -n "${MAX_TRAIN_SAMPLES:-}" ]]; then
|
| 85 |
+
common_args+=(--max-train-samples "${MAX_TRAIN_SAMPLES}")
|
| 86 |
+
echo "[config] max-train-samples = ${MAX_TRAIN_SAMPLES}"
|
| 87 |
+
fi
|
| 88 |
+
if [[ -n "${MAX_VALID_SAMPLES:-}" ]]; then
|
| 89 |
+
common_args+=(--max-valid-samples "${MAX_VALID_SAMPLES}")
|
| 90 |
+
echo "[config] max-valid-samples = ${MAX_VALID_SAMPLES}"
|
| 91 |
+
fi
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
这样:
|
| 95 |
+
```bash
|
| 96 |
+
MAX_TRAIN_SAMPLES=64 MAX_VALID_SAMPLES=8 bash shell/launch_train_spatial_beats_qwen3.sh
|
| 97 |
+
```
|
| 98 |
+
就能跑一个真实的小批数据 smoke。
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## 4. 新增脚本
|
| 103 |
+
|
| 104 |
+
### 4.1 `shell/launch_train_spatial_beats_qwen3_h20_ddp.sh` —— H20 DDP 入口
|
| 105 |
+
|
| 106 |
+
H20 95 GB 单卡能容纳完整 30B 模型,因此切换到原生 DDP(一进程一卡 replica)。脚本是对 `launch_train_spatial_beats_qwen3.sh` 的薄封装,改动如下:
|
| 107 |
+
|
| 108 |
+
```bash
|
| 109 |
+
unset DEVICE_MAP # 触发底层脚本的 torchrun DDP 分支
|
| 110 |
+
export ATTN_IMPL="${ATTN_IMPL:-flash_attention_2}" # qwen3 env 已装 flash_attn 2.8.3
|
| 111 |
+
# 每卡 BS(保守起步,stage1 实测 ~67 GB / 95 GB):
|
| 112 |
+
export STAGE1_BATCH_SIZE="${STAGE1_BATCH_SIZE:-4}" # projector_only:最省显存
|
| 113 |
+
export STAGE2_BATCH_SIZE="${STAGE2_BATCH_SIZE:-2}" # encoder_lora:加 LoRA optimizer
|
| 114 |
+
export STAGE3_BATCH_SIZE="${STAGE3_BATCH_SIZE:-1}" # beats_lora:解冻 BEATs 激活更大
|
| 115 |
+
# 全局 batch 通过 grad_accum 维持在 64:
|
| 116 |
+
export STAGE1_GRAD_ACCUM="${STAGE1_GRAD_ACCUM:-2}" # 4*2*8 = 64
|
| 117 |
+
export STAGE2_GRAD_ACCUM="${STAGE2_GRAD_ACCUM:-4}" # 2*4*8 = 64
|
| 118 |
+
export STAGE3_GRAD_ACCUM="${STAGE3_GRAD_ACCUM:-8}" # 1*8*8 = 64
|
| 119 |
+
export SPATIAL_QWEN_NCCL_TIMEOUT_MIN="${SPATIAL_QWEN_NCCL_TIMEOUT_MIN:-120}"
|
| 120 |
+
exec bash "${ROOT_DIR}/shell/launch_train_spatial_beats_qwen3.sh" "$@"
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
注意:所有变量都用 `${VAR:-default}` 风格,可被外层覆盖。
|
| 124 |
+
|
| 125 |
+
> 实测显存(stage1 projector_only, BS=1, GC 开启):约 **66-69 GB / 卡**,剩 ~25 GB 给激活/通信。BS=4 大概率能放下;如果还有富余可以试 BS=8。
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
### 4.2 `shell/launch_train_curriculum_qwen3_h20_ddp.sh` —— easy/medium/hard 课程化训练
|
| 130 |
+
|
| 131 |
+
按用户要求实现 **easy 三阶段 → medium stage3 续训 → hard stage3 续训** 的课程:
|
| 132 |
+
|
| 133 |
+
| 阶段 | QA 数据 | 训练模式 | 起点 |
|
| 134 |
+
|------|---------|----------|------|
|
| 135 |
+
| Phase 1 — easy | `easy/` (627 K train, 66 K valid) | stage1→stage2→stage3 | 从头 |
|
| 136 |
+
| Phase 2 — medium | `medium_plus_easy10/` (607 K train, 65 K valid) | 仅 stage3 (beats_lora) | resume from easy stage3 best |
|
| 137 |
+
| Phase 3 — hard | `hard_plus_med20_easy10/` (377 K train, 40 K valid) | 仅 stage3 (beats_lora) | resume from medium stage3 best |
|
| 138 |
+
|
| 139 |
+
> `medium_plus_easy10` 表示 medium 主体 + 10% easy 回放,`hard_plus_med20_easy10` 表示 hard + 20% medium + 10% easy 回放。**纯 hard 目录只有 test.jsonl,没有 train/valid,所以 hard 阶段必须用 `_plus_*` 课程版本。**
|
| 140 |
+
|
| 141 |
+
#### 关键设计
|
| 142 |
+
|
| 143 |
+
- **不重写底层逻辑**:每个 phase 都是一次 `bash launch_train_spatial_beats_qwen3_h20_ddp.sh` 的调用,通过 env 变量传 `QA_ROOT` / `RUN_ROOT` / `START_STAGE` / `STAGE3_RESUME_CKPT` / `STAGE3_RESUME_MODEL_ONLY=1`,让现有 stage 切换逻辑负责 LoRA 装配 + ckpt 加载。
|
| 144 |
+
- **medium / hard 用更小学习率**:避免覆盖 easy 阶段已学到的 LoRA + projector + BEATs 权重。默认:
|
| 145 |
+
```
|
| 146 |
+
MEDIUM_STAGE3_LR=2e-5 MEDIUM_STAGE3_LORA_LR=2e-5
|
| 147 |
+
MEDIUM_STAGE3_PROJECTOR_LR=1e-6 MEDIUM_STAGE3_BEATS_LR=5e-7
|
| 148 |
+
HARD_STAGE3_LR=1e-5 HARD_STAGE3_LORA_LR=1e-5
|
| 149 |
+
HARD_STAGE3_PROJECTOR_LR=1e-6 HARD_STAGE3_BEATS_LR=5e-7
|
| 150 |
+
```
|
| 151 |
+
- **依赖检查**:每个 phase 进入前检查对应 jsonl 存在;medium/hard 还会检查上一 phase 的 best_trainable.pt 是否就绪,缺失则 fail-fast。
|
| 152 |
+
- **可跳过任意 phase**:`SKIP_EASY=1` / `SKIP_MEDIUM=1` / `SKIP_HARD=1`;easy 内部可用 `EASY_START_STAGE=2` 等续训。
|
| 153 |
+
|
| 154 |
+
#### 输出目录结构
|
| 155 |
+
|
| 156 |
+
```
|
| 157 |
+
runs/qwen3_curriculum/
|
| 158 |
+
easy/
|
| 159 |
+
stage1_projector/checkpoints/{best,last,epoch_NNN}_trainable.pt
|
| 160 |
+
stage2_encoder_lora/checkpoints/...
|
| 161 |
+
stage3_beats_lora/checkpoints/best_trainable.pt # → medium 起点
|
| 162 |
+
medium/
|
| 163 |
+
stage3_beats_lora/checkpoints/best_trainable.pt # → hard 起点
|
| 164 |
+
hard/
|
| 165 |
+
stage3_beats_lora/checkpoints/best_trainable.pt
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
---
|
| 169 |
+
|
| 170 |
+
## 5. 启动命令
|
| 171 |
+
|
| 172 |
+
### 5.1 释放 GPU(之前残留的 vllm / torchrun 进程)
|
| 173 |
+
|
| 174 |
+
```bash
|
| 175 |
+
# 终止占用 8 卡的 ms-swift vllm deploy
|
| 176 |
+
kill -9 1194399 1194463 1194590 1194717 1194781 1194971 1195098 1195165
|
| 177 |
+
pkill -9 -f 'torchrun.*train_spatial' || true
|
| 178 |
+
pkill -9 -f 'train_spatial_beats_qa_qwen3' || true
|
| 179 |
+
nvidia-smi # 确认 8 卡显存清空
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
### 5.2 启动完整课程训练
|
| 183 |
+
|
| 184 |
+
建议放进 tmux/screen,预计运行多天。
|
| 185 |
+
|
| 186 |
+
```bash
|
| 187 |
+
source /root/miniconda3/etc/profile.d/conda.sh
|
| 188 |
+
conda activate qwen3
|
| 189 |
+
cd /apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/zzy/Spatial-Qwen
|
| 190 |
+
|
| 191 |
+
mkdir -p logs
|
| 192 |
+
GPUS=0,1,2,3,4,5,6,7 \
|
| 193 |
+
MODEL_ID=/apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/model_warehouse/Qwen3-Omni-30B-A3B-Instruct \
|
| 194 |
+
QWEN3_OMNI_FORK=/apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/zzy/transformers/src \
|
| 195 |
+
RUN_ROOT_BASE=./runs/qwen3_curriculum \
|
| 196 |
+
bash shell/launch_train_curriculum_qwen3_h20_ddp.sh 2>&1 \
|
| 197 |
+
| tee logs/qwen3_curriculum_$(date +%Y%m%d_%H%M).log
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
### 5.3 常用 override
|
| 201 |
+
|
| 202 |
+
```bash
|
| 203 |
+
# 跳过部分 phase(已经跑完 easy 想继续 medium)
|
| 204 |
+
SKIP_EASY=1 bash shell/launch_train_curriculum_qwen3_h20_ddp.sh
|
| 205 |
+
|
| 206 |
+
# 只跑 hard
|
| 207 |
+
SKIP_EASY=1 SKIP_MEDIUM=1 bash shell/launch_train_curriculum_qwen3_h20_ddp.sh
|
| 208 |
+
|
| 209 |
+
# easy 从 stage2 续(stage1 已完成)
|
| 210 |
+
EASY_START_STAGE=2 bash shell/launch_train_curriculum_qwen3_h20_ddp.sh
|
| 211 |
+
|
| 212 |
+
# 调整 BS(实测 stage1 还有大量显存余量时尝试)
|
| 213 |
+
STAGE1_BATCH_SIZE=8 STAGE1_GRAD_ACCUM=1 \
|
| 214 |
+
bash shell/launch_train_curriculum_qwen3_h20_ddp.sh
|
| 215 |
+
|
| 216 |
+
# 调整 epoch 数
|
| 217 |
+
STAGE1_EPOCHS=2 STAGE2_EPOCHS=3 STAGE3_EPOCHS=3 \
|
| 218 |
+
MEDIUM_STAGE3_EPOCHS=2 HARD_STAGE3_EPOCHS=2 \
|
| 219 |
+
bash shell/launch_train_curriculum_qwen3_h20_ddp.sh
|
| 220 |
+
|
| 221 |
+
# Smoke:每 phase 32 训练样本 + 1 epoch(验证 wiring,不训练)
|
| 222 |
+
MAX_TRAIN_SAMPLES=32 MAX_VALID_SAMPLES=8 \
|
| 223 |
+
STAGE1_EPOCHS=1 STAGE2_EPOCHS=1 STAGE3_EPOCHS=1 \
|
| 224 |
+
MEDIUM_STAGE3_EPOCHS=1 HARD_STAGE3_EPOCHS=1 \
|
| 225 |
+
RUN_ROOT_BASE=./runs/qwen3_curriculum_smoke \
|
| 226 |
+
bash shell/launch_train_curriculum_qwen3_h20_ddp.sh
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
+
---
|
| 230 |
+
|
| 231 |
+
## 6. 已验证 / 已知行为
|
| 232 |
+
|
| 233 |
+
### 6.1 已验证
|
| 234 |
+
|
| 235 |
+
- **环境**:qwen3 conda env 内 torch 2.9.0+cu128、transformers 5.0.0、flash_attn 2.8.3、peft、accelerate、tensorboard、soundfile 全部 import 通过。
|
| 236 |
+
- **fork 可达**:`/apdcephfs_fsgm/.../zzy/transformers/src` 下 `qwen3_omni_moe` 子模块可正常 import;config.json 解析后 `hidden_size=2048`、`audio_token_id=151675` 与 `docs/qwen3_env.md` 描述一致。
|
| 237 |
+
- **DDP 启动**:8 ranks 通过 torchrun 正常初始化,`from_pretrained` 后通过新加的 `model.to(args.device)` 上 GPU,DDP wrap(`find_unused_parameters=True`)成功。
|
| 238 |
+
- **训练循环**:stage1 BS=1 项目下 ~2 it/s,loss 1.0–3.0 区间合理震荡。
|
| 239 |
+
- **显存(stage1 projector_only, BS=1, GC=on)**:~66-69 GB / 卡,95 GB 余 ~25 GB,BS=4 安全可行。
|
| 240 |
+
|
| 241 |
+
### 6.2 已知 quirk
|
| 242 |
+
|
| 243 |
+
- **跨区域 NFS 慢**:每次 from_pretrained 加载 30B 权重约 15-20 min,是当前最大的启动开销。如果反复实验值得做:
|
| 244 |
+
```bash
|
| 245 |
+
# 把模型 cp 到本地 ssd(如果有)
|
| 246 |
+
rsync -av /apdcephfs_fsgm/.../Qwen3-Omni-30B-A3B-Instruct/ /local/ssd/Qwen3-Omni-30B-A3B-Instruct/
|
| 247 |
+
```
|
| 248 |
+
- **DDP find_unused_parameters=True 警告**:基底 trainer 出于稳健性默认开启,每个 forward 多遍历一次 autograd 图。stage1 实测对吞吐影响不大,stage2/3 LoRA 路径才真正需要它,保持现状。
|
| 249 |
+
- **`use_cache=True` 与 GC 冲突**:transformers 会自动回退到 `use_cache=False`,仅有警告,可忽略。
|
| 250 |
+
- **vllm 占卡**:本机此前长时间运行 8 个 ms-swift vllm deploy(端口 8100-8107,`Qwen3omni-thinking-opsd-merged-ablation1500`),训练前必须 `kill -9` 释放。
|
| 251 |
+
|
| 252 |
+
### 6.3 ⚠️ 未验证但需要关注
|
| 253 |
+
|
| 254 |
+
- **BS=4 / 8 / 16 的真实显存峰值**:smoke 没跑到稳态,启动时 GPU 还有 vllm 残留导致一次 OOM。建议第一次跑真实训练前用 `nvidia-smi --query-gpu=memory.used --format=csv -l 5` 监控前 100 步峰值,按需下调 BS。
|
| 255 |
+
- **stage3 解冻 BEATs 的显存**:BEATs encoder backbone 进入训练梯度,且会调 `torch.stft` / `cuFFT`,旧文档强调要小心 `cufft_plan_cache` 碎片(基底 trainer 已经把 `max_size=8` + `empty_cache(每500 step)`)。stage3 BS=1 应该安全,但请观察前几个 epoch 是否稳定。
|
| 256 |
+
- **medium/hard resume 的 `find_unused_parameters`**:medium/hard 从 easy stage3 best 续训,如果 LoRA target 解析顺序在不同 stage 略有不同,可能有未使用参数;已默认开启 `find_unused_parameters=True`,无需手动处理。
|
| 257 |
+
|
| 258 |
+
---
|
| 259 |
+
|
| 260 |
+
## 7. 文件改动清单
|
| 261 |
+
|
| 262 |
+
| 路径 | 改动 |
|
| 263 |
+
|------|------|
|
| 264 |
+
| `train_spatial_beats_qa_qwen3.py` | **修改** —— `_build_model_qwen3()` 末尾追加 `if device_map is None: model.to(args.device)`(约 7 行新增) |
|
| 265 |
+
| `shell/launch_train_spatial_beats_qwen3.sh` | **修改** —— 在 `common_args` 后追加 MAX_TRAIN_SAMPLES / MAX_VALID_SAMPLES 转发(约 8 行新增) |
|
| 266 |
+
| `shell/launch_train_spatial_beats_qwen3_h20_ddp.sh` | **新增** —— H20 DDP 入口(~70 行) |
|
| 267 |
+
| `shell/launch_train_curriculum_qwen3_h20_ddp.sh` | **新增** —— easy/medium/hard 课程化主控脚本(~140 行) |
|
| 268 |
+
| `docs/qwen3_h20_ddp_curriculum.md` | **新增** —— 本文档 |
|
| 269 |
+
|
| 270 |
+
未改动(按原约束保留):
|
| 271 |
+
- `train_spatial_beats_qa.py`(Qwen2.5 基底 trainer)
|
| 272 |
+
- `transformers` fork 内任何文件
|
| 273 |
+
- `spatial_qwen/model/` 与 `spatial_qwen/modules/` 任何文件
|
| 274 |
+
|
| 275 |
+
---
|
| 276 |
+
|
| 277 |
+
## 8. 后续 TODO(不阻塞当前训练)
|
| 278 |
+
|
| 279 |
+
- **DeepSpeed ZeRO-3 接入**:`configs/ds_zero3_qwen3.json` 已存在,但 trainer 还没接 `deepspeed.initialize`。当前 H20 DDP 已经够用,仅在多机扩展或后续更大模型时再做。
|
| 280 |
+
- **本地 SSD 缓存模型权重**:消除每次 15-20 min 的跨区域 NFS 启动开销。
|
| 281 |
+
- **课程化数据加权策略实验**:当前 medium / hard 直接复用预生成的 `_plus_*` jsonl。后续可以尝试在 trainer 里做 on-the-fly 难度采样。
|
docs/seld233_implementation.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SELD233 Spatial Implementation Guide
|
| 2 |
+
|
| 3 |
+
## Purpose
|
| 4 |
+
This document is the implementation guide for the independent SELD233 spatial modality.
|
| 5 |
+
|
| 6 |
+
It answers four questions:
|
| 7 |
+
- which classes and functions were implemented for the core path
|
| 8 |
+
- which classes are already scaffolded and should be reused as-is
|
| 9 |
+
- what each interface accepts and returns
|
| 10 |
+
- what concrete code is still deferred outside the current scope
|
| 11 |
+
|
| 12 |
+
This guide should be read together with:
|
| 13 |
+
- `docs/spatial_encoder_plan.md`
|
| 14 |
+
- `docs/seld233_spatial_scaffold.md`
|
| 15 |
+
|
| 16 |
+
## Fixed Constraints
|
| 17 |
+
- Do not modify the DCASE baseline repository.
|
| 18 |
+
- Do not modify the original QwenOmni main classes for this feature; use the new spatial subclasses.
|
| 19 |
+
- A batch must be either all mono or all FOA.
|
| 20 |
+
- Mono batch:
|
| 21 |
+
- must contain exactly one `<|AUDIO|>`
|
| 22 |
+
- must not contain `<|spatial|>`
|
| 23 |
+
- only the original audio path is active
|
| 24 |
+
- FOA batch:
|
| 25 |
+
- must contain exactly one `<|AUDIO|>`
|
| 26 |
+
- must contain exactly one `<|spatial|>`
|
| 27 |
+
- both audio and spatial paths are active
|
| 28 |
+
- Audio is clipped to `0-20s`.
|
| 29 |
+
- Sample rate is `16kHz`.
|
| 30 |
+
- Spatial token rate target is `2.5 Hz`.
|
| 31 |
+
- Full `20s` limits:
|
| 32 |
+
- max samples: `320000`
|
| 33 |
+
- max feature frames: `1000`
|
| 34 |
+
- max SELD frames: `200`
|
| 35 |
+
- max spatial tokens: `50`
|
| 36 |
+
|
| 37 |
+
## Status Summary
|
| 38 |
+
|
| 39 |
+
### Already scaffolded and reusable
|
| 40 |
+
- `qwen2_5_omni_spur/spatial_seld233_utils.py`
|
| 41 |
+
- `qwen2_5_omni_spur/modules/seldnet233_spatial_adapter.py`
|
| 42 |
+
- `qwen2_5_omni_spur/modules/spatial_token_projector.py`
|
| 43 |
+
- `qwen2_5_omni_spur/processing_qwen2_5_omni_spatial.py`
|
| 44 |
+
- `qwen2_5_omni_spur/modeling_qwen2_5_omni_spatial.py`
|
| 45 |
+
- config additions in `qwen2_5_omni_spur/configuration_qwen2_5_omni.py`
|
| 46 |
+
|
| 47 |
+
### Must still be implemented
|
| 48 |
+
- training script migration to the new spatial subclasses
|
| 49 |
+
- inference script migration to the new spatial subclasses
|
| 50 |
+
|
| 51 |
+
### Explicitly deferred for now
|
| 52 |
+
- `image + spatial` joint RoPE
|
| 53 |
+
- `use_audio_in_video=True`
|
| 54 |
+
- `return_audio=True` talker path with spatial modality
|
| 55 |
+
|
| 56 |
+
## Implementation Inventory
|
| 57 |
+
|
| 58 |
+
| Priority | File | Symbol | Current State | Required Action |
|
| 59 |
+
| --- | --- | --- | --- | --- |
|
| 60 |
+
| P0 | `qwen2_5_omni_spur/modules/seldnet233_feature_bridge.py` | `SeldNet233FeatureBridge._extract_online_features` | implemented | no further action for the current scope |
|
| 61 |
+
| P0 | `qwen2_5_omni_spur/modules/seldnet233_backbone.py` | `SeldNet233Backbone._run_seldnet_backbone` | implemented | no further action for the current scope |
|
| 62 |
+
| P1 | `training-qwen-omni/train_spur_spatial_only_hf.py` | `main()` and config wiring | legacy | migrate only if this script is needed for training runs |
|
| 63 |
+
| P1 | `qwen-omni-inference.py` | script body | legacy | migrate only if this script is needed for ad hoc inference |
|
| 64 |
+
| P2 | `qwen2_5_omni_spur/modeling_qwen2_5_omni_spatial.py` | `get_rope_index` | partial | only needed later if image + spatial is required |
|
| 65 |
+
| P2 | `qwen2_5_omni_spur/modeling_qwen2_5_omni_spatial.py` | `generate(return_audio=True)` path | partial | only needed if talker output is required later |
|
| 66 |
+
|
| 67 |
+
## Detailed Interface Guide
|
| 68 |
+
|
| 69 |
+
### 1. `SeldNet233FeatureBridge`
|
| 70 |
+
File:
|
| 71 |
+
- `qwen2_5_omni_spur/modules/seldnet233_feature_bridge.py`
|
| 72 |
+
|
| 73 |
+
Class:
|
| 74 |
+
- `SeldNet233FeatureBridge`
|
| 75 |
+
|
| 76 |
+
Already implemented:
|
| 77 |
+
- constructor
|
| 78 |
+
- input validation
|
| 79 |
+
- waveform mask -> valid length conversion
|
| 80 |
+
- waveform length -> feature length conversion
|
| 81 |
+
- output mask bookkeeping
|
| 82 |
+
- online baseline-aligned STFT / log-mel / intensity-vector extraction
|
| 83 |
+
- baseline `foa_wts` normalization
|
| 84 |
+
|
| 85 |
+
Input contract:
|
| 86 |
+
- `spatial_audio`: `torch.Tensor`, shape `[B, T_audio_max, 4]`
|
| 87 |
+
- `spatial_audio_lengths`: `torch.LongTensor`, shape `[B]`
|
| 88 |
+
- `feature_lengths`: `torch.LongTensor`, shape `[B]`
|
| 89 |
+
- `feature_attention_mask`: `torch.BoolTensor`, shape `[B, T_feat_max]`
|
| 90 |
+
|
| 91 |
+
Output contract:
|
| 92 |
+
- `SeldNet233FeatureBridgeOutput.features`: `[B, 7, T_feat_max, 64]`
|
| 93 |
+
- `SeldNet233FeatureBridgeOutput.feature_attention_mask`: `[B, T_feat_max]`
|
| 94 |
+
- `SeldNet233FeatureBridgeOutput.feature_lengths`: `[B]`
|
| 95 |
+
|
| 96 |
+
Required implementation content:
|
| 97 |
+
1. Load or derive the exact task-233 feature configuration.
|
| 98 |
+
2. Reproduce the baseline feature math for FOA:
|
| 99 |
+
- `4ch` log-mel
|
| 100 |
+
- `3ch` FOA intensity vector
|
| 101 |
+
3. Use the task-233 normalization weights.
|
| 102 |
+
4. Keep output frame count aligned with `feature_lengths`.
|
| 103 |
+
5. Zero-fill padded tail frames only after valid frames are computed.
|
| 104 |
+
|
| 105 |
+
Recommended private helpers to add inside this file:
|
| 106 |
+
- `_load_task233_feature_config()`
|
| 107 |
+
- `_load_feature_stats()`
|
| 108 |
+
- `_compute_stft(...)`
|
| 109 |
+
- `_compute_logmel_channels(...)`
|
| 110 |
+
- `_compute_intensity_vector_channels(...)`
|
| 111 |
+
- `_normalize_feature_tensor(...)`
|
| 112 |
+
|
| 113 |
+
Important shape transitions:
|
| 114 |
+
- raw FOA waveform: `[B, T_audio_max, 4]`
|
| 115 |
+
- internal channels-first view: `[B, 4, T_audio_max]`
|
| 116 |
+
- mel-like features before stacking: `[B, 4, T_feat_max, 64]`
|
| 117 |
+
- intensity-vector features: `[B, 3, T_feat_max, 64]`
|
| 118 |
+
- final baseline tensor: `[B, 7, T_feat_max, 64]`
|
| 119 |
+
|
| 120 |
+
Validation checklist:
|
| 121 |
+
- same sample length gives same `T_feat` as `samples_to_feature_frames`
|
| 122 |
+
- values match offline baseline extraction on the same clip
|
| 123 |
+
- normalization path is identical to baseline task `233`
|
| 124 |
+
|
| 125 |
+
### 2. `SeldNet233Backbone`
|
| 126 |
+
File:
|
| 127 |
+
- `qwen2_5_omni_spur/modules/seldnet233_backbone.py`
|
| 128 |
+
|
| 129 |
+
Class:
|
| 130 |
+
- `SeldNet233Backbone`
|
| 131 |
+
|
| 132 |
+
Already implemented:
|
| 133 |
+
- constructor
|
| 134 |
+
- input validation
|
| 135 |
+
- feature length -> SELD length conversion
|
| 136 |
+
- output mask bookkeeping
|
| 137 |
+
- dynamic baseline loading
|
| 138 |
+
- checkpoint restore with shape-compatible filtering
|
| 139 |
+
- last MHSA LayerNorm hidden capture
|
| 140 |
+
|
| 141 |
+
Input contract:
|
| 142 |
+
- `seld233_features`: `torch.Tensor`, shape `[B, 7, T_feat_max, 64]`
|
| 143 |
+
- `seld233_feature_lengths`: `torch.LongTensor`, shape `[B]`
|
| 144 |
+
- `hidden_lengths`: `torch.LongTensor`, shape `[B]`
|
| 145 |
+
- `hidden_attention_mask`: `torch.BoolTensor`, shape `[B, T_seld_max]`
|
| 146 |
+
|
| 147 |
+
Output contract:
|
| 148 |
+
- `SeldNet233BackboneOutput.hidden_states`: `[B, T_seld_max, 128]`
|
| 149 |
+
- `SeldNet233BackboneOutput.hidden_attention_mask`: `[B, T_seld_max]`
|
| 150 |
+
- `SeldNet233BackboneOutput.hidden_lengths`: `[B]`
|
| 151 |
+
|
| 152 |
+
Required implementation content:
|
| 153 |
+
1. Dynamically load `parameters.py` and `seldnet_model.py` from the baseline repo path.
|
| 154 |
+
2. Build the task-233 baseline model.
|
| 155 |
+
3. Restore the pretrained checkpoint from `seld233_checkpoint_path`.
|
| 156 |
+
4. Freeze the backbone if `seld233_freeze_backbone=True`.
|
| 157 |
+
5. Register a hook at the final MHSA shared representation.
|
| 158 |
+
6. Feed the baseline-compatible features into the model.
|
| 159 |
+
7. Return the captured hidden tensor, not accdoa heads and not sed logits.
|
| 160 |
+
|
| 161 |
+
Recommended private helpers to add inside this file:
|
| 162 |
+
- `_load_baseline_modules()`
|
| 163 |
+
- `_build_seld233_model()`
|
| 164 |
+
- `_load_checkpoint_weights()`
|
| 165 |
+
- `_register_hidden_hook()`
|
| 166 |
+
- `_prepare_baseline_input_layout(...)`
|
| 167 |
+
|
| 168 |
+
Important shape transitions:
|
| 169 |
+
- model input for this wrapper: `[B, 7, T_feat_max, 64]`
|
| 170 |
+
- likely baseline internal flattened layout: `[B, T_feat_max, 448]`
|
| 171 |
+
- captured MHSA hidden: `[B, T_seld_max, 128]`
|
| 172 |
+
|
| 173 |
+
Validation checklist:
|
| 174 |
+
- checkpoint path exists
|
| 175 |
+
- hook fires exactly once per forward
|
| 176 |
+
- hidden dim is exactly `128`
|
| 177 |
+
- hidden length matches `feature_frames_to_seld_frames`
|
| 178 |
+
|
| 179 |
+
### 3. `SeldNet233SpatialAdapter`
|
| 180 |
+
File:
|
| 181 |
+
- `qwen2_5_omni_spur/modules/seldnet233_spatial_adapter.py`
|
| 182 |
+
|
| 183 |
+
Class:
|
| 184 |
+
- `SeldNet233SpatialAdapter`
|
| 185 |
+
|
| 186 |
+
Status:
|
| 187 |
+
- already usable once feature bridge and backbone are implemented
|
| 188 |
+
|
| 189 |
+
Input modes already supported:
|
| 190 |
+
- raw audio path:
|
| 191 |
+
- `spatial_audio [B, T_audio_max, 4]`
|
| 192 |
+
- offline feature path:
|
| 193 |
+
- `seld233_features [B, 7, T_feat_max, 64]`
|
| 194 |
+
- direct hidden path:
|
| 195 |
+
- `seld233_hidden_states [B, T_seld_max, 128]`
|
| 196 |
+
|
| 197 |
+
Output:
|
| 198 |
+
- `spatial_tokens [B, T_spat_max, 256]`
|
| 199 |
+
- `spatial_token_attention_mask [B, T_spat_max]`
|
| 200 |
+
- `spatial_token_lengths [B]`
|
| 201 |
+
|
| 202 |
+
No new implementation is required here unless you want to change:
|
| 203 |
+
- downsampling rule
|
| 204 |
+
- token MLP architecture
|
| 205 |
+
- token dimension
|
| 206 |
+
|
| 207 |
+
Current downsampling rule:
|
| 208 |
+
- `T_spat = ceil(T_seld / 4)`
|
| 209 |
+
- effective rate: `10 Hz -> 2.5 Hz`
|
| 210 |
+
|
| 211 |
+
### 4. `SpatialTokenProjector`
|
| 212 |
+
File:
|
| 213 |
+
- `qwen2_5_omni_spur/modules/spatial_token_projector.py`
|
| 214 |
+
|
| 215 |
+
Class:
|
| 216 |
+
- `SpatialTokenProjector`
|
| 217 |
+
|
| 218 |
+
Status:
|
| 219 |
+
- already implemented
|
| 220 |
+
|
| 221 |
+
Input:
|
| 222 |
+
- `spatial_tokens [B, T_spat, D_in]`
|
| 223 |
+
|
| 224 |
+
Output:
|
| 225 |
+
- projected tokens `[B, T_spat, D_llm]`
|
| 226 |
+
|
| 227 |
+
No further code is required here unless model capacity needs tuning.
|
| 228 |
+
|
| 229 |
+
### 5. `Qwen2_5OmniSpatialProcessor`
|
| 230 |
+
File:
|
| 231 |
+
- `qwen2_5_omni_spur/processing_qwen2_5_omni_spatial.py`
|
| 232 |
+
|
| 233 |
+
Class:
|
| 234 |
+
- `Qwen2_5OmniSpatialProcessor`
|
| 235 |
+
|
| 236 |
+
Status:
|
| 237 |
+
- implemented scaffold
|
| 238 |
+
- should be reused, not rewritten
|
| 239 |
+
|
| 240 |
+
Important public interfaces:
|
| 241 |
+
- `__call__(...)`
|
| 242 |
+
- `sync_spatial_tokenizer_with_model(model)`
|
| 243 |
+
|
| 244 |
+
Input behavior:
|
| 245 |
+
- mono batch:
|
| 246 |
+
- prompt must include one `<|AUDIO|>`
|
| 247 |
+
- prompt must not include `<|spatial|>`
|
| 248 |
+
- FOA batch:
|
| 249 |
+
- prompt must include one `<|AUDIO|>`
|
| 250 |
+
- prompt must include one `<|spatial|>`
|
| 251 |
+
|
| 252 |
+
Output keys already supported:
|
| 253 |
+
- `input_ids`
|
| 254 |
+
- `input_features`
|
| 255 |
+
- `feature_attention_mask`
|
| 256 |
+
- `spatial_audio`
|
| 257 |
+
- `spatial_audio_attention_mask`
|
| 258 |
+
- `spatial_audio_lengths`
|
| 259 |
+
- `spatial_tokens`
|
| 260 |
+
- `seld233_features`
|
| 261 |
+
- `seld233_feature_attention_mask`
|
| 262 |
+
- `seld233_feature_lengths`
|
| 263 |
+
- `spatial_token_lengths`
|
| 264 |
+
|
| 265 |
+
No core algorithm is missing here.
|
| 266 |
+
|
| 267 |
+
What still needs to happen outside this file:
|
| 268 |
+
- training script must actually instantiate this processor
|
| 269 |
+
- inference script must actually instantiate this processor
|
| 270 |
+
- both scripts must call `processor.sync_spatial_tokenizer_with_model(model)`
|
| 271 |
+
|
| 272 |
+
### 6. `Qwen2_5OmniSpatialThinkerForConditionalGeneration`
|
| 273 |
+
File:
|
| 274 |
+
- `qwen2_5_omni_spur/modeling_qwen2_5_omni_spatial.py`
|
| 275 |
+
|
| 276 |
+
Class:
|
| 277 |
+
- `Qwen2_5OmniSpatialThinkerForConditionalGeneration`
|
| 278 |
+
|
| 279 |
+
Status:
|
| 280 |
+
- spatial injection path is implemented
|
| 281 |
+
- tokenizer sync helper is implemented
|
| 282 |
+
- prefill spatial routing is implemented
|
| 283 |
+
- video + audio + spatial RoPE is implemented for `use_audio_in_video=False`
|
| 284 |
+
|
| 285 |
+
Important public interfaces:
|
| 286 |
+
- `forward(...)`
|
| 287 |
+
- `prepare_inputs_for_generation(...)`
|
| 288 |
+
- `sync_spatial_tokenizer(...)`
|
| 289 |
+
|
| 290 |
+
Input contract:
|
| 291 |
+
- normal Qwen text/audio inputs
|
| 292 |
+
- optional spatial inputs:
|
| 293 |
+
- `spatial_audio [B, T_audio_max, 4]`
|
| 294 |
+
- `seld233_features [B, 7, T_feat_max, 64]`
|
| 295 |
+
- `spatial_tokens [B, T_spat_max, D_spat]`
|
| 296 |
+
- matching length or mask tensors
|
| 297 |
+
|
| 298 |
+
Output behavior:
|
| 299 |
+
- if no spatial input is provided, it falls back to the base thinker
|
| 300 |
+
- if spatial input is provided, it injects projected spatial embeddings at
|
| 301 |
+
`<|spatial|>` positions
|
| 302 |
+
|
| 303 |
+
Still missing only if scope expands later:
|
| 304 |
+
- true multimodal RoPE for `image + spatial`
|
| 305 |
+
- talker/audio-output path
|
| 306 |
+
|
| 307 |
+
### 7. `Qwen2_5OmniSpatialForConditionalGeneration`
|
| 308 |
+
File:
|
| 309 |
+
- `qwen2_5_omni_spur/modeling_qwen2_5_omni_spatial.py`
|
| 310 |
+
|
| 311 |
+
Class:
|
| 312 |
+
- `Qwen2_5OmniSpatialForConditionalGeneration`
|
| 313 |
+
|
| 314 |
+
Status:
|
| 315 |
+
- implemented scaffold
|
| 316 |
+
|
| 317 |
+
Important public interfaces:
|
| 318 |
+
- `sync_spatial_tokenizer(...)`
|
| 319 |
+
- `generate(...)`
|
| 320 |
+
|
| 321 |
+
No core code is missing for text-only generation with audio/spatial input.
|
| 322 |
+
|
| 323 |
+
Still deferred:
|
| 324 |
+
- `return_audio=True` path
|
| 325 |
+
|
| 326 |
+
## Script-Level Work
|
| 327 |
+
|
| 328 |
+
### 8. Training Script
|
| 329 |
+
File:
|
| 330 |
+
- `training-qwen-omni/train_spur_spatial_only_hf.py`
|
| 331 |
+
|
| 332 |
+
Current issue:
|
| 333 |
+
- it still uses the old SPUR audio-fusion line
|
| 334 |
+
|
| 335 |
+
Minimum required changes:
|
| 336 |
+
1. Replace imports:
|
| 337 |
+
- old:
|
| 338 |
+
- `Qwen2_5OmniProcessor`
|
| 339 |
+
- `Qwen2_5OmniForConditionalGeneration`
|
| 340 |
+
- new:
|
| 341 |
+
- `Qwen2_5OmniSpatialProcessor`
|
| 342 |
+
- `Qwen2_5OmniSpatialForConditionalGeneration`
|
| 343 |
+
2. Replace old SPUR config overrides with new `seld233_*` thinker config fields.
|
| 344 |
+
3. After loading processor and model, call:
|
| 345 |
+
- `processor.sync_spatial_tokenizer_with_model(model)`
|
| 346 |
+
4. Update prompt construction:
|
| 347 |
+
- mono batch prompt: includes `<|AUDIO|>` only
|
| 348 |
+
- FOA batch prompt: includes `<|AUDIO|><|spatial|>`
|
| 349 |
+
5. Ensure collator preserves mono or FOA batch homogeneity.
|
| 350 |
+
6. Ensure audio clips are clipped to `20s`.
|
| 351 |
+
7. Ensure training batch uses the new processor output keys.
|
| 352 |
+
|
| 353 |
+
Functions that most likely need modification:
|
| 354 |
+
- `apply_spur_config_overrides(...)`
|
| 355 |
+
- `main()`
|
| 356 |
+
|
| 357 |
+
### 9. Inference Script
|
| 358 |
+
File:
|
| 359 |
+
- `qwen-omni-inference.py`
|
| 360 |
+
|
| 361 |
+
Current issue:
|
| 362 |
+
- it still uses the old processor/model path
|
| 363 |
+
|
| 364 |
+
Minimum required changes:
|
| 365 |
+
1. Replace imports with the new spatial subclasses.
|
| 366 |
+
2. Load FOA audio without collapsing channels.
|
| 367 |
+
3. Build prompt with canonical tokens:
|
| 368 |
+
- FOA: `<|AUDIO|><|spatial|> ...`
|
| 369 |
+
- mono: `<|AUDIO|> ...`
|
| 370 |
+
4. Call:
|
| 371 |
+
- `processor.sync_spatial_tokenizer_with_model(model)`
|
| 372 |
+
5. Print or assert:
|
| 373 |
+
- `spatial_token_lengths`
|
| 374 |
+
- number of `<|spatial|>` token positions after tokenization
|
| 375 |
+
6. Run one prefill/generation sanity check.
|
| 376 |
+
|
| 377 |
+
There is no reusable function boundary in the current script; the top-level
|
| 378 |
+
script body itself needs to be migrated.
|
| 379 |
+
|
| 380 |
+
## Suggested Implementation Order
|
| 381 |
+
1. Implement `SeldNet233FeatureBridge._extract_online_features`.
|
| 382 |
+
2. Implement `SeldNet233Backbone._run_seldnet_backbone`.
|
| 383 |
+
3. Run a direct module test:
|
| 384 |
+
- `spatial_audio -> feature bridge -> backbone -> adapter`
|
| 385 |
+
4. Migrate `training-qwen-omni/train_spur_spatial_only_hf.py`.
|
| 386 |
+
5. Migrate `qwen-omni-inference.py`.
|
| 387 |
+
6. Only after that, consider optional RoPE/talker extensions.
|
| 388 |
+
|
| 389 |
+
## Required Checks After Each Stage
|
| 390 |
+
|
| 391 |
+
### After feature bridge
|
| 392 |
+
- same clip gives matching online vs offline task-233 features
|
| 393 |
+
- feature tensor is `[B, 7, T_feat_max, 64]`
|
| 394 |
+
- feature mask matches `feature_lengths`
|
| 395 |
+
|
| 396 |
+
### After backbone
|
| 397 |
+
- checkpoint loads successfully
|
| 398 |
+
- captured hidden is `[B, T_seld_max, 128]`
|
| 399 |
+
- hidden length matches derived `T_seld`
|
| 400 |
+
|
| 401 |
+
### After end-to-end spatial adapter
|
| 402 |
+
- `spatial_tokens` is `[B, T_spat_max, 256]`
|
| 403 |
+
- `spatial_token_lengths` equals `ceil(T_seld / 4)`
|
| 404 |
+
- no placeholder count mismatch
|
| 405 |
+
|
| 406 |
+
### After training/inference migration
|
| 407 |
+
- `<|spatial|>` is present in tokenizer vocab
|
| 408 |
+
- `config.thinker_config.spatial_token_index` is set
|
| 409 |
+
- thinker embedding size matches tokenizer size
|
| 410 |
+
- mono batch runs without spatial injection
|
| 411 |
+
- FOA batch runs with spatial injection
|
| 412 |
+
|
| 413 |
+
## Out of Scope For The Next Coding Stage
|
| 414 |
+
- support mixed mono/FOA batches
|
| 415 |
+
- support image/video + spatial at the same time
|
| 416 |
+
- support talker audio generation with spatial tokens
|
| 417 |
+
- change the task-233 feature definition or baseline architecture
|
docs/seld233_scaffold.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SELD233 Spatial Scaffold
|
| 2 |
+
|
| 3 |
+
## Purpose
|
| 4 |
+
This scaffold adds a new, non-invasive code path for the independent SELD233 spatial modality without changing the existing QwenOmni audio / image / video implementation.
|
| 5 |
+
|
| 6 |
+
The scaffold focuses on:
|
| 7 |
+
- public class boundaries
|
| 8 |
+
- tensor contracts
|
| 9 |
+
- length bookkeeping
|
| 10 |
+
- placeholder expansion
|
| 11 |
+
- thinker-side spatial injection wiring
|
| 12 |
+
|
| 13 |
+
The current state is no longer scaffold-only for the core `audio + spatial + text`
|
| 14 |
+
path:
|
| 15 |
+
- online `FOA -> 7ch` feature extraction is implemented
|
| 16 |
+
- SELD backbone loading + checkpoint restore + MHSA hidden capture is implemented
|
| 17 |
+
- the remaining deferred items are limited to `image + spatial`,
|
| 18 |
+
`use_audio_in_video=True`, and `return_audio=True`
|
| 19 |
+
|
| 20 |
+
## New Files
|
| 21 |
+
|
| 22 |
+
### `qwen2_5_omni_spur/spatial_seld233_utils.py`
|
| 23 |
+
Shared length and mask helpers.
|
| 24 |
+
|
| 25 |
+
Key utilities:
|
| 26 |
+
- `attention_mask_to_lengths(attention_mask) -> [B]`
|
| 27 |
+
- `build_1d_attention_mask(lengths, max_length) -> [B, T]`
|
| 28 |
+
- `samples_to_feature_frames(num_samples) -> [B]`
|
| 29 |
+
- `feature_frames_to_seld_frames(num_feature_frames) -> [B]`
|
| 30 |
+
- `seld_frames_to_spatial_tokens(num_seld_frames) -> [B]`
|
| 31 |
+
- `samples_to_spatial_length_bundle(num_samples) -> Seld233LengthBundle`
|
| 32 |
+
|
| 33 |
+
### `qwen2_5_omni_spur/modules/seldnet233_feature_bridge.py`
|
| 34 |
+
Online feature bridge scaffold.
|
| 35 |
+
|
| 36 |
+
Input:
|
| 37 |
+
- `spatial_audio`: `[B, T_audio, 4]`
|
| 38 |
+
- `spatial_audio_attention_mask`: `[B, T_audio]`
|
| 39 |
+
- `spatial_audio_lengths`: `[B]`
|
| 40 |
+
|
| 41 |
+
Expected output:
|
| 42 |
+
- `features`: `[B, 7, T_feat_max, 64]`
|
| 43 |
+
- `feature_attention_mask`: `[B, T_feat_max]`
|
| 44 |
+
- `feature_lengths`: `[B]`
|
| 45 |
+
|
| 46 |
+
Current status:
|
| 47 |
+
- input validation implemented
|
| 48 |
+
- length bookkeeping implemented
|
| 49 |
+
- baseline-aligned STFT / mel / intensity-vector extraction implemented
|
| 50 |
+
- baseline `foa_wts` normalization implemented
|
| 51 |
+
|
| 52 |
+
### `qwen2_5_omni_spur/modules/seldnet233_backbone.py`
|
| 53 |
+
SELD backbone scaffold.
|
| 54 |
+
|
| 55 |
+
Input:
|
| 56 |
+
- `seld233_features`: `[B, 7, T_feat_max, 64]`
|
| 57 |
+
- `seld233_feature_attention_mask`: `[B, T_feat_max]`
|
| 58 |
+
- `seld233_feature_lengths`: `[B]`
|
| 59 |
+
|
| 60 |
+
Expected output:
|
| 61 |
+
- `hidden_states`: `[B, T_seld_max, 128]`
|
| 62 |
+
- `hidden_attention_mask`: `[B, T_seld_max]`
|
| 63 |
+
- `hidden_lengths`: `[B]`
|
| 64 |
+
|
| 65 |
+
Current status:
|
| 66 |
+
- input validation implemented
|
| 67 |
+
- feature-to-SELD length mapping implemented
|
| 68 |
+
- dynamic baseline loading implemented
|
| 69 |
+
- checkpoint restore implemented
|
| 70 |
+
- last-MHSA hidden capture implemented
|
| 71 |
+
|
| 72 |
+
### `qwen2_5_omni_spur/modules/spatial_token_projector.py`
|
| 73 |
+
Implemented MLP projector.
|
| 74 |
+
|
| 75 |
+
Input:
|
| 76 |
+
- `spatial_tokens`: `[B, T_spat, D_in]`
|
| 77 |
+
|
| 78 |
+
Output:
|
| 79 |
+
- projected tokens: `[B, T_spat, D_out]`
|
| 80 |
+
|
| 81 |
+
### `qwen2_5_omni_spur/modules/seldnet233_spatial_adapter.py`
|
| 82 |
+
Implemented low-rate token adapter around the bridge/backbone.
|
| 83 |
+
|
| 84 |
+
Supported input modes:
|
| 85 |
+
1. `spatial_audio`
|
| 86 |
+
2. `seld233_features`
|
| 87 |
+
3. `seld233_hidden_states`
|
| 88 |
+
|
| 89 |
+
Main output:
|
| 90 |
+
- `spatial_tokens`: `[B, T_spat_max, 256]`
|
| 91 |
+
- `spatial_token_attention_mask`: `[B, T_spat_max]`
|
| 92 |
+
- `spatial_token_lengths`: `[B]`
|
| 93 |
+
|
| 94 |
+
Implemented:
|
| 95 |
+
- mode routing
|
| 96 |
+
- hidden-state downsampling from `10 Hz` to `2.5 Hz`
|
| 97 |
+
- token MLP head
|
| 98 |
+
- upstream `spatial_audio -> features -> hidden_states` path is now implemented
|
| 99 |
+
|
| 100 |
+
### `qwen2_5_omni_spur/processing_qwen2_5_omni_spatial.py`
|
| 101 |
+
New processor subclass: `Qwen2_5OmniSpatialProcessor`
|
| 102 |
+
|
| 103 |
+
What it does:
|
| 104 |
+
1. accepts mono or FOA audio and normalizes it to `[C, T_audio]`
|
| 105 |
+
2. truncates every sample to `0-20s`, with explicit warnings on clipping
|
| 106 |
+
3. rejects mixed `mono + FOA` batches up front
|
| 107 |
+
4. keeps the original audio path aligned to the same clipped window
|
| 108 |
+
5. normalizes prompt aliases by converting `<|audio|>` to the canonical
|
| 109 |
+
tokenizer token `<|AUDIO|>`
|
| 110 |
+
6. for FOA samples only, creates:
|
| 111 |
+
- `spatial_audio`: `[B, 320000, 4]`
|
| 112 |
+
- `spatial_audio_attention_mask`: `[B, 320000]`
|
| 113 |
+
- `spatial_audio_lengths`: `[B]`
|
| 114 |
+
- `spatial_token_lengths`: `[B]`
|
| 115 |
+
7. supports explicit processor-side spatial inputs:
|
| 116 |
+
- `spatial_tokens`
|
| 117 |
+
- `seld233_features`
|
| 118 |
+
- `seld233_feature_attention_mask`
|
| 119 |
+
- `seld233_feature_lengths`
|
| 120 |
+
- `spatial_token_lengths` only as a companion to `spatial_tokens` or
|
| 121 |
+
`seld233_features`, never as a standalone field
|
| 122 |
+
8. validates prompt constraints:
|
| 123 |
+
- every sample must contain exactly one `<|AUDIO|>`
|
| 124 |
+
- FOA samples must contain exactly one `<|spatial|>`
|
| 125 |
+
- mono samples must contain zero `<|spatial|>`
|
| 126 |
+
9. expands one `<|spatial|>` placeholder into repeated `<|spatial|>` tokens
|
| 127 |
+
10. delegates normal audio / image / video handling to the base processor
|
| 128 |
+
|
| 129 |
+
Current status:
|
| 130 |
+
- fully wired for placeholder expansion, mono/FOA branching, tensor packaging,
|
| 131 |
+
and processor-side spatial fallback inputs
|
| 132 |
+
- registers `<|spatial|>` into the tokenizer
|
| 133 |
+
- exposes `sync_spatial_tokenizer_with_model(model)` to synchronize tokenizer
|
| 134 |
+
vocab growth with model embedding resize
|
| 135 |
+
|
| 136 |
+
### `qwen2_5_omni_spur/modeling_qwen2_5_omni_spatial.py`
|
| 137 |
+
New model subclasses:
|
| 138 |
+
- `Qwen2_5OmniSpatialThinkerForConditionalGeneration`
|
| 139 |
+
- `Qwen2_5OmniSpatialForConditionalGeneration`
|
| 140 |
+
|
| 141 |
+
Thinker behavior:
|
| 142 |
+
1. reuse original audio/image/video merge behavior
|
| 143 |
+
2. resolve `spatial_tokens` from:
|
| 144 |
+
- direct input, or
|
| 145 |
+
- spatial adapter
|
| 146 |
+
3. project tokens to LLM hidden size
|
| 147 |
+
4. pack only valid spatial rows across the batch
|
| 148 |
+
5. replace `<|spatial|>` positions using `masked_scatter`
|
| 149 |
+
|
| 150 |
+
Current status:
|
| 151 |
+
- precomputed `spatial_tokens` path is wired
|
| 152 |
+
- raw-audio / raw-feature path is wired up to the adapter
|
| 153 |
+
- variable-length `B>1` spatial-token injection is now packed correctly before
|
| 154 |
+
`masked_scatter`
|
| 155 |
+
- online feature bridge + SELD backbone internals are implemented
|
| 156 |
+
- RoPE now supports:
|
| 157 |
+
- `text + audio + spatial`
|
| 158 |
+
- `text + video + audio + spatial`
|
| 159 |
+
with fixed modal order `<|VIDEO|><|AUDIO|><|spatial|>` and
|
| 160 |
+
`use_audio_in_video=False`
|
| 161 |
+
- image + spatial remains unsupported
|
| 162 |
+
- `return_audio=True` with spatial currently raises `NotImplementedError`
|
| 163 |
+
|
| 164 |
+
## Minimal Config Fields Added
|
| 165 |
+
Added to `Qwen2_5OmniThinkerConfig`:
|
| 166 |
+
- `spatial_token_index`
|
| 167 |
+
- `use_seld233_spatial_modality`
|
| 168 |
+
- `seld233_checkpoint_path`
|
| 169 |
+
- `seld233_baseline_repo_path`
|
| 170 |
+
- `seld233_task_id`
|
| 171 |
+
- `seld233_feature_stats_dir`
|
| 172 |
+
- `seld233_num_feature_channels`
|
| 173 |
+
- `seld233_num_mel_bins`
|
| 174 |
+
- `seld233_encoder_dim`
|
| 175 |
+
- `seld233_token_dim`
|
| 176 |
+
- `seld233_token_rate_hz`
|
| 177 |
+
- `seld233_downsample_factor`
|
| 178 |
+
- `seld233_projector_hidden_dim`
|
| 179 |
+
- `seld233_freeze_backbone`
|
| 180 |
+
- `seld233_max_audio_seconds`
|
| 181 |
+
|
| 182 |
+
## Current Call Chain
|
| 183 |
+
For the intended text+FOA(+spatial) path:
|
| 184 |
+
|
| 185 |
+
1. `Qwen2_5OmniSpatialProcessor.__call__`
|
| 186 |
+
2. base processor handles original audio path
|
| 187 |
+
3. processor adds spatial tensors and expands `<|spatial|>`
|
| 188 |
+
4. `Qwen2_5OmniSpatialForConditionalGeneration.generate(...)`
|
| 189 |
+
5. `Qwen2_5OmniSpatialThinkerForConditionalGeneration.forward(...)`
|
| 190 |
+
6. thinker resolves spatial tokens
|
| 191 |
+
7. thinker projects spatial tokens, packs valid rows, and injects them into `inputs_embeds`
|
| 192 |
+
8. original thinker forward continues for text/audio merging
|
| 193 |
+
|
| 194 |
+
For the intended text+video+FOA+spatial path:
|
| 195 |
+
|
| 196 |
+
1. prompt order is fixed as `<|VIDEO|><|AUDIO|><|spatial|>`
|
| 197 |
+
2. processor validates the fixed modal order
|
| 198 |
+
3. base processor expands video and audio placeholders
|
| 199 |
+
4. spatial processor expands spatial placeholders
|
| 200 |
+
5. thinker injects spatial embeddings first
|
| 201 |
+
6. original QwenOmni thinker merges video and audio embeddings afterward
|
| 202 |
+
7. custom RoPE assigns positions by scanning the real `video -> audio -> spatial` token runs
|
| 203 |
+
|
| 204 |
+
Tokenizer/model synchronization:
|
| 205 |
+
1. instantiate `Qwen2_5OmniSpatialProcessor`
|
| 206 |
+
2. processor registers `<|spatial|>` into `tokenizer`
|
| 207 |
+
3. call `processor.sync_spatial_tokenizer_with_model(model)`
|
| 208 |
+
4. model updates `spatial_token_index` and resizes thinker embeddings
|
| 209 |
+
|
| 210 |
+
## Verification
|
| 211 |
+
- `python -m py_compile` passed for all newly added scaffold files.
|
| 212 |
+
- A local runtime shape test passed for the new spatial modules without
|
| 213 |
+
depending on `transformers`:
|
| 214 |
+
- `features`: `(3, 7, 1000, 64)`
|
| 215 |
+
- `hidden`: `(3, 200, 128)`
|
| 216 |
+
- `spatial`: `(3, 47, 256)`
|
| 217 |
+
- Full Qwen integration should still be validated in a target environment that
|
| 218 |
+
has `transformers`; see
|
| 219 |
+
[seld233_spatial_validation.md](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni/docs/seld233_spatial_validation.md).
|
| 220 |
+
|
| 221 |
+
## What Is Still Intentionally Missing
|
| 222 |
+
- image + spatial joint RoPE path
|
| 223 |
+
- talker-side audio output path when spatial modality is present
|
| 224 |
+
- `use_audio_in_video=True`
|
docs/seld233_validation.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SELD233 Spatial Validation
|
| 2 |
+
|
| 3 |
+
## Purpose
|
| 4 |
+
Validate the implemented `audio + spatial + text` path with a synthetic `B=3`
|
| 5 |
+
FOA batch whose waveform lengths differ per sample.
|
| 6 |
+
|
| 7 |
+
The validation script prints:
|
| 8 |
+
- processor outputs and placeholder expansion results
|
| 9 |
+
- `FOA -> 7ch` feature shapes
|
| 10 |
+
- SELD backbone hidden-state shapes
|
| 11 |
+
- `2.5 Hz` spatial-token shapes
|
| 12 |
+
- the final multimodal token tensor shape implied by the expanded prompt
|
| 13 |
+
|
| 14 |
+
If the full Qwen model is loaded, it also builds the actual multimodal
|
| 15 |
+
`inputs_embeds` tensor after audio and spatial injection.
|
| 16 |
+
|
| 17 |
+
## Script
|
| 18 |
+
- [validate_seld233_spatial_random_foa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni/scripts/validate_seld233_spatial_random_foa.py)
|
| 19 |
+
|
| 20 |
+
## Recommended Run
|
| 21 |
+
Shape-only validation without loading the full Qwen model:
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
python scripts/validate_seld233_spatial_random_foa.py \
|
| 25 |
+
--model-id /apdcephfs_cq10/share_1603164/user/schmittzhu/model/Qwen2.5-Omni-7B \
|
| 26 |
+
--baseline-repo-path /apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline \
|
| 27 |
+
--seld233-checkpoint-path /apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/3_1_dev_split0_multiaccdoa_foa_model.h5 \
|
| 28 |
+
--seld233-feature-stats-dir /apdcephfs_cq10/share_1603164/user/schmittzhu/data/seld_feat_label/starss23_plus_foa_16k_29cls
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
Full multimodal embedding construction on a single device:
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
python scripts/validate_seld233_spatial_random_foa.py \
|
| 35 |
+
--model-id /apdcephfs_cq10/share_1603164/user/schmittzhu/model/Qwen2.5-Omni-7B \
|
| 36 |
+
--baseline-repo-path /apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline \
|
| 37 |
+
--seld233-checkpoint-path /apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/3_1_dev_split0_multiaccdoa_foa_model.h5 \
|
| 38 |
+
--seld233-feature-stats-dir /apdcephfs_cq10/share_1603164/user/schmittzhu/data/seld_feat_label/starss23_plus_foa_16k_29cls \
|
| 39 |
+
--load-qwen-model \
|
| 40 |
+
--device cuda:0 \
|
| 41 |
+
--dtype bfloat16
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Expected Core Shapes
|
| 45 |
+
For 20-second padded inputs:
|
| 46 |
+
- `spatial_audio`: `[B, 320000, 4]`
|
| 47 |
+
- `features`: `[B, 7, 1000, 64]`
|
| 48 |
+
- `hidden_states`: `[B, 200, 128]`
|
| 49 |
+
- `spatial_tokens`: `[B, T_spat_max, 256]`
|
| 50 |
+
|
| 51 |
+
`T_spat_max` depends on the longest valid sample in the batch.
|
| 52 |
+
|
| 53 |
+
## Current Limits
|
| 54 |
+
- `use_audio_in_video=False` only
|
| 55 |
+
- `image + spatial` not implemented
|
| 56 |
+
- `return_audio=True` not implemented for the spatial subclass
|
docs/spatial_beats_design.md
ADDED
|
@@ -0,0 +1,511 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Spatial-BEATs 接入 SPUR Spatial QA 的设计说明
|
| 2 |
+
|
| 3 |
+
## 1. 目标
|
| 4 |
+
|
| 5 |
+
本文档整理如何将 `Spatial-BEATs` 接入当前的 SPUR/Qwen spatial QA 训练链路,替换现有 `SELD233 + spatial_adapter + spatial_projector` 的空间编码路径。
|
| 6 |
+
|
| 7 |
+
目标不是修改代码,而是先明确一套可落地的设计:
|
| 8 |
+
|
| 9 |
+
- 取 `Spatial-BEATs` 的哪一层作为 LLM 的空间 token 源
|
| 10 |
+
- projector/bridge 应该如何设计
|
| 11 |
+
- 如何映射到当前 [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py) 的训练模式
|
| 12 |
+
- 如何分阶段训练,尽量复用现有缓存、LoRA、resume、QA 数据集逻辑
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## 2. 当前 `train_spur_spatial_qa.py` 的关键逻辑
|
| 17 |
+
|
| 18 |
+
### 2.1 文本接口不是结构化 head,而是 spatial token 占位符
|
| 19 |
+
|
| 20 |
+
当前 collator 在 prompt 前缀里写入:
|
| 21 |
+
|
| 22 |
+
```text
|
| 23 |
+
<audio><spatial>
|
| 24 |
+
question...
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
对应逻辑见:
|
| 28 |
+
|
| 29 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L565)
|
| 30 |
+
|
| 31 |
+
也就是说,LLM 侧只知道有一串 `spatial_token` 要插入,并不要求这串 token 来自某个特定 encoder。
|
| 32 |
+
|
| 33 |
+
### 2.2 当前空间分支的三层结构
|
| 34 |
+
|
| 35 |
+
当前 Qwen spatial 路径可以抽象成:
|
| 36 |
+
|
| 37 |
+
1. `seld233_backbone`
|
| 38 |
+
2. `seld233_spatial_adapter`
|
| 39 |
+
3. `seld233_spatial_projector`
|
| 40 |
+
|
| 41 |
+
训练模式围绕这三块展开:
|
| 42 |
+
|
| 43 |
+
- `spatial_only`: 只训练 adapter + projector
|
| 44 |
+
- `adapter_lora`: 冻结空间 backbone,只训练 adapter + projector + LLM LoRA
|
| 45 |
+
- `spatial_lora`: 训练空间 backbone + adapter + projector + LLM LoRA
|
| 46 |
+
|
| 47 |
+
对应逻辑见:
|
| 48 |
+
|
| 49 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L1005)
|
| 50 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L1059)
|
| 51 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L1078)
|
| 52 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L1714)
|
| 53 |
+
|
| 54 |
+
### 2.3 当前缓存机制的抽象非常适合替换 encoder
|
| 55 |
+
|
| 56 |
+
collator 目前支持两种缓存输入:
|
| 57 |
+
|
| 58 |
+
1. feature cache
|
| 59 |
+
- `seld233_features`: `[B, C, T_feat, M]`
|
| 60 |
+
- 仍在线运行 backbone
|
| 61 |
+
|
| 62 |
+
2. hidden cache
|
| 63 |
+
- `seld233_hidden_states`: `[B, T_hidden, D]`
|
| 64 |
+
- 直接绕过 feature bridge + backbone
|
| 65 |
+
|
| 66 |
+
对应逻辑见:
|
| 67 |
+
|
| 68 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L630)
|
| 69 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L672)
|
| 70 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L1652)
|
| 71 |
+
|
| 72 |
+
这个抽象意味着:
|
| 73 |
+
|
| 74 |
+
- 如果 `Spatial-BEATs` 能输出 `[T_s, D]` 的时序 hidden states
|
| 75 |
+
- 那它可以直接替代现有 hidden cache 路径
|
| 76 |
+
|
| 77 |
+
这对工程落地非常有利。
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
## 3. `Spatial-BEATs` 当前最适合接 LLM 的层
|
| 82 |
+
|
| 83 |
+
### 3.1 不应直接用监督 head 输出
|
| 84 |
+
|
| 85 |
+
`Spatial-BEATs` 里存在多种监督读出:
|
| 86 |
+
|
| 87 |
+
- `slot_latents`
|
| 88 |
+
- `prediction_output`
|
| 89 |
+
- `mono_task_tokens`
|
| 90 |
+
- `mono_prediction_output`
|
| 91 |
+
- `pretrunk_task_tokens`
|
| 92 |
+
- `pretrunk_prediction_output`
|
| 93 |
+
|
| 94 |
+
这些都不适合直接喂给 LLM,原因是:
|
| 95 |
+
|
| 96 |
+
- 它们已经是任务特化后的 readout
|
| 97 |
+
- 信息被压缩进分类/方向/距离头
|
| 98 |
+
- 对 QA 这种开放式下游推理来说,保留的上下文冗余不足
|
| 99 |
+
|
| 100 |
+
### 3.2 推荐层:`fused_spatial_embeddings`
|
| 101 |
+
|
| 102 |
+
在 `readout_scheme='local_spatial'` 下,最推荐的 LLM 输入源是:
|
| 103 |
+
|
| 104 |
+
- `fused_spatial_embeddings`
|
| 105 |
+
|
| 106 |
+
对应逻辑:
|
| 107 |
+
|
| 108 |
+
- [spatial_beats.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/spatial_beats.py#L845)
|
| 109 |
+
- [spatial_beats.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/spatial_beats.py#L1092)
|
| 110 |
+
|
| 111 |
+
它的来源是:
|
| 112 |
+
|
| 113 |
+
1. `W` 通道经过原始 BEATs semantic path
|
| 114 |
+
2. `WXYZ + IVxyz` 经过 `local_spatial_encoder`
|
| 115 |
+
3. 两路在同一 token rate 上对齐
|
| 116 |
+
4. 经 `local_spatial_proj` 后加和融合
|
| 117 |
+
|
| 118 |
+
因此这层同时包含:
|
| 119 |
+
|
| 120 |
+
- 语义稳定性
|
| 121 |
+
- 局部空间 cues
|
| 122 |
+
- 时间结构
|
| 123 |
+
|
| 124 |
+
这是比单独 `spatial_embeddings` 更好的 LLM 输入层。
|
| 125 |
+
|
| 126 |
+
### 3.3 备选层:`spatial_embeddings`
|
| 127 |
+
|
| 128 |
+
如果初版想先降低复杂度,可以先接:
|
| 129 |
+
|
| 130 |
+
- `spatial_embeddings`
|
| 131 |
+
|
| 132 |
+
对应逻辑:
|
| 133 |
+
|
| 134 |
+
- [spatial_beats.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/spatial_beats.py#L736)
|
| 135 |
+
- [spatial_beats.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/spatial_beats.py#L985)
|
| 136 |
+
|
| 137 |
+
但在 `local_spatial` 路径下,它少了显式 local-spatial fusion,优先级低于 `fused_spatial_embeddings`。
|
| 138 |
+
|
| 139 |
+
### 3.4 token 数量建议保持低频时序接口
|
| 140 |
+
|
| 141 |
+
`Spatial-BEATs` 文档已经明确:
|
| 142 |
+
|
| 143 |
+
- 最终给 LLM 的应该是低频时序 token
|
| 144 |
+
- 不是 `time x slot`
|
| 145 |
+
- 默认接口为 `2.5 Hz`
|
| 146 |
+
|
| 147 |
+
对应说明:
|
| 148 |
+
|
| 149 |
+
- [spatial_beats_token_interface_note.md](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/docs/spatial_beats_token_interface_note.md#L32)
|
| 150 |
+
|
| 151 |
+
因此推荐的外部接口是:
|
| 152 |
+
|
| 153 |
+
- `10s -> 25 tokens`
|
| 154 |
+
- 形状:`[B, T_s, D]`
|
| 155 |
+
|
| 156 |
+
不要把内部 slot 数 `K` 展开成 `T_s * K` 个 LLM token。
|
| 157 |
+
|
| 158 |
+
---
|
| 159 |
+
|
| 160 |
+
## 4. 推荐的 bridge/projector 设计
|
| 161 |
+
|
| 162 |
+
### 4.1 当前 `Spatial-BEATs` 自带 projector
|
| 163 |
+
|
| 164 |
+
当前 projector 为:
|
| 165 |
+
|
| 166 |
+
- `Linear(D -> H)`
|
| 167 |
+
- `GELU`
|
| 168 |
+
- `LayerNorm(H)`
|
| 169 |
+
- `Linear(H -> d_llm)`
|
| 170 |
+
|
| 171 |
+
见:
|
| 172 |
+
|
| 173 |
+
- [spatial_modules.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/spatial_modules.py#L1159)
|
| 174 |
+
|
| 175 |
+
这作为第一版是合理的,但它是“纯 token-wise MLP”,没有显式时间建模。
|
| 176 |
+
|
| 177 |
+
### 4.2 推荐:LLM bridge 版 projector
|
| 178 |
+
|
| 179 |
+
针对 QA 下游,推荐的 bridge 设计不是只做线性升维,而是:
|
| 180 |
+
|
| 181 |
+
```text
|
| 182 |
+
fused_spatial_embeddings [B, T_s, D]
|
| 183 |
+
-> LayerNorm
|
| 184 |
+
-> temporal bridge block
|
| 185 |
+
-> token projector MLP
|
| 186 |
+
-> llm_spatial_tokens [B, T_s, d_llm]
|
| 187 |
+
```
|
| 188 |
+
|
| 189 |
+
其中:
|
| 190 |
+
|
| 191 |
+
#### 1. temporal bridge block
|
| 192 |
+
|
| 193 |
+
建议用轻量模块,1 层即可:
|
| 194 |
+
|
| 195 |
+
- 1-layer TransformerEncoder
|
| 196 |
+
或
|
| 197 |
+
- gated MLP / temporal Conv1d block
|
| 198 |
+
|
| 199 |
+
目的:
|
| 200 |
+
|
| 201 |
+
- 在进入 LLM 前,对低频空间 token 再做一次跨时间整形
|
| 202 |
+
- 补偿 projector 完全逐 token 独立的缺陷
|
| 203 |
+
|
| 204 |
+
推荐输入输出维度不变:
|
| 205 |
+
|
| 206 |
+
- `D = 768`
|
| 207 |
+
|
| 208 |
+
#### 2. token projector MLP
|
| 209 |
+
|
| 210 |
+
建议结构:
|
| 211 |
+
|
| 212 |
+
```text
|
| 213 |
+
LayerNorm(768)
|
| 214 |
+
Linear(768, 1536)
|
| 215 |
+
GELU
|
| 216 |
+
Linear(1536, 4096)
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
如果想更稳,可以再加:
|
| 220 |
+
|
| 221 |
+
- `LayerNorm(4096)`
|
| 222 |
+
或
|
| 223 |
+
- 一个可学习 gate
|
| 224 |
+
|
| 225 |
+
例如:
|
| 226 |
+
|
| 227 |
+
```text
|
| 228 |
+
proj = MLP(x)
|
| 229 |
+
gate = sigmoid(W_g x)
|
| 230 |
+
llm_tokens = gate * proj
|
| 231 |
+
```
|
| 232 |
+
|
| 233 |
+
但第一版不必上 gate。
|
| 234 |
+
|
| 235 |
+
### 4.3 为什么不建议直接投分类/角度/距离结果
|
| 236 |
+
|
| 237 |
+
不建议将这些 head 输出拼成 LLM 输入:
|
| 238 |
+
|
| 239 |
+
- `pred_class_logits`
|
| 240 |
+
- `pred_direction`
|
| 241 |
+
- `pred_distance`
|
| 242 |
+
|
| 243 |
+
原因:
|
| 244 |
+
|
| 245 |
+
- 这些已经是强任务约束后的压缩表示
|
| 246 |
+
- 会丢掉很多时序上下文和不确定性信息
|
| 247 |
+
- LLM 更适合消费 dense latent,而不是 encoder 的最终判决
|
| 248 |
+
|
| 249 |
+
这些输出可以作为:
|
| 250 |
+
|
| 251 |
+
- 训练时的 auxiliary supervision
|
| 252 |
+
- 或后续做解释性 probing
|
| 253 |
+
|
| 254 |
+
但不应作为主 token 接口。
|
| 255 |
+
|
| 256 |
+
---
|
| 257 |
+
|
| 258 |
+
## 5. 与当前 `train_spur_spatial_qa.py` 的映射设计
|
| 259 |
+
|
| 260 |
+
### 5.1 模块映射
|
| 261 |
+
|
| 262 |
+
建议把当前 `SELD233` 路径替换为:
|
| 263 |
+
|
| 264 |
+
```text
|
| 265 |
+
seld233_backbone -> spatial_beats_backbone
|
| 266 |
+
seld233_spatial_adapter -> spatial_beats_bridge
|
| 267 |
+
seld233_spatial_projector -> spatial_beats_llm_projector
|
| 268 |
+
```
|
| 269 |
+
|
| 270 |
+
更具体地说:
|
| 271 |
+
|
| 272 |
+
#### `spatial_beats_backbone`
|
| 273 |
+
|
| 274 |
+
包含:
|
| 275 |
+
|
| 276 |
+
- preprocessor
|
| 277 |
+
- BEATs trunk
|
| 278 |
+
- local_spatial_encoder
|
| 279 |
+
- local_spatial_proj
|
| 280 |
+
- local_spatial_fusion_norm
|
| 281 |
+
|
| 282 |
+
输出:
|
| 283 |
+
|
| 284 |
+
- `fused_spatial_embeddings`
|
| 285 |
+
- `temporal_padding_mask`
|
| 286 |
+
|
| 287 |
+
#### `spatial_beats_bridge`
|
| 288 |
+
|
| 289 |
+
新增的一层轻量 temporal bridge:
|
| 290 |
+
|
| 291 |
+
- 1-layer temporal adapter
|
| 292 |
+
- 输入输出都为 `768`
|
| 293 |
+
|
| 294 |
+
这是新设计里最关键的“LLM bridge”部分。
|
| 295 |
+
|
| 296 |
+
#### `spatial_beats_llm_projector`
|
| 297 |
+
|
| 298 |
+
将 bridge 后的 token 投到 LLM hidden size:
|
| 299 |
+
|
| 300 |
+
- `768 -> 1536 -> 4096`
|
| 301 |
+
|
| 302 |
+
输出:
|
| 303 |
+
|
| 304 |
+
- `[B, T_s, d_llm]`
|
| 305 |
+
|
| 306 |
+
### 5.2 对应当前两种 cache 语义
|
| 307 |
+
|
| 308 |
+
推荐保留当前 cache 设计思路,但改名语义如下:
|
| 309 |
+
|
| 310 |
+
#### feature cache
|
| 311 |
+
|
| 312 |
+
缓存 `Spatial-BEATs` 前端中间结果,例如:
|
| 313 |
+
|
| 314 |
+
- `foa_feat`
|
| 315 |
+
- 或 patch/token 级中间特征
|
| 316 |
+
|
| 317 |
+
只在你想继续训练 backbone 时使用。
|
| 318 |
+
|
| 319 |
+
#### hidden cache
|
| 320 |
+
|
| 321 |
+
缓存:
|
| 322 |
+
|
| 323 |
+
- `fused_spatial_embeddings`
|
| 324 |
+
或
|
| 325 |
+
- `bridge` 之前的 `[T_s, 768]`
|
| 326 |
+
|
| 327 |
+
这是最有用的 cache 形式。
|
| 328 |
+
|
| 329 |
+
它对应当前 `train_spur_spatial_qa.py` 的 hidden-cache 路线:
|
| 330 |
+
|
| 331 |
+
- 在线不跑空间 backbone
|
| 332 |
+
- 只训练 bridge/projector/LLM
|
| 333 |
+
|
| 334 |
+
对于 QA 阶段,这会是最实用的加速方案。
|
| 335 |
+
|
| 336 |
+
---
|
| 337 |
+
|
| 338 |
+
## 6. 推荐训练阶段
|
| 339 |
+
|
| 340 |
+
### 阶段 A:encoder-only 预训练
|
| 341 |
+
|
| 342 |
+
目标:
|
| 343 |
+
|
| 344 |
+
- 在 `Spatial-BEATs` 自己的监督任务上训出靠谱的 `fused_spatial_embeddings`
|
| 345 |
+
|
| 346 |
+
推荐 checkpoint:
|
| 347 |
+
|
| 348 |
+
- `ov1_local_spatial` 最优 checkpoint
|
| 349 |
+
- 更理想是其 balanced follow-up checkpoint
|
| 350 |
+
|
| 351 |
+
此阶段不接 LLM。
|
| 352 |
+
|
| 353 |
+
### 阶段 B:freeze Spatial-BEATs,训练 bridge + LLM LoRA
|
| 354 |
+
|
| 355 |
+
这是最推荐的第一轮接入实验。
|
| 356 |
+
|
| 357 |
+
训练参数对应当前 QA 框架可映射为:
|
| 358 |
+
|
| 359 |
+
- 冻结 `spatial_beats_backbone`
|
| 360 |
+
- 训练 `spatial_beats_bridge`
|
| 361 |
+
- 训练 `spatial_beats_llm_projector`
|
| 362 |
+
- 训练 `LLM LoRA`
|
| 363 |
+
|
| 364 |
+
它在当前 `train_spur_spatial_qa.py` 中最接近:
|
| 365 |
+
|
| 366 |
+
- `--train-adapter-lora`
|
| 367 |
+
|
| 368 |
+
只是把现有的 `seld233_spatial_adapter + seld233_spatial_projector`
|
| 369 |
+
替换成 `spatial_beats_bridge + spatial_beats_llm_projector`。
|
| 370 |
+
|
| 371 |
+
这是最值得先做的实验,因为:
|
| 372 |
+
|
| 373 |
+
- encoder 先不动,稳定
|
| 374 |
+
- 速度快
|
| 375 |
+
- 容易判断 `Spatial-BEATs` token 是否比 DCASE encoder 更有用
|
| 376 |
+
|
| 377 |
+
### 阶段 C:解冻 Spatial-BEATs 尾部,小学习率联合微调
|
| 378 |
+
|
| 379 |
+
当阶段 B 证明 token 有效后,再解冻少量模块:
|
| 380 |
+
|
| 381 |
+
- `local_spatial_proj`
|
| 382 |
+
- `local_spatial_fusion_norm`
|
| 383 |
+
- 可选 `local_spatial_encoder` 最后一层
|
| 384 |
+
- 可选 BEATs trunk 最后 1-2 层
|
| 385 |
+
|
| 386 |
+
训练对象:
|
| 387 |
+
|
| 388 |
+
- Spatial-BEATs 尾部
|
| 389 |
+
- bridge
|
| 390 |
+
- projector
|
| 391 |
+
- LLM LoRA
|
| 392 |
+
|
| 393 |
+
它在当前 QA 框架中最接近:
|
| 394 |
+
|
| 395 |
+
- `--train-spatial-lora`
|
| 396 |
+
|
| 397 |
+
但不建议一开始就这样做,因为会把“encoder 不好”与“LLM 对不上”混在一起。
|
| 398 |
+
|
| 399 |
+
### 阶段 D:hidden-cache 加速 QA 训练
|
| 400 |
+
|
| 401 |
+
当阶段 B/C 结构稳定后,推荐预先导出:
|
| 402 |
+
|
| 403 |
+
- `fused_spatial_embeddings`
|
| 404 |
+
- `temporal_padding_mask`
|
| 405 |
+
|
| 406 |
+
作为 hidden cache。
|
| 407 |
+
|
| 408 |
+
然后 QA 训练使用 hidden cache,避免每次在线跑 Spatial-BEATs。
|
| 409 |
+
|
| 410 |
+
这对应当前脚本里的 hidden cache 模式:
|
| 411 |
+
|
| 412 |
+
- [train_spur_spatial_qa.py](/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/train_spur_spatial_qa.py#L630)
|
| 413 |
+
|
| 414 |
+
---
|
| 415 |
+
|
| 416 |
+
## 7. 推荐的第一版落地方案
|
| 417 |
+
|
| 418 |
+
如果只做第一版、最小风险接入,建议如下:
|
| 419 |
+
|
| 420 |
+
### 7.1 encoder 输出
|
| 421 |
+
|
| 422 |
+
从 `Spatial-BEATsOutput` 里读取:
|
| 423 |
+
|
| 424 |
+
- 首选 `fused_spatial_embeddings`
|
| 425 |
+
- fallback `spatial_embeddings`
|
| 426 |
+
|
| 427 |
+
同时读取:
|
| 428 |
+
|
| 429 |
+
- `temporal_padding_mask`
|
| 430 |
+
|
| 431 |
+
### 7.2 bridge/projector
|
| 432 |
+
|
| 433 |
+
使用:
|
| 434 |
+
|
| 435 |
+
```text
|
| 436 |
+
fused_spatial_embeddings [B, T_s, 768]
|
| 437 |
+
-> LayerNorm
|
| 438 |
+
-> 1-layer TransformerEncoder (768)
|
| 439 |
+
-> LayerNorm
|
| 440 |
+
-> Linear(768, 1536)
|
| 441 |
+
-> GELU
|
| 442 |
+
-> Linear(1536, 4096)
|
| 443 |
+
```
|
| 444 |
+
|
| 445 |
+
输出:
|
| 446 |
+
|
| 447 |
+
- `llm_spatial_tokens [B, T_s, 4096]`
|
| 448 |
+
|
| 449 |
+
### 7.3 QA 训练策略
|
| 450 |
+
|
| 451 |
+
第一轮只做:
|
| 452 |
+
|
| 453 |
+
- freeze Spatial-BEATs backbone
|
| 454 |
+
- train bridge
|
| 455 |
+
- train projector
|
| 456 |
+
- train LLM LoRA
|
| 457 |
+
|
| 458 |
+
也就是概念上对应当前的:
|
| 459 |
+
|
| 460 |
+
- `adapter_lora`
|
| 461 |
+
|
| 462 |
+
### 7.4 不建议第一版就做的事
|
| 463 |
+
|
| 464 |
+
以下都不建议第一版就做:
|
| 465 |
+
|
| 466 |
+
- 用 slot 输出替代 dense latent
|
| 467 |
+
- 同时训练 Spatial-BEATs 全 backbone
|
| 468 |
+
- 同时改 QA prompt 设计
|
| 469 |
+
- 把分类/角度/距离 head 输出直接拼进 LLM token
|
| 470 |
+
|
| 471 |
+
这些会大幅增加排障复杂度。
|
| 472 |
+
|
| 473 |
+
---
|
| 474 |
+
|
| 475 |
+
## 8. 为什么这条路线比当前 DCASE encoder 更合理
|
| 476 |
+
|
| 477 |
+
当前 DCASE spatial encoder 路径的问题是:
|
| 478 |
+
|
| 479 |
+
- 更偏任务 readout
|
| 480 |
+
- 对 QA 来说 token 表征容量不足
|
| 481 |
+
- 数值空间信息学得不稳
|
| 482 |
+
|
| 483 |
+
而 `Spatial-BEATs local_spatial` 路径的优势是:
|
| 484 |
+
|
| 485 |
+
1. 有明确的低频时序 token 接口
|
| 486 |
+
2. `fused_spatial_embeddings` 本身就是为“投给 LLM”准备的 dense latent
|
| 487 |
+
3. semantic path 与 local spatial path 分工清晰
|
| 488 |
+
4. 已经有 projector 抽象和 token interface 文档
|
| 489 |
+
|
| 490 |
+
换句话说,`Spatial-BEATs` 的结构天然更像一个可插拔的独立 spatial encoder,而不是一个“SELD head 顺便挤出 token”。
|
| 491 |
+
|
| 492 |
+
---
|
| 493 |
+
|
| 494 |
+
## 9. 建议的下一步
|
| 495 |
+
|
| 496 |
+
建议按下面顺序推进:
|
| 497 |
+
|
| 498 |
+
1. 先实现 `Spatial-BEATs -> fused_spatial_embeddings -> bridge -> projector -> LLM spatial tokens`
|
| 499 |
+
2. 第一轮只做 freeze encoder + bridge/projector + LLM LoRA
|
| 500 |
+
3. 验证 QA 上是否比当前 DCASE spatial encoder 明显更好
|
| 501 |
+
4. 如果有效,再做尾部联合微调
|
| 502 |
+
5. 最后再做 hidden-cache 预计算优化
|
| 503 |
+
|
| 504 |
+
这样可以把风险拆开:
|
| 505 |
+
|
| 506 |
+
- encoder token 是否有效
|
| 507 |
+
- bridge 是否够用
|
| 508 |
+
- LLM 是否能消费这组 token
|
| 509 |
+
|
| 510 |
+
而不是把三个问题同时耦合起来。
|
| 511 |
+
|
docs/spatial_encoder_plan.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SELDNet-233 Spatial Modality Integration Design
|
| 2 |
+
## Document Status
|
| 3 |
+
- Owner: Student Implementation
|
| 4 |
+
- Reviewer: Project Maintainer
|
| 5 |
+
- Target Repository: `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni`
|
| 6 |
+
- Related Baseline Repository: `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline`
|
| 7 |
+
|
| 8 |
+
## 1. Background
|
| 9 |
+
This project aims to extend the current `Qwen2.5-Omni`-based system with a new **independent spatial modality** derived from a pretrained `SELDNet` encoder.
|
| 10 |
+
The current system already supports:
|
| 11 |
+
- text
|
| 12 |
+
- image
|
| 13 |
+
- video
|
| 14 |
+
The current SPUR-related spatial path in the Omni codebase is not a truly independent modality. Instead, it computes spatial features and fuses them back into the audio encoder branch. This is
|
| 15 |
+
**not** the desired design for this project.
|
| 16 |
+
|
| 17 |
+
- keep the **original audio encoder unchanged**
|
| 18 |
+
- use the same FOA input audio in **two parallel paths**
|
| 19 |
+
- inject a new set of **spatial tokens** into the LLM as a separate modality
|
| 20 |
+
## 2. Objective
|
| 21 |
+
Given a 4-channel FOA audio input:
|
| 22 |
+
1. The **W channel** should continue to go through the original Omni mono audio pipeline.
|
| 23 |
+
2. The full **4-channel FOA** should go through a pretrained `SELDNet-233` encoder.
|
| 24 |
+
3. The `SELDNet-233` encoder should provide a sequence of **spatial tokens** derived from its **MHSA output**, not from its final localization/classification heads.
|
| 25 |
+
4. These spatial tokens should be projected into the LLM hidden space and injected into the thinker decoder input as a new modality `<|spatial|>`.
|
| 26 |
+
|
| 27 |
+
## 3. Non-Goals
|
| 28 |
+
- modify the existing SELD baseline source code
|
| 29 |
+
- modify existing SELD training or inference behavior
|
| 30 |
+
- use SELDNet final `accdoa` or `sed_logits` as the LLM input representation
|
| 31 |
+
|
| 32 |
+
## 4. Fixed Dependencies
|
| 33 |
+
- Path: `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline`
|
| 34 |
+
|
| 35 |
+
### 4.2 SELD checkpoint to use
|
| 36 |
+
|
| 37 |
+
### 4.3 SELD task configuration
|
| 38 |
+
- Task ID: `233`
|
| 39 |
+
|
| 40 |
+
### 4.4 SELD model definition
|
| 41 |
+
|
| 42 |
+
## 5. Key Design Decision
|
| 43 |
+
|
| 44 |
+
### 5.1 Spatial representation source
|
| 45 |
+
The spatial representation must come from the **shared temporal representation after the final MHSA block** in `SELDNet`, not from:
|
| 46 |
+
- final `accdoa`
|
| 47 |
+
- final `sed_logits`
|
| 48 |
+
- explicit detection heads
|
| 49 |
+
|
| 50 |
+
### 5.2 Why this representation
|
| 51 |
+
This tensor is:
|
| 52 |
+
- temporally ordered
|
| 53 |
+
- dense
|
| 54 |
+
- scene-level
|
| 55 |
+
- richer than detection output heads
|
| 56 |
+
- better suited for LLM conditioning
|
| 57 |
+
|
| 58 |
+
## 6. Target Architecture
|
| 59 |
+
|
| 60 |
+
### 6.1 Input
|
| 61 |
+
|
| 62 |
+
### 6.2 Dual-path processing
|
| 63 |
+
- take FOA `W channel`
|
| 64 |
+
- convert to mono
|
| 65 |
+
- feed into original Omni audio encoder
|
| 66 |
+
- keep existing tokenization rate unchanged
|
| 67 |
+
- expected token rate: about `25 Hz`
|
| 68 |
+
Path B: New spatial path
|
| 69 |
+
- keep all 4 FOA channels
|
| 70 |
+
- convert to SELD baseline-compatible input features
|
| 71 |
+
- feed into pretrained `SELDNet-233`
|
| 72 |
+
- produce spatial token sequence
|
| 73 |
+
- project into LLM hidden size
|
| 74 |
+
- inject as `<|spatial|>` modality
|
| 75 |
+
### 6.3 Final LLM view
|
| 76 |
+
- normal text tokens
|
| 77 |
+
- normal audio tokens from original audio encoder
|
| 78 |
+
- optional image/video tokens
|
| 79 |
+
- new spatial tokens from SELDNet-233 branch
|
| 80 |
+
|
| 81 |
+
## 7. Temporal Resolution Requirements
|
| 82 |
+
|
| 83 |
+
### 7.1 Audio token frequency
|
| 84 |
+
Keep current Omni audio token frequency unchanged:
|
| 85 |
+
- approximately `25 Hz`
|
| 86 |
+
|
| 87 |
+
### 7.2 Spatial token frequency
|
| 88 |
+
Spatial tokens should be lower frequency:
|
| 89 |
+
- target `2.5 Hz`
|
| 90 |
+
|
| 91 |
+
This is intentional because:
|
| 92 |
+
- lower token rate reduces prompt length
|
| 93 |
+
- lower token rate is sufficient for spatial reasoning
|
| 94 |
+
Recommended first version:
|
| 95 |
+
- `h_seld`: `[B, T_seld, 128]`
|
| 96 |
+
- `spatial_tokens`: `[B, T_spat, 256]`
|
| 97 |
+
- `projected_spatial`: `[B, T_spat, D_llm]`
|
| 98 |
+
|
| 99 |
+
Where:
|
| 100 |
+
- `T_spat = 5 * seconds`
|
| 101 |
+
|
| 102 |
+
## 8. Data Flow
|
| 103 |
+
|
| 104 |
+
1. Input FOA waveform enters processor.
|
| 105 |
+
2. Processor keeps original audio path intact:
|
| 106 |
+
- use `W channel` for original audio encoder.
|
| 107 |
+
3. Processor also passes full FOA waveform as `spatial_audio`.
|
| 108 |
+
- `spatial_audio` for new spatial path
|
| 109 |
+
5. New SELD spatial adapter computes:
|
| 110 |
+
- SELD MHSA output
|
| 111 |
+
- `2.5 Hz` spatial tokens
|
| 112 |
+
6. Spatial projector maps tokens to LLM hidden dimension.
|
| 113 |
+
8. Thinker injects projected spatial embeddings into `inputs_embeds`.
|
| 114 |
+
9. LLM decoder consumes them as a true multimodal prefix.
|
| 115 |
+
|
| 116 |
+
## 9. Required Code Work
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
### A. `qwen2_5_omni_spur/modules/seldnet233_backbone.py`
|
| 120 |
+
Purpose:
|
| 121 |
+
- build baseline `SeldModel` with task `233`
|
| 122 |
+
- load pretrained checkpoint
|
| 123 |
+
- freeze model by default
|
| 124 |
+
- register a forward hook on the final MHSA output
|
| 125 |
+
|
| 126 |
+
Expected behavior:
|
| 127 |
+
- input: baseline-compatible SELD features
|
| 128 |
+
- output: `h_seld [B, T_seld, D_seld]`
|
| 129 |
+
|
| 130 |
+
- do not modify baseline code
|
| 131 |
+
- use import-time wrapping or dynamic module loading
|
| 132 |
+
- use forward hook on the last MHSA normalization output
|
| 133 |
+
|
| 134 |
+
### B. `qwen2_5_omni_spur/modules/seldnet233_feature_bridge.py`
|
| 135 |
+
Purpose:
|
| 136 |
+
- convert FOA waveform into the feature representation expected by SELD task `233`
|
| 137 |
+
|
| 138 |
+
Expected behavior:
|
| 139 |
+
- output: baseline feature tensor `[B, C, T_feat, F_feat]`
|
| 140 |
+
|
| 141 |
+
Implementation notes:
|
| 142 |
+
- must match SELD task `233` feature config exactly
|
| 143 |
+
- sample rate must be `16k`
|
| 144 |
+
- should reuse baseline feature logic where possible
|
| 145 |
+
|
| 146 |
+
Purpose:
|
| 147 |
+
- build a full SELD-based spatial token extractor
|
| 148 |
+
|
| 149 |
+
Internal structure:
|
| 150 |
+
- feature bridge
|
| 151 |
+
- SELD backbone
|
| 152 |
+
- spatial token head
|
| 153 |
+
|
| 154 |
+
Expected behavior:
|
| 155 |
+
- output:
|
| 156 |
+
- `spatial_tokens [B, T_spat, D_spat]`
|
| 157 |
+
|
| 158 |
+
Implementation notes:
|
| 159 |
+
- token rate target must be `2.5 Hz`
|
| 160 |
+
- default token dim should be `256`
|
| 161 |
+
- token head may use:
|
| 162 |
+
- pooling
|
| 163 |
+
- MLP
|
| 164 |
+
- recommended first implementation:
|
| 165 |
+
|
| 166 |
+
### D. Optional: `qwen2_5_omni_spur/modules/spatial_token_projector.py`
|
| 167 |
+
Purpose:
|
| 168 |
+
- project SELD spatial tokens into LLM hidden dimension
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
## 9.2 Existing files to modify
|
| 172 |
+
### A. `qwen2_5_omni_spur/configuration_qwen2_5_omni.py`
|
| 173 |
+
Add config fields:
|
| 174 |
+
- `spatial_token_index`
|
| 175 |
+
- `use_seld233_spatial_modality`
|
| 176 |
+
- `seld233_checkpoint_path`
|
| 177 |
+
- `seld233_token_dim`
|
| 178 |
+
- `seld233_token_rate_hz`
|
| 179 |
+
- `seld233_projector_hidden_dim`
|
| 180 |
+
- optional `seld233_freeze_backbone`
|
| 181 |
+
|
| 182 |
+
- `attribute_map` to include `spatial_token_id`
|
| 183 |
+
|
| 184 |
+
### B. `qwen2_5_omni_spur/modules/__init__.py`
|
| 185 |
+
Export new modules:
|
| 186 |
+
- `SeldNet233Backbone`
|
| 187 |
+
- optional new projector class
|
| 188 |
+
|
| 189 |
+
### C. `qwen2_5_omni_spur/processing_qwen2_5_omni.py`
|
| 190 |
+
Add a new special token:
|
| 191 |
+
- `<|spatial|>`
|
| 192 |
+
|
| 193 |
+
- store `self.spatial_token`
|
| 194 |
+
- optionally accept `spatial_tokens` and `spatial_token_lengths`
|
| 195 |
+
- expand `<|spatial|>` into repeated placeholders based on spatial token length
|
| 196 |
+
- expose spatial fields through `model_input_names`
|
| 197 |
+
Important constraint:
|
| 198 |
+
- original W-channel mono audio path must remain unchanged
|
| 199 |
+
### D. `qwen2_5_omni_spur/modeling_qwen2_5_omni.py`
|
| 200 |
+
Required changes:
|
| 201 |
+
- instantiate SELD spatial adapter in thinker
|
| 202 |
+
- accept `spatial_audio` in thinker forward
|
| 203 |
+
- compute spatial embeddings
|
| 204 |
+
- inject them via `masked_scatter`
|
| 205 |
+
- update multimodal rope logic
|
| 206 |
+
- route spatial fields through generation
|
| 207 |
+
### E. `training-qwen-omni/train_spur_spatial_only_hf.py`
|
| 208 |
+
Update collator:
|
| 209 |
+
- additionally pass full FOA as `spatial_audio`
|
| 210 |
+
|
| 211 |
+
### F. `qwen-omni-inference.py`
|
| 212 |
+
Update inference script:
|
| 213 |
+
- register `<|spatial|>` token
|
| 214 |
+
- construct prompt with spatial placeholder
|
| 215 |
+
- validate both paths run together
|
| 216 |
+
|
| 217 |
+
## 10. Processor Design
|
| 218 |
+
|
| 219 |
+
### 10.1 Prompt convention
|
| 220 |
+
- `<|spatial|>`
|
| 221 |
+
|
| 222 |
+
Example:
|
| 223 |
+
- `<|AUDIO|><|spatial|> Please answer the question using both sound content and spatial cues.`
|
| 224 |
+
|
| 225 |
+
### 10.2 Placeholder expansion behavior
|
| 226 |
+
- `T_spat` repeated spatial token positions
|
| 227 |
+
|
| 228 |
+
This mirrors current audio/image/video placeholder logic.
|
| 229 |
+
|
| 230 |
+
### 10.3 Recommended input mode
|
| 231 |
+
- processor receives `spatial_audio`
|
| 232 |
+
|
| 233 |
+
Fallback mode:
|
| 234 |
+
- processor receives precomputed `spatial_tokens`
|
| 235 |
+
|
| 236 |
+
## 11. SELD Path Design
|
| 237 |
+
### 11.1 Backbone loading
|
| 238 |
+
The SELD branch must:
|
| 239 |
+
- use task `233`
|
| 240 |
+
- load the fixed checkpoint above
|
| 241 |
+
- stay frozen in the first training stage
|
| 242 |
+
### 11.2 Feature extraction
|
| 243 |
+
The spatial branch must operate on:
|
| 244 |
+
- full 4-channel FOA
|
| 245 |
+
- `16kHz`
|
| 246 |
+
- baseline-compatible feature format
|
| 247 |
+
### 11.3 Hidden representation extraction
|
| 248 |
+
The representation to extract is:
|
| 249 |
+
- final MHSA output
|
| 250 |
+
- not final heads
|
| 251 |
+
- not sed logits
|
| 252 |
+
|
| 253 |
+
### 11.4 Tokenization
|
| 254 |
+
The spatial token head must:
|
| 255 |
+
- preserve temporal ordering
|
| 256 |
+
- reduce token rate to `2.5 Hz`
|
| 257 |
+
- output a fixed hidden dim, recommended `256`
|
| 258 |
+
|
| 259 |
+
### 12.1 New thinker members
|
| 260 |
+
Add:
|
| 261 |
+
- optional `self.seld233_spatial_norm`
|
| 262 |
+
### 12.2 Forward inputs
|
| 263 |
+
Thinker forward should support:
|
| 264 |
+
- `spatial_audio`
|
| 265 |
+
- `spatial_tokens`
|
| 266 |
+
- `spatial_token_lengths`
|
| 267 |
+
|
| 268 |
+
Priority:
|
| 269 |
+
- if `spatial_tokens` provided, use them directly
|
| 270 |
+
|
| 271 |
+
### 12.3 Injection point
|
| 272 |
+
Injection should happen in the same stage where current code merges:
|
| 273 |
+
- text
|
| 274 |
+
- audio
|
| 275 |
+
- video
|
| 276 |
+
The new logic should:
|
| 277 |
+
1. compute `projected_spatial`
|
| 278 |
+
2. build `spatial_mask = (input_ids == spatial_token_id)`
|
| 279 |
+
3. inject with `masked_scatter`
|
| 280 |
+
|
| 281 |
+
Before scatter, verify:
|
| 282 |
+
|
| 283 |
+
If not, raise an error.
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
### 13.1 Why needed
|
| 287 |
+
Adding a new modality requires updating multimodal position ID construction.
|
| 288 |
+
### 13.2 Required additions
|
| 289 |
+
- add `spatial_token_id`
|
| 290 |
+
- add `spatial_seqlens`
|
| 291 |
+
- count spatial modality occurrences
|
| 292 |
+
- add `remain_spatials`
|
| 293 |
+
- add spatial branch when selecting next multimodal segment
|
| 294 |
+
|
| 295 |
+
### 13.3 Spatial position assignment
|
| 296 |
+
Spatial token positions should be assigned:
|
| 297 |
+
- length equal to `spatial_token_lengths`
|
| 298 |
+
- consistent with `2.5 Hz` token rate
|
| 299 |
+
|
| 300 |
+
## 14. Generation Path Changes
|
| 301 |
+
|
| 302 |
+
Top-level `generate()` must forward:
|
| 303 |
+
- `spatial_audio`
|
| 304 |
+
- `spatial_tokens`
|
| 305 |
+
- `spatial_token_lengths`
|
| 306 |
+
to thinker generation.
|
| 307 |
+
### 14.2 Talker interaction
|
| 308 |
+
Recommended first version:
|
| 309 |
+
- spatial positions should be zeroed before passing thinker hidden states into talker
|
| 310 |
+
|
| 311 |
+
Reason:
|
| 312 |
+
- spatial modality is meant for reasoning
|
| 313 |
+
- not necessarily for speech token generation conditioning
|
| 314 |
+
## 15. Training Strategy
|
| 315 |
+
|
| 316 |
+
### 15.1 Stage 1
|
| 317 |
+
Freeze:
|
| 318 |
+
- SELD backbone
|
| 319 |
+
|
| 320 |
+
Train only:
|
| 321 |
+
- spatial token head
|
| 322 |
+
- spatial projector
|
| 323 |
+
- LoRA / lightweight LLM adapters if used
|
| 324 |
+
|
| 325 |
+
- last spatial token head layers
|
| 326 |
+
- projector
|
| 327 |
+
- maybe a small part of SELD adapter
|
| 328 |
+
### 15.3 Stage 3
|
| 329 |
+
Optional advanced finetuning:
|
| 330 |
+
- limited SELD backbone finetuning
|
| 331 |
+
- only after full pipeline is stable
|
| 332 |
+
## 16. Validation Plan
|
| 333 |
+
### 16.1 Unit-level validation
|
| 334 |
+
- checkpoint loads successfully
|
| 335 |
+
- MHSA output is captured successfully
|
| 336 |
+
- spatial token head outputs expected shape
|
| 337 |
+
- token rate is `2.5 Hz`
|
| 338 |
+
### 16.2 Processor validation
|
| 339 |
+
Validate:
|
| 340 |
+
- spatial fields appear in batch output
|
| 341 |
+
- original audio path is unchanged
|
| 342 |
+
|
| 343 |
+
Validate:
|
| 344 |
+
- spatial projector output matches LLM hidden size
|
| 345 |
+
- no length mismatch
|
| 346 |
+
- no dtype/device mismatch
|
| 347 |
+
### 16.4 Rope validation
|
| 348 |
+
Validate:
|
| 349 |
+
- generation does not crash when `<|spatial|>` is present
|
| 350 |
+
|
| 351 |
+
Validate:
|
| 352 |
+
- original audio tokens still exist
|
| 353 |
+
- spatial tokens are injected independently
|
| 354 |
+
- text generation completes
|
| 355 |
+
|
| 356 |
+
## 17. Risks
|
| 357 |
+
|
| 358 |
+
### 17.1 Feature mismatch risk
|
| 359 |
+
If SELD features differ from training-time `233` config, checkpoint utility may collapse.
|
| 360 |
+
|
| 361 |
+
Mitigation:
|
| 362 |
+
- strictly reuse baseline feature logic
|
| 363 |
+
|
| 364 |
+
If hook location is incorrect, extracted representation may not correspond to post-MHSA scene representation.
|
| 365 |
+
Mitigation:
|
| 366 |
+
- verify against baseline layer order
|
| 367 |
+
- inspect shape and stability
|
| 368 |
+
|
| 369 |
+
### 17.3 Rope mismatch
|
| 370 |
+
If `<|spatial|>` positions are not included in multimodal rope indexing, model behavior may degrade or fail.
|
| 371 |
+
|
| 372 |
+
Mitigation:
|
| 373 |
+
- treat spatial exactly as a fourth modality in rope construction
|
| 374 |
+
|
| 375 |
+
### 17.4 Prompt length growth
|
| 376 |
+
Adding spatial tokens increases context length.
|
| 377 |
+
Mitigation:
|
| 378 |
+
|
| 379 |
+
## 18. Final Requirements Checklist
|
| 380 |
+
|
| 381 |
+
- [ ] Use checkpoint `233_merged29_foa_16k_sedwarmup_v1_dev_split0_multiaccdoa_foa_best_full_model.h5`
|
| 382 |
+
- [ ] Keep original audio encoder unchanged
|
| 383 |
+
- [ ] Audio path uses `W channel` only
|
| 384 |
+
- [ ] Spatial path uses all 4 FOA channels
|
| 385 |
+
- [ ] Spatial representation comes from final SELD MHSA output
|
| 386 |
+
- [ ] Spatial token rate is `2.5 Hz`
|
| 387 |
+
- [ ] Spatial token dimension defaults to `256`
|
| 388 |
+
- [ ] Spatial tokens are injected as a true independent modality
|
| 389 |
+
- [ ] `<|spatial|>` placeholder is supported in processor
|
| 390 |
+
- [ ] RoPE logic includes spatial modality
|
| 391 |
+
- [ ] End-to-end generate path runs successfully
|
| 392 |
+
|
| 393 |
+
## 19. Recommended Implementation Order
|
| 394 |
+
|
| 395 |
+
1. Implement `seldnet233_backbone.py`
|
| 396 |
+
2. Implement `seldnet233_feature_bridge.py`
|
| 397 |
+
3. Implement `seldnet233_spatial_adapter.py`
|
| 398 |
+
4. Add config fields
|
| 399 |
+
5. Add processor `<|spatial|>` support
|
| 400 |
+
6. Add thinker spatial encoder + projector
|
| 401 |
+
7. Add spatial `masked_scatter`
|
| 402 |
+
8. Update `get_rope_index()`
|
| 403 |
+
9. Update `generate()`
|
| 404 |
+
10. Update collator and inference script
|
| 405 |
+
11. Run shape-only validation
|
| 406 |
+
12. Run end-to-end generation validation
|
| 407 |
+
|
| 408 |
+
## 20. Reviewer Notes
|
| 409 |
+
|
| 410 |
+
This design intentionally separates:
|
| 411 |
+
- content understanding from the original audio encoder
|
| 412 |
+
- spatial reasoning from the SELDNet-based encoder
|
| 413 |
+
|
| 414 |
+
The design is successful only if the final model sees:
|
| 415 |
+
- mono audio content tokens at normal resolution
|
| 416 |
+
- spatial tokens at low resolution
|
| 417 |
+
- both as independent modalities inside the thinker input stream
|
docs/spatial_qwen3_design.md
ADDED
|
@@ -0,0 +1,821 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Spatial-Qwen 升级到 Qwen3-Omni-MoE-30B-A3B 设计文档
|
| 2 |
+
|
| 3 |
+
> **状态**:阶段 0–4 已完成;阶段 5(端到端 smoke + 1 epoch 真实训练)和阶段 1d(pytest 集成测试)待执行。
|
| 4 |
+
> **最后更新**:2026-05-11
|
| 5 |
+
> **作者**:Claude Code(claudeMd 项目协作)
|
| 6 |
+
>
|
| 7 |
+
> 本文档是 Qwen3-Omni-MoE Spatial 升级的**单一权威记录**。
|
| 8 |
+
> 旧路径(Qwen2.5-Omni-7B Spatial)完全不动;本工程独立运行在新 conda env `spur-qwen3` 上,
|
| 9 |
+
> 使用独立的 model 类、独立的训练入口、独立的 RUN_ROOT。
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## 0. 总览
|
| 14 |
+
|
| 15 |
+
把 Spatial-Qwen 的 Spatial-BEATs 路径(FOA 4ch 音频 → spatial token → `<|spatial|>` 占位符 → LLM)
|
| 16 |
+
从 backbone **Qwen2.5-Omni-7B (Dense Thinker, hidden=4096)** 升级到
|
| 17 |
+
**Qwen3-Omni-30B-A3B-Instruct (MoE Thinker, hidden=2048, 128 experts/top-8)**。
|
| 18 |
+
|
| 19 |
+
### 设计准则(按用户决策固化)
|
| 20 |
+
|
| 21 |
+
| 决策点 | 选择 | 原因 |
|
| 22 |
+
|---|---|---|
|
| 23 |
+
| Qwen3 模型规格 | **30B-A3B-Instruct** | 用户明确指定;Instruct 版省了 chat template 调优 |
|
| 24 |
+
| 集成模式 | **重侵入式**(subclass + override `forward` / `__init__`) | 与 Qwen2.5 现有 `Qwen2_5OmniSpatialThinkerForConditionalGeneration` 对齐;不走 AF3 轻量 wrapper 模式 |
|
| 25 |
+
| Spatial encoder | **仅 Spatial-BEATs** | IV / Neural-IV / SELD233 留到下一轮;先验证 30B-MoE 路径能跑起来 |
|
| 26 |
+
| Conda env | **克隆 `spur` 为 `spur-qwen3`** | 与现有训练环境完全隔离;`pip install` 不污染 spur |
|
| 27 |
+
| transformers 来源 | **本地 fork editable install** | pip 4.52 没有 qwen3_omni_moe;fork 5.0.0.dev0 有,但 talker / video_processor 有 bug |
|
| 28 |
+
| 现有代码 | **完全不动** | 所有 Qwen2.5 / IV / AF3 / shell / runs / ckpt 保持不变 |
|
| 29 |
+
|
| 30 |
+
### 硬件 / 软件约束
|
| 31 |
+
|
| 32 |
+
- **GPU**:8× A100 40 GB
|
| 33 |
+
- **CUDA driver**:12.2
|
| 34 |
+
- **CUDA runtime (torch)**:12.8(torch 2.10)
|
| 35 |
+
- **conda**:conda 25.x,env 安装到 `/opt/conda/envs/spur-qwen3`(12T overlay,8.5T free;apdcephfs_cq10 共享 NFS 已仅剩 3.7 GB 可用)
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## 1. 阶段 0:环境(已完成)
|
| 40 |
+
|
| 41 |
+
### 1.1 克隆 conda env
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
conda create -n spur-qwen3 --clone spur
|
| 45 |
+
conda activate spur-qwen3
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
完成后 `python --version` = Python 3.10.19,与 `spur` 一致。
|
| 49 |
+
|
| 50 |
+
### 1.2 安装本地 transformers fork (editable)
|
| 51 |
+
|
| 52 |
+
`pip install transformers==4.52` 没有 `qwen3_omni_moe` 模块。本地已有完整 fork:
|
| 53 |
+
|
| 54 |
+
```
|
| 55 |
+
/apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers/src/transformers/models/qwen3_omni_moe/
|
| 56 |
+
configuration_qwen3_omni_moe.py # Thinker / Talker / Audio / Vision config
|
| 57 |
+
modeling_qwen3_omni_moe.py # 4138 行,Thinker 在 line 1906
|
| 58 |
+
modular_qwen3_omni_moe.py # 模块化源码(HF tooling 自动生成 modeling)
|
| 59 |
+
processing_qwen3_omni_moe.py # Qwen3OmniMoeProcessor + ProcessorKwargs
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
实际安装命令(以 fork 根目录的 `pyproject.toml` 为入口):
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
cd /apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers
|
| 66 |
+
pip install -e .
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
安装后 `transformers.__version__` = `5.0.0.dev0`(editable)。
|
| 70 |
+
|
| 71 |
+
### 1.3 修复 fork 引入的依赖冲突
|
| 72 |
+
|
| 73 |
+
| 现象 | 原因 | 修复 |
|
| 74 |
+
|---|---|---|
|
| 75 |
+
| `huggingface_hub.is_offline_mode` 不存在 | hf_hub 0.36.2 与 transformers 5.0 不兼容 | `pip install -U "huggingface-hub>=1.3.0,<2.0"` → 1.14.0 |
|
| 76 |
+
| `tokenizers` 兼容性报错 | tokenizers 0.21.4 旧 | `pip install -U "tokenizers>=0.22.0,<=0.23.0"` → 0.22.2 |
|
| 77 |
+
|
| 78 |
+
### 1.4 拍 fork 快照(防止改坏后无法回滚)
|
| 79 |
+
|
| 80 |
+
```bash
|
| 81 |
+
cp -r /apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers \
|
| 82 |
+
/apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers.snapshot-pre-qwen3
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### 1.5 已知 fork bug 与规避
|
| 86 |
+
|
| 87 |
+
1. **`Qwen3OmniMoeConfig.from_pretrained(MODEL)` 顶层加载崩溃**
|
| 88 |
+
- 错误:`AttributeError: 'Qwen3OmniMoeTalkerCodePredictorConfig' object has no attribute 'use_sliding_window'`
|
| 89 |
+
- 规避:直接读 `config.json` 原始 JSON,从 `raw["thinker_config"]` 实例化 `Qwen3OmniMoeThinkerConfig`,**完全跳过 talker 解析**。我们不需要 talker,所以这是无成本规避。
|
| 90 |
+
2. **`AutoProcessor.from_pretrained` 崩溃**
|
| 91 |
+
- 错误:`TypeError: argument of type 'NoneType' is not iterable` 在 video_processor auto-loading
|
| 92 |
+
- 规避:分别加载 `AutoTokenizer` + `AutoFeatureExtractor`,跳过 image / video processor。
|
| 93 |
+
3. **`AutoVideoProcessor` 需要 torchvision**,spur-qwen3 env 里没装;不打算装(音频 QA 不用 video)。
|
| 94 |
+
4. **`Qwen3OmniMoeProcessor.__init__` 拒绝 None image / video processor**
|
| 95 |
+
- 内部 `check_argument_for_proper_class(image_processor, ImageProcessingMixin)` 抛 `TypeError`
|
| 96 |
+
- 规避:subclass 里**不调用** `super().__init__`,手动赋值 attribute(见 §3.2)
|
| 97 |
+
|
| 98 |
+
### 1.6 pip freeze(关键依赖)
|
| 99 |
+
|
| 100 |
+
```
|
| 101 |
+
python : 3.10.19
|
| 102 |
+
torch : 2.10.0+cu128 (CUDA 12.8 runtime;driver 12.2 兼容)
|
| 103 |
+
torchaudio : 2.10.0
|
| 104 |
+
torchvision : NOT installed(不需要)
|
| 105 |
+
transformers : 5.0.0.dev0 (editable @ /apdcephfs_cq10/.../model/transformers)
|
| 106 |
+
huggingface_hub : 1.14.0
|
| 107 |
+
tokenizers : 0.22.2
|
| 108 |
+
peft : 0.18.1
|
| 109 |
+
deepspeed : 0.19.0 (已装,但 train script 暂未 wire;见 §6)
|
| 110 |
+
flash_attn : NOT installed → ATTN_IMPL=sdpa
|
| 111 |
+
soundfile / numpy / tqdm / einops / safetensors / accelerate
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
### 1.7 激活 env
|
| 115 |
+
|
| 116 |
+
```bash
|
| 117 |
+
source /opt/conda/etc/profile.d/conda.sh
|
| 118 |
+
conda activate spur-qwen3
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
> 现有 Qwen2.5 / IV / AF3 训练继续在 `spur` env 跑,**不受影响**。
|
| 122 |
+
|
| 123 |
+
### 1.8 Qwen3 模型权重
|
| 124 |
+
|
| 125 |
+
```
|
| 126 |
+
/apdcephfs_cq12/share_302080740/model/Qwen3-Omni-30B-A3B-Instruct/
|
| 127 |
+
config.json # 含 thinker_config + talker_config + token2wav_config
|
| 128 |
+
model-{00001..00015}-of-00015.safetensors # 30B BF16 ≈ 60 GB,分 15 个分片
|
| 129 |
+
tokenizer.json / vocab.json / merges.txt
|
| 130 |
+
chat_template.jinja / preprocessor_config.json
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
---
|
| 134 |
+
|
| 135 |
+
## 2. 阶段 1:spatial 子类骨架(已完成)
|
| 136 |
+
|
| 137 |
+
### 2.1 Qwen3 Thinker config 关键参数(实测)
|
| 138 |
+
|
| 139 |
+
```
|
| 140 |
+
hidden_size = 2048 (Qwen2.5: 4096) ← projector output_dim 必须改!
|
| 141 |
+
num_hidden_layers = 48 (Qwen2.5: 28)
|
| 142 |
+
num_experts = 128 (MoE)
|
| 143 |
+
num_experts_per_tok = 8
|
| 144 |
+
mrope_section = (24, 20, 20) (Qwen2.5: (16, 24, 24))
|
| 145 |
+
mrope_interleaved = True (Qwen2.5: 不 interleaved)
|
| 146 |
+
audio_token_id = 151675 (Qwen2.5: 151646)
|
| 147 |
+
image_token_id = 151655
|
| 148 |
+
video_token_id = 151656
|
| 149 |
+
audio_encoder = qwen3_omni_moe_audio_encoder(Whisper-flavor,128 mel)
|
| 150 |
+
sampling_rate = 16000
|
| 151 |
+
audio_token (str) = "<|audio_pad|>" ← 关键差异!Qwen2.5 用 "<|AUDIO|>"
|
| 152 |
+
audio_bos / audio_eos = "<|audio_start|>" / "<|audio_end|>"
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
### 2.2 文件 1:`spatial_qwen/model/configuration_qwen3_omni.py`(202 行)
|
| 156 |
+
|
| 157 |
+
**目的**:定义 spatial 扩展 config,subclass `Qwen3OmniMoeThinkerConfig`,加 30+ 个 `spatial_*` 字段。
|
| 158 |
+
|
| 159 |
+
**核心代码**:
|
| 160 |
+
|
| 161 |
+
```python
|
| 162 |
+
class Qwen3OmniMoeSpatialThinkerConfig(Qwen3OmniMoeThinkerConfig):
|
| 163 |
+
model_type = "qwen3_omni_moe_thinker_spatial"
|
| 164 |
+
attribute_map = {"spatial_token_id": "spatial_token_index"}
|
| 165 |
+
sub_configs = {
|
| 166 |
+
"audio_config": Qwen3OmniMoeAudioEncoderConfig,
|
| 167 |
+
"vision_config": Qwen3OmniMoeVisionEncoderConfig,
|
| 168 |
+
"text_config": Qwen3OmniMoeTextConfig,
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
def __init__(self, ..., spatial_token_index=None, spatial_encoder_type="spatial_beats", ..., **kwargs):
|
| 172 |
+
kwargs.pop("model_type", None) # 防止 from_pretrained roundtrip 时父类把 model_type 改回 vanilla
|
| 173 |
+
# 设置所有 spatial_* 字段
|
| 174 |
+
self.spatial_token_index = spatial_token_index
|
| 175 |
+
...
|
| 176 |
+
# 把 audio/vision/text + token id 交给父类
|
| 177 |
+
super().__init__(audio_config=..., vision_config=..., text_config=..., **kwargs)
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
**关键设计**:
|
| 181 |
+
- `model_type` 用唯一名字 `qwen3_omni_moe_thinker_spatial`,避免 AutoConfig 误匹配。
|
| 182 |
+
- `attribute_map` **只**保留 `spatial_token_id → spatial_token_index`(Qwen3 父类直接用 `*_token_id`,但旧 spatial 代码读 `config.spatial_token_index`,所以保留这一个映射)。
|
| 183 |
+
- `kwargs.pop("model_type", None)`:HF `to_dict()` 把 `model_type` 序列化进 dict,下次 `from_dict(**d)` 父类 `__init__` 会把 `self.model_type` 设回 `qwen3_omni_moe_thinker`,覆盖类级属性。必须先 pop 才能保住 subclass 的 `model_type`。
|
| 184 |
+
- spatial 字段顺序:先 BEATs(10 个),再 IV(9 个),再 SELD233(16 个),与 Qwen2.5 `configuration.py` lines 583–676 完全对齐。
|
| 185 |
+
- `spatial_encoder_type` 默认值改为 `"spatial_beats"`(Qwen2.5 默认 `"seld233"`)。
|
| 186 |
+
- 添加 `llm_hidden_size` property(=`text_config.hidden_size`,Qwen3 上是 2048)。
|
| 187 |
+
|
| 188 |
+
**Smoke 测试**(基于真实 30B config.json):
|
| 189 |
+
|
| 190 |
+
```python
|
| 191 |
+
import json
|
| 192 |
+
from spatial_qwen.model.configuration_qwen3_omni import Qwen3OmniMoeSpatialThinkerConfig
|
| 193 |
+
raw = json.load(open('/apdcephfs_cq12/.../Qwen3-Omni-30B-A3B-Instruct/config.json'))
|
| 194 |
+
cfg = Qwen3OmniMoeSpatialThinkerConfig(**raw['thinker_config'], spatial_token_index=151700)
|
| 195 |
+
# → hidden=2048, layers=48, audio_token_id=151675, model_type=qwen3_omni_moe_thinker_spatial
|
| 196 |
+
# → roundtrip cfg.to_dict() → Qwen3OmniMoeSpatialThinkerConfig(**d) 字段全部保住
|
| 197 |
+
```
|
| 198 |
+
|
| 199 |
+
### 2.3 文件 2:`spatial_qwen/model/processing_spatial_qwen3.py`(494 行)
|
| 200 |
+
|
| 201 |
+
**目的**:Qwen3-Omni-MoE 的 spatial 处理器(仅 BEATs 路径),处理 FOA 输入并构造 `<|spatial|>` 占位符。
|
| 202 |
+
|
| 203 |
+
**与 Qwen2.5 spatial processor 的关键差异**:
|
| 204 |
+
|
| 205 |
+
1. **不走 SELD233 / IV 显式 payload 分支**(删掉了 ~200 行)。
|
| 206 |
+
2. **Qwen3 `audio_token` 字符串是 `<|audio_pad|>`**,不是 `<|AUDIO|>`。`audio_token_aliases` 包含 `("<|audio|>", "<|AUDIO|>")` 两种,方便用户写习惯的 prompt。
|
| 207 |
+
3. **不调 `super().__init__`**(fork 父类拒绝 None image/video processor):
|
| 208 |
+
```python
|
| 209 |
+
def __init__(self, image_processor=None, video_processor=None, feature_extractor=None,
|
| 210 |
+
tokenizer=None, chat_template=None):
|
| 211 |
+
# 手动赋 attribute 跳过 ProcessorMixin 的类型检查
|
| 212 |
+
self.image_processor = image_processor # None
|
| 213 |
+
self.video_processor = video_processor # None
|
| 214 |
+
self.feature_extractor = feature_extractor
|
| 215 |
+
self.tokenizer = tokenizer
|
| 216 |
+
self.chat_template = chat_template
|
| 217 |
+
# 直接读 tokenizer 的 special token 字符串
|
| 218 |
+
self.audio_token = self.tokenizer.audio_token # "<|audio_pad|>"
|
| 219 |
+
self.image_token = getattr(self.tokenizer, "image_token", "<|IMAGE|>")
|
| 220 |
+
...
|
| 221 |
+
self.attributes = [] # ProcessorMixin enumerate 子组件用,留空
|
| 222 |
+
self.spatial_token = "<|spatial|>"
|
| 223 |
+
self.spatial_token_id = self._register_spatial_token_on_tokenizer()
|
| 224 |
+
```
|
| 225 |
+
4. **`__call__` 不调 `super().__call__`**(父类会触碰 image/video 分支,但 torchvision 没装)。改为内联实现 audio-only 路径:
|
| 226 |
+
```python
|
| 227 |
+
audio_inputs = self.feature_extractor(upstream_audio, sampling_rate=16000, padding=True, ...)
|
| 228 |
+
audio_inputs["feature_attention_mask"] = audio_inputs.pop("attention_mask")
|
| 229 |
+
audio_lengths = _get_feat_extract_output_lengths(feat_attn.sum(-1))
|
| 230 |
+
# expand <|AUDIO|> 占位符为 per-frame audio_pad token
|
| 231 |
+
for sample in text_list:
|
| 232 |
+
count = sample.count(self.audio_token)
|
| 233 |
+
for _ in range(count):
|
| 234 |
+
sample = sample.replace(self.audio_token, AUDIO_PH * next(audio_iter), 1)
|
| 235 |
+
sample = sample.replace(AUDIO_PH, self.audio_token)
|
| 236 |
+
texts_inputs = self.tokenizer(tokenizer_text, padding=False, padding_side="left", ...)
|
| 237 |
+
batch = BatchFeature(data={**texts_inputs, **audio_inputs}, tensor_type=...)
|
| 238 |
+
```
|
| 239 |
+
5. **保留 Qwen2.5 spatial processor 的所有结构**:
|
| 240 |
+
- `_normalize_audio_list`:mono `[T] / [1,T] / [T,1]` 或 FOA `[4,T] / [T,4]` → `[C, T_audio]` 标准化
|
| 241 |
+
- `_truncate_audio_list`:>20s 截断 + warning
|
| 242 |
+
- `_build_spatial_audio_payload`:FOA padded 到 `[B, 320000, 4]`,attention mask `[B, 320000]`,spatial_token_lengths via `_samples_to_spatial_beats_tokens`(half-to-even rounding,2.5Hz target → 5s → 12 token、20s → 50 token)
|
| 243 |
+
- `_validate_text_modal_placeholders`:每条样本必须 `audio_count == 1`;FOA 必须 `spatial_count == 1`,mono 必须 `spatial_count == 0`;模态顺序 `<|AUDIO|> < <|spatial|>`
|
| 244 |
+
- `_expand_spatial_placeholders`:把单个 `<|spatial|>` 展开成 N 个,N = spatial_token_lengths[i]
|
| 245 |
+
- `sync_spatial_tokenizer_with_model`:调 `model.sync_spatial_tokenizer(tokenizer)`,把 token id 同步到 model.config
|
| 246 |
+
|
| 247 |
+
**Smoke 测试**:
|
| 248 |
+
|
| 249 |
+
```python
|
| 250 |
+
proc = Qwen3OmniMoeSpatialProcessor(feature_extractor=fe, tokenizer=tok)
|
| 251 |
+
foa = np.random.randn(4, 16000 * 5).astype(np.float32) # 5s FOA
|
| 252 |
+
text = '<|im_start|>user\n<|audio_start|><|AUDIO|><|audio_end|><|spatial|>Direction?<|im_end|>'
|
| 253 |
+
batch = proc(text=text, audio=[foa], return_tensors='pt')
|
| 254 |
+
# input_features=[1,128,500], spatial_audio=[1,320000,4], spatial_token_lengths=[12], spatial_audio_lengths=[80000]
|
| 255 |
+
# input_ids 中 spatial token 数 = 12, audio_pad token 数 = 65(按 mel 帧数)
|
| 256 |
+
```
|
| 257 |
+
|
| 258 |
+
### 2.4 文件 3:`spatial_qwen/model/modeling_spatial_qwen3_thinker.py`(359 行)
|
| 259 |
+
|
| 260 |
+
**目的**:Spatial-BEATs 注入版的 Qwen3 Thinker。
|
| 261 |
+
|
| 262 |
+
**两个对外类**:
|
| 263 |
+
|
| 264 |
+
| 类名 | 父类 | 用途 |
|
| 265 |
+
|---|---|---|
|
| 266 |
+
| `Qwen3OmniMoeSpatialThinkerForConditionalGeneration` | `Qwen3OmniMoeThinkerForConditionalGeneration`(fork) | 真正的 spatial 模型,所有逻辑在这里 |
|
| 267 |
+
| `Qwen3OmniMoeSpatialForConditionalGeneration` | 上者 | **wrapper**:让 `model.thinker == model`,`model.disable_talker()` 是 no-op,方便复用 Qwen2.5 训练脚本 |
|
| 268 |
+
|
| 269 |
+
**关键设计**:
|
| 270 |
+
|
| 271 |
+
1. **`__init__`**:
|
| 272 |
+
- 父类 init 先建 `audio_tower / visual / model / lm_head` (Qwen3 的 Thinker),然后我们加 `spatial_beats_encoder`(`SpatialBEATsEncoderWrapper`)和 `spatial_beats_projector`(pixel-shuffle,output_dim=2048)。
|
| 273 |
+
- 验证 rate 一致性:`encoder_rate / shuffle_factor == target_rate`(默认 10/4 = 2.5)。
|
| 274 |
+
- 仅支持 `spatial_encoder_type == "spatial_beats"`,其他抛 `NotImplementedError`。
|
| 275 |
+
|
| 276 |
+
2. **`forward`** 注入流程(与 Qwen2.5 spatial 一致,只改投影维度):
|
| 277 |
+
```
|
| 278 |
+
if 没有 spatial 输入: return super().forward(*args, **kwargs)
|
| 279 |
+
if use_audio_in_video: NotImplementedError
|
| 280 |
+
spatial_tokens = self._resolve_spatial_tokens(...) # BEATs encoder forward
|
| 281 |
+
projected = self.spatial_beats_projector(spatial_tokens) # pixel-shuffle,输出 [B, T_after, 2048]
|
| 282 |
+
if shuffle_factor > 1: 调整 spatial_token_lengths
|
| 283 |
+
projected, lengths = self._align_to_placeholders(...) # 与 input_ids 中 <|spatial|> 数对齐
|
| 284 |
+
flat = self._flatten_projected_spatial(...) # [sum_T, 2048]
|
| 285 |
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
| 286 |
+
spatial_mask = (input_ids == config.spatial_token_index).unsqueeze(-1).expand_as(inputs_embeds)
|
| 287 |
+
inputs_embeds = inputs_embeds.masked_scatter(spatial_mask, flat)
|
| 288 |
+
kwargs["inputs_embeds"] = inputs_embeds
|
| 289 |
+
return super().forward(*args, **kwargs)
|
| 290 |
+
```
|
| 291 |
+
|
| 292 |
+
3. **`get_rope_index` 不重写**!🎯 关键发现:
|
| 293 |
+
- Qwen3 上游 `get_rope_index`(`Qwen3OmniMoePreTrainedModelForConditionalGeneration` 类,line 260)对每个 token 检查是不是 `vision_start_token_id` / `audio_start_token_id` / `image_token_id` / `video_token_id`;任何**不**匹配特殊 id 的 token 都被当作普通 text,分配 sequential position id。
|
| 294 |
+
- 我们注册的 `<|spatial|>` 是新 id,不在父类已知 id 列表中 → 自动走 text 分支 → 拿到与文本一致的 sequential position id。
|
| 295 |
+
- mrope_section (24, 20, 20) + interleaved=True 由底层 `Qwen3OmniMoeThinkerTextRotaryEmbedding` 处理,对调用方透明。
|
| 296 |
+
- **结论:spatial token 的 RoPE 完全由父类正确处理,不需要任何重写**。这是相对 Qwen2.5 spatial 实现(重写了 200 行 get_rope_index)的最大简化。
|
| 297 |
+
|
| 298 |
+
4. **`sync_spatial_tokenizer`**:把 `<|spatial|>` 加进 tokenizer,resize embeddings,把 token id 写回 `config.spatial_token_index`。与 Qwen2.5 实现完全一致。
|
| 299 |
+
|
| 300 |
+
5. **`Qwen3OmniMoeSpatialForConditionalGeneration` wrapper**:
|
| 301 |
+
```python
|
| 302 |
+
class Qwen3OmniMoeSpatialForConditionalGeneration(Qwen3OmniMoeSpatialThinkerForConditionalGeneration):
|
| 303 |
+
@property
|
| 304 |
+
def thinker(self):
|
| 305 |
+
return self
|
| 306 |
+
def disable_talker(self):
|
| 307 |
+
return None # Qwen3 路径不构建 talker
|
| 308 |
+
```
|
| 309 |
+
这样 Qwen2.5 训练脚本里所有 `model.thinker.spatial_beats_encoder.X` 访问、`model.disable_talker()` 调用都直接 work。
|
| 310 |
+
|
| 311 |
+
6. **Talker 完全跳过**:30B 的 talker 占额外 ~3 GB,且训练脚本不需要它(QA 任务只需要 LM logits)。Wrapper 直接以 Thinker 作为 top-level model,与 fork 的顶层 `Qwen3OmniMoeForConditionalGeneration` 解耦(也避开了 fork 顶层 config 加载的 bug)。
|
| 312 |
+
|
| 313 |
+
### 2.5 复用的现有模块(**完全不动**)
|
| 314 |
+
|
| 315 |
+
| 模块 | 路径 | 作用 |
|
| 316 |
+
|---|---|---|
|
| 317 |
+
| `SpatialBEATsEncoderWrapper` | `spatial_qwen/modules/spatial_beats_encoder.py` | FOA → 768d encoder hidden @10Hz;checkpoint 加载逻辑 |
|
| 318 |
+
| `SpatialTokenProjector` / `build_spatial_token_projector` | `spatial_qwen/modules/spatial_token_projector.py` | pixel_shuffle / mlp / mlp_ln 三种 projector,**通过 `output_dim=config.text_config.hidden_size` 自动适配 4096→2048** |
|
| 319 |
+
|
| 320 |
+
### 2.6 不写的文件
|
| 321 |
+
|
| 322 |
+
- ❌ `feature_extraction_qwen3_audio_spatial.py`:Qwen2.5 版本是 SPUR/banding 代码(用 SimplePowerVector 等),我们 BEATs 路径不需要它;Whisper 风格的 mel 由 `WhisperFeatureExtractor` 处理 mono branch,FOA 由 spatial processor 自己 pad,没有任何 banding。
|
| 323 |
+
- ❌ `processing_qwen3_omni_moe.py` 的本地副本:直接 import fork 上游。
|
| 324 |
+
|
| 325 |
+
---
|
| 326 |
+
|
| 327 |
+
## 3. 阶段 2:训练入口 + shell(已完成)
|
| 328 |
+
|
| 329 |
+
### 3.1 文件 4:`train_spatial_beats_qa_qwen3.py`(185 行)
|
| 330 |
+
|
| 331 |
+
**策略**:**不复制** 1500 行的 `train_spatial_beats_qa.py`。改为 thin wrapper,只 monkey-patch 唯一两个 Qwen-version-specific 函数。
|
| 332 |
+
|
| 333 |
+
```python
|
| 334 |
+
import train_spatial_beats_qa as _trainer
|
| 335 |
+
|
| 336 |
+
def _build_processor_qwen3(model_id, sqr):
|
| 337 |
+
tok = AutoTokenizer.from_pretrained(model_id)
|
| 338 |
+
fe = AutoFeatureExtractor.from_pretrained(model_id)
|
| 339 |
+
return Qwen3OmniMoeSpatialProcessor(feature_extractor=fe, tokenizer=tok)
|
| 340 |
+
|
| 341 |
+
def _build_model_qwen3(args, processor):
|
| 342 |
+
raw = json.load(open(os.path.join(args.model_id, "config.json")))
|
| 343 |
+
cfg = Qwen3OmniMoeSpatialThinkerConfig(**raw["thinker_config"])
|
| 344 |
+
cfg.spatial_encoder_type = "spatial_beats"
|
| 345 |
+
cfg.spatial_beats_checkpoint_path = args.beats_checkpoint
|
| 346 |
+
...
|
| 347 |
+
cfg.text_config.router_aux_loss_coef = 0.0 # 关 MoE aux loss
|
| 348 |
+
cfg.text_config.output_router_logits = False
|
| 349 |
+
cfg.loss_type = "ForCausalLMLoss"
|
| 350 |
+
model = Qwen3OmniMoeSpatialForConditionalGeneration.from_pretrained(
|
| 351 |
+
args.model_id, config=cfg, torch_dtype=bf16, attn_implementation="sdpa", low_cpu_mem_usage=True,
|
| 352 |
+
)
|
| 353 |
+
processor.sync_spatial_tokenizer_with_model(model)
|
| 354 |
+
model.disable_talker() # no-op
|
| 355 |
+
if args.gradient_checkpointing:
|
| 356 |
+
_trainer.enable_gradient_checkpointing(model)
|
| 357 |
+
enc = model.spatial_beats_encoder
|
| 358 |
+
if enc is not None:
|
| 359 |
+
enc._build_model() # CPU 上构建,再迁到 projector 设备
|
| 360 |
+
if device_map is not None:
|
| 361 |
+
enc.to(next(model.spatial_beats_projector.parameters()).device)
|
| 362 |
+
return model
|
| 363 |
+
|
| 364 |
+
def main():
|
| 365 |
+
_trainer.build_processor = _build_processor_qwen3
|
| 366 |
+
_trainer.build_model = _build_model_qwen3
|
| 367 |
+
return _trainer.main()
|
| 368 |
+
```
|
| 369 |
+
|
| 370 |
+
**为什么 monkey-patch 而不是 fork**:
|
| 371 |
+
- `train_spatial_beats_qa.py` 的 1500 行里 99% 是 dataloader / DDP / LoRA / valid / checkpoint / resume,全部 backbone-agnostic。
|
| 372 |
+
- 唯一两个 Qwen-specific 函数:`build_processor` 和 `build_model`,正好用 monkey-patch 替换。
|
| 373 |
+
- 通过 wrapper class `Qwen3OmniMoeSpatialForConditionalGeneration` 提供 `model.thinker == model`,所有 `model.thinker.spatial_beats_encoder` 访问继续生效��
|
| 374 |
+
|
| 375 |
+
**关键细节**:
|
| 376 |
+
- 关 MoE router aux loss:`router_aux_loss_coef=0.0`、`output_router_logits=False`。我们只 LoRA attention 层,experts 都是冻结的,aux loss 没有任何意义;保持开启会污染 LM loss 信号。
|
| 377 |
+
- `attn_impl="auto"` 自动 fallback 到 sdpa(spur-qwen3 没装 flash-attn)。
|
| 378 |
+
- `low_cpu_mem_usage=True` 在 30B 模型上必开,避免双倍显存占用峰值。
|
| 379 |
+
- BEATs 的 `_build_model()` 推迟到 model 加载之后再调,避开父类 init 顺序冲突。
|
| 380 |
+
|
| 381 |
+
### 3.2 文件 5:`shell/launch_train_spatial_beats_qwen3.sh`(230 行)
|
| 382 |
+
|
| 383 |
+
复制 `shell/launch_train_spatial_beats_v13d_easy.sh` 的 3 阶段结构(projector → encoder_lora → beats_lora),关键改动:
|
| 384 |
+
|
| 385 |
+
```bash
|
| 386 |
+
QWEN3_OMNI_FORK="${QWEN3_OMNI_FORK:-/apdcephfs_cq10/.../model/transformers/src}"
|
| 387 |
+
export QWEN3_OMNI_FORK # train script 的 sys.path bootstrap 依赖此环境变量
|
| 388 |
+
|
| 389 |
+
MODEL_ID="${MODEL_ID:-/apdcephfs_cq12/share_302080740/model/Qwen3-Omni-30B-A3B-Instruct}"
|
| 390 |
+
RUN_ROOT="${RUN_ROOT:-${ROOT_DIR}/runs/qwen3_v1_easy_llmqa}" # 与 Qwen2.5 完全隔离
|
| 391 |
+
|
| 392 |
+
BATCH_SIZE="${BATCH_SIZE:-1}" # 30B vs 7B → 单 batch,省显存
|
| 393 |
+
GRAD_ACCUM_STEPS="${GRAD_ACCUM_STEPS:-8}" # 全局 batch = 1 * 8 * 8 = 64,与 v13d 对齐
|
| 394 |
+
ATTN_IMPL="${ATTN_IMPL:-sdpa}" # spur-qwen3 没装 flash-attn
|
| 395 |
+
USE_GRADIENT_CHECKPOINTING="${USE_GRADIENT_CHECKPOINTING:-1}" # 30B 推荐打开
|
| 396 |
+
|
| 397 |
+
LORA_TARGET_MODULES=(${LORA_TARGET_MODULES:-q_proj k_proj v_proj o_proj}) # 只贴 attention,experts 不动
|
| 398 |
+
|
| 399 |
+
# stage 学习率与 v13d 一致
|
| 400 |
+
STAGE1_LR=5e-5 STAGE1_PROJECTOR_LR=1e-4
|
| 401 |
+
STAGE2_LR=5e-5 STAGE2_LORA_LR=5e-5 STAGE2_PROJECTOR_LR=3e-5
|
| 402 |
+
STAGE3_LR=3e-5 STAGE3_LORA_LR=3e-5 STAGE3_PROJECTOR_LR=1e-6 STAGE3_BEATS_LR=1e-6
|
| 403 |
+
|
| 404 |
+
run_train() {
|
| 405 |
+
CUDA_VISIBLE_DEVICES="${GPUS}" QWEN3_OMNI_FORK="${QWEN3_OMNI_FORK}" \
|
| 406 |
+
torchrun --nnodes=... --nproc_per_node=${NPROC} ... \
|
| 407 |
+
"${ROOT_DIR}/train_spatial_beats_qa_qwen3.py" "$@"
|
| 408 |
+
}
|
| 409 |
+
```
|
| 410 |
+
|
| 411 |
+
**前置检查**:BEATs ckpt / QA 数据 / Qwen3 模型目录 / fork 路径必须存在,缺一个就 exit 1。
|
| 412 |
+
|
| 413 |
+
### 3.3 默认路径
|
| 414 |
+
|
| 415 |
+
```
|
| 416 |
+
QA_ROOT = /apdcephfs_cq10/.../genQA/all_qa_llm_by_difficulty_v2/easy_filtered (787K train / 84K valid / 84K test)
|
| 417 |
+
BEATS_CKPT = /apdcephfs_cq10/.../unilm/beats/checkpoints/spatial_beats_ov1_unified_v13d_exp/03_ov123_top4/best.pt
|
| 418 |
+
BEATS_REPO = /apdcephfs_cq10/.../unilm/beats
|
| 419 |
+
RUN_ROOT = runs/qwen3_v1_easy_llmqa
|
| 420 |
+
stage1_projector/
|
| 421 |
+
stage2_encoder_lora/
|
| 422 |
+
stage3_beats_lora/
|
| 423 |
+
```
|
| 424 |
+
|
| 425 |
+
### 3.4 调用范例
|
| 426 |
+
|
| 427 |
+
```bash
|
| 428 |
+
# 单机 8 卡,三阶段全流程
|
| 429 |
+
bash shell/launch_train_spatial_beats_qwen3.sh
|
| 430 |
+
|
| 431 |
+
# 从 stage2 开始
|
| 432 |
+
START_STAGE=2 bash shell/launch_train_spatial_beats_qwen3.sh
|
| 433 |
+
|
| 434 |
+
# smoke 测试(仅 32 样本)
|
| 435 |
+
MAX_TRAIN_SAMPLES=32 STAGE1_EPOCHS=1 bash shell/launch_train_spatial_beats_qwen3.sh
|
| 436 |
+
```
|
| 437 |
+
|
| 438 |
+
---
|
| 439 |
+
|
| 440 |
+
## 4. 阶段 3:DeepSpeed ZeRO-3(已完成 - asset,trainer 集成 TODO)
|
| 441 |
+
|
| 442 |
+
### 4.1 显存预算
|
| 443 |
+
|
| 444 |
+
| 组件 | 大小 |
|
| 445 |
+
|---|---|
|
| 446 |
+
| 30B BF16 权重 | 60 GB |
|
| 447 |
+
| ZeRO-3 分片到 8 卡 | 7.5 GB / 卡 |
|
| 448 |
+
| BEATs encoder(freeze) | 0.4 GB |
|
| 449 |
+
| LoRA(attention only,r=16) | ~50M ≈ 0.1 GB trainable |
|
| 450 |
+
| AdamW optimizer state(CPU offload) | 0 GB GPU |
|
| 451 |
+
| Activations + KV cache(bs=1, seq~4096) | 10 GB / 卡 |
|
| 452 |
+
| **预估每卡总占用** | **~22 GB**(40 GB 卡留 18 GB margin) |
|
| 453 |
+
|
| 454 |
+
### 4.2 文件 6:`configs/ds_zero3_qwen3.json`(55 行)
|
| 455 |
+
|
| 456 |
+
```json
|
| 457 |
+
{
|
| 458 |
+
"bf16": {"enabled": true},
|
| 459 |
+
"zero_optimization": {
|
| 460 |
+
"stage": 3,
|
| 461 |
+
"offload_optimizer": {"device": "cpu", "pin_memory": true},
|
| 462 |
+
"offload_param": {"device": "cpu", "pin_memory": true},
|
| 463 |
+
"overlap_comm": true,
|
| 464 |
+
"contiguous_gradients": true,
|
| 465 |
+
"stage3_gather_16bit_weights_on_model_save": true,
|
| 466 |
+
...
|
| 467 |
+
},
|
| 468 |
+
"gradient_accumulation_steps": "auto",
|
| 469 |
+
"train_micro_batch_size_per_gpu": "auto",
|
| 470 |
+
"gradient_clipping": "auto",
|
| 471 |
+
"optimizer": {"type": "AdamW", "params": {"lr": "auto", ...}},
|
| 472 |
+
"scheduler": {"type": "WarmupDecayLR", "params": {...}}
|
| 473 |
+
}
|
| 474 |
+
```
|
| 475 |
+
|
| 476 |
+
### 4.3 集成状态
|
| 477 |
+
|
| 478 |
+
- ✅ JSON config 已写。
|
| 479 |
+
- ❌ `train_spatial_beats_qa_qwen3.py` 还**没有** wire DeepSpeed。
|
| 480 |
+
|
| 481 |
+
### 4.4 集成 TODO(约 1–2 天工作量)
|
| 482 |
+
|
| 483 |
+
需要在 `train_spatial_beats_qa.py` 里加:
|
| 484 |
+
|
| 485 |
+
```python
|
| 486 |
+
import deepspeed
|
| 487 |
+
|
| 488 |
+
# 替换 DDP wrap:
|
| 489 |
+
# OLD: model = DistributedDataParallel(model, device_ids=[local_rank])
|
| 490 |
+
# NEW:
|
| 491 |
+
model_engine, optimizer, _, scheduler = deepspeed.initialize(
|
| 492 |
+
args=args, model=model, model_parameters=trainable_params,
|
| 493 |
+
config=os.environ.get("DS_CONFIG", "configs/ds_zero3_qwen3.json"),
|
| 494 |
+
)
|
| 495 |
+
|
| 496 |
+
# 替换训练步:
|
| 497 |
+
# OLD: loss.backward(); optimizer.step(); optimizer.zero_grad()
|
| 498 |
+
# NEW: model_engine.backward(loss); model_engine.step()
|
| 499 |
+
|
| 500 |
+
# checkpoint:用 model_engine.save_checkpoint(...) 而不是 torch.save
|
| 501 |
+
```
|
| 502 |
+
|
| 503 |
+
### 4.5 临时回退(在 DS 集成完成前)
|
| 504 |
+
|
| 505 |
+
- **stage 1 projector_only**:试 `BATCH_SIZE=1 GRAD_ACCUM_STEPS=8` + plain DDP;如果 30B forward 单卡 OOM,退到 `device_map="auto"` 单 replica(NPROC=1,HF accelerate 跨 8 卡 sharding,仅推理时验证过)。
|
| 506 |
+
- **stage 2 / 3 LoRA + optimizer state**:必须 ZeRO-3,**集成完成前不要跑**。
|
| 507 |
+
- 阶段 5 真实训练前,先把 DS 接入做完。
|
| 508 |
+
|
| 509 |
+
---
|
| 510 |
+
|
| 511 |
+
## 5. 阶段 4:bench(已完成)
|
| 512 |
+
|
| 513 |
+
### 5.1 文件 7:`scripts/bench_test_generate_qwen3.py`(66 行)
|
| 514 |
+
|
| 515 |
+
Thin wrapper,monkey-patch 三层:
|
| 516 |
+
|
| 517 |
+
```python
|
| 518 |
+
import train_spatial_beats_qa as _trainer
|
| 519 |
+
from train_spatial_beats_qa_qwen3 import _build_processor_qwen3, _build_model_qwen3
|
| 520 |
+
|
| 521 |
+
# 1. patch trainer module
|
| 522 |
+
_trainer.build_processor = _build_processor_qwen3
|
| 523 |
+
_trainer.build_model = _build_model_qwen3
|
| 524 |
+
|
| 525 |
+
# 2. patch batch_bench module(已经 from train_spatial_beats_qa import build_processor)
|
| 526 |
+
from scripts import batch_bench_spatial_beats_qa as _bb
|
| 527 |
+
_bb.build_processor = _build_processor_qwen3
|
| 528 |
+
_bb.build_model = _build_model_qwen3
|
| 529 |
+
|
| 530 |
+
# 3. patch bench_test_generate(已经 from batch_bench import instantiate_model_for_checkpoint)
|
| 531 |
+
from scripts import bench_test_generate as _bench
|
| 532 |
+
_bench.build_processor = _build_processor_qwen3
|
| 533 |
+
_bench.build_model = _build_model_qwen3
|
| 534 |
+
|
| 535 |
+
def main(): return _bench.main()
|
| 536 |
+
```
|
| 537 |
+
|
| 538 |
+
**为什么必须三层 patch**:Python `from M import name` 是绑定**当前时刻**的引用,不是 lazy lookup。`bench_test_generate.py` 在 import 时已经把 `build_processor` 复制到自己的 module namespace;只 patch `train_spatial_beats_qa.build_processor` 不够,必须把所有「捕获了引用的 module」都重新绑定。
|
| 539 |
+
|
| 540 |
+
### 5.2 文件 8:`scripts/run_bench.py`(修改 1 处)
|
| 541 |
+
|
| 542 |
+
加 2 个 baseline 路由:
|
| 543 |
+
|
| 544 |
+
```python
|
| 545 |
+
BASELINE_TO_MODULE = {
|
| 546 |
+
"spatial-qwen": ("scripts.bench_test_generate", []),
|
| 547 |
+
"spatial-qwen3": ("scripts.bench_test_generate_qwen3", []), # ← 新
|
| 548 |
+
"zero-spatial": ("scripts.bench_test_generate", ["--spatial-ablation", "zero"]),
|
| 549 |
+
"zero-spatial-qwen3": ("scripts.bench_test_generate_qwen3", ["--spatial-ablation", "zero"]), # ← 新
|
| 550 |
+
"iv": ("scripts.bench_test_generate_iv", []),
|
| 551 |
+
"neural-iv": ("scripts.bench_test_generate_iv", []),
|
| 552 |
+
"spatial-flamingo": ("scripts.bench_test_generate_af3", []),
|
| 553 |
+
}
|
| 554 |
+
```
|
| 555 |
+
|
| 556 |
+
### 5.3 调用范例
|
| 557 |
+
|
| 558 |
+
```bash
|
| 559 |
+
# Qwen3 baseline 实测
|
| 560 |
+
torchrun --nproc_per_node=8 scripts/run_bench.py \
|
| 561 |
+
--baseline spatial-qwen3 \
|
| 562 |
+
--checkpoint-paths runs/qwen3_v1_easy_llmqa/stage2_encoder_lora/checkpoints/best_trainable.pt \
|
| 563 |
+
--qa-root /apdcephfs_cq10/.../easy_filtered \
|
| 564 |
+
--split test --batch-size 1 --num-workers 4 \
|
| 565 |
+
--output-dir runs/qwen3_v1_easy_llmqa/stage2_encoder_lora/bench/test
|
| 566 |
+
|
| 567 |
+
# 关 spatial 通道的 ablation
|
| 568 |
+
torchrun --nproc_per_node=8 scripts/run_bench.py \
|
| 569 |
+
--baseline zero-spatial-qwen3 \
|
| 570 |
+
--checkpoint-paths .../best_trainable.pt \
|
| 571 |
+
--qa-root .../easy_filtered --split test
|
| 572 |
+
```
|
| 573 |
+
|
| 574 |
+
bench 完成后用既有 `scripts/score_test_predictions.py` 打分(CPU only,可加 LLM judge)。
|
| 575 |
+
|
| 576 |
+
---
|
| 577 |
+
|
| 578 |
+
## 6. 完整文件清单
|
| 579 |
+
|
| 580 |
+
### 6.1 新建的文件(10 个,~1300 行)
|
| 581 |
+
|
| 582 |
+
| # | 路径 | 行数 | 状态 | 说明 |
|
| 583 |
+
|---|---|---|---|---|
|
| 584 |
+
| 1 | `spatial_qwen/model/configuration_qwen3_omni.py` | 202 | ✅ smoke 通过 | spatial Thinker config |
|
| 585 |
+
| 2 | `spatial_qwen/model/processing_spatial_qwen3.py` | 494 | ✅ smoke 通过 | FOA + `<\|spatial\|>` processor |
|
| 586 |
+
| 3 | `spatial_qwen/model/modeling_spatial_qwen3_thinker.py` | 359 | ✅ 编译通过 | spatial 注入 Thinker + wrapper |
|
| 587 |
+
| 4 | `train_spatial_beats_qa_qwen3.py` | 185 | ✅ `--help` 通过 | 训练 entrypoint(monkey-patch 包装) |
|
| 588 |
+
| 5 | `shell/launch_train_spatial_beats_qwen3.sh` | 230 | ✅ 前置检查通过 | 三阶段 launcher |
|
| 589 |
+
| 6 | `configs/ds_zero3_qwen3.json` | 55 | ✅ JSON 合法 | DS ZeRO-3 配置 asset |
|
| 590 |
+
| 7 | `scripts/bench_test_generate_qwen3.py` | 66 | ✅ `--help` 通过 | bench 入口(monkey-patch) |
|
| 591 |
+
| 8 | `docs/qwen3_env.md` | ~80 | ✅ | 环境笔记 + memory budget |
|
| 592 |
+
| 9 | `docs/spatial_qwen3_design.md` | 本文 | ✅ | **本设计文档** |
|
| 593 |
+
| 10 | `tests/test_spatial_qwen3_pipeline.py` | — | ⏳ TODO(阶段 1d) | pytest 集成测试 |
|
| 594 |
+
|
| 595 |
+
### 6.2 修改的文件(1 个)
|
| 596 |
+
|
| 597 |
+
| 路径 | 改动 |
|
| 598 |
+
|---|---|
|
| 599 |
+
| `scripts/run_bench.py` | `BASELINE_TO_MODULE` 加 2 项:`spatial-qwen3` / `zero-spatial-qwen3` |
|
| 600 |
+
|
| 601 |
+
### 6.3 完全不动的文件
|
| 602 |
+
|
| 603 |
+
```
|
| 604 |
+
所有 Qwen2.5 路径文件(≈ 12 个),包括:
|
| 605 |
+
train_spatial_beats_qa.py
|
| 606 |
+
spatial_qwen/model/modeling_spatial_thinker.py
|
| 607 |
+
spatial_qwen/model/processing_spatial.py
|
| 608 |
+
spatial_qwen/model/configuration.py
|
| 609 |
+
spatial_qwen/model/modeling_qwen2_5_omni.py / modular_qwen2_5_omni.py / processing_qwen2_5_omni.py
|
| 610 |
+
spatial_qwen/model/feature_extraction_qwen2_audio_spatial.py
|
| 611 |
+
shell/launch_train_spatial_beats_v13d_easy.sh
|
| 612 |
+
|
| 613 |
+
所有 IV / Neural-IV 路径文件(≈ 6 个)
|
| 614 |
+
|
| 615 |
+
所有 AF3 路径文件(≈ 4 个)
|
| 616 |
+
|
| 617 |
+
所有 backbone-agnostic 模块(complete share between Qwen2.5 / Qwen3):
|
| 618 |
+
spatial_qwen/modules/spatial_beats_encoder.py
|
| 619 |
+
spatial_qwen/modules/spatial_token_projector.py
|
| 620 |
+
spatial_qwen/modules/iv_spatial_adapters.py
|
| 621 |
+
spatial_qwen/modules/seldnet233_*.py
|
| 622 |
+
spatial_qwen/encoders/seldnet/ / encoders/beats/
|
| 623 |
+
scripts/score_test_predictions.py
|
| 624 |
+
scripts/precompute_*.py
|
| 625 |
+
|
| 626 |
+
spur conda env 本身(保持 Qwen2.5 训练环境完全不变)
|
| 627 |
+
所有 runs/v13d_easy_llmqa/ 等历史 ckpt
|
| 628 |
+
```
|
| 629 |
+
|
| 630 |
+
---
|
| 631 |
+
|
| 632 |
+
## 7. 运行策略 / 复现指南
|
| 633 |
+
|
| 634 |
+
### 7.1 完整运行清单(按时间顺序)
|
| 635 |
+
|
| 636 |
+
#### Step 0:环境准备(已完成,仅记录)
|
| 637 |
+
|
| 638 |
+
```bash
|
| 639 |
+
# 0a. 克隆 conda env
|
| 640 |
+
conda create -n spur-qwen3 --clone spur
|
| 641 |
+
|
| 642 |
+
# 0b. fork editable install
|
| 643 |
+
conda activate spur-qwen3
|
| 644 |
+
cd /apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers
|
| 645 |
+
pip install -e .
|
| 646 |
+
|
| 647 |
+
# 0c. 修兼容性
|
| 648 |
+
pip install -U "huggingface-hub>=1.3.0,<2.0" # → 1.14.0
|
| 649 |
+
pip install -U "tokenizers>=0.22.0,<=0.23.0" # → 0.22.2
|
| 650 |
+
|
| 651 |
+
# 0d. 拍快照
|
| 652 |
+
cp -r /apdcephfs_cq10/.../model/transformers /apdcephfs_cq10/.../model/transformers.snapshot-pre-qwen3
|
| 653 |
+
|
| 654 |
+
# 0e. 验证
|
| 655 |
+
python -c "
|
| 656 |
+
import sys; sys.path.insert(0, '/apdcephfs_cq10/.../model/transformers/src')
|
| 657 |
+
from transformers.models.qwen3_omni_moe import (
|
| 658 |
+
Qwen3OmniMoeThinkerForConditionalGeneration,
|
| 659 |
+
Qwen3OmniMoeProcessor,
|
| 660 |
+
Qwen3OmniMoeThinkerConfig,
|
| 661 |
+
)
|
| 662 |
+
print('OK')
|
| 663 |
+
"
|
| 664 |
+
```
|
| 665 |
+
|
| 666 |
+
#### Step 1:单元烟测(阶段 1d,TODO)
|
| 667 |
+
|
| 668 |
+
```bash
|
| 669 |
+
conda activate spur-qwen3
|
| 670 |
+
cd /apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen
|
| 671 |
+
pytest tests/test_spatial_qwen3_pipeline.py -v
|
| 672 |
+
```
|
| 673 |
+
|
| 674 |
+
测试内容(待写):
|
| 675 |
+
1. 配置 from_pretrained roundtrip 保住 spatial 字段
|
| 676 |
+
2. processor 对单条 FOA 5s 输入 → spatial_token_lengths == 12,audio token 数与 mel 长度一致
|
| 677 |
+
3. 用 tiny config(hidden=256, layers=2, experts=4)实例化 model,random init forward 一次,logits shape OK,无 NaN
|
| 678 |
+
4. `model.thinker is model`,`disable_talker()` 不报错
|
| 679 |
+
|
| 680 |
+
#### Step 2:smoke 训练(阶段 5,第一步)
|
| 681 |
+
|
| 682 |
+
```bash
|
| 683 |
+
# 32 样本 stage1 projector_only,确认 loss 5 步内单调下降
|
| 684 |
+
conda activate spur-qwen3
|
| 685 |
+
cd /apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen
|
| 686 |
+
MAX_TRAIN_SAMPLES=32 STAGE1_EPOCHS=1 BATCH_SIZE=1 GRAD_ACCUM_STEPS=2 \
|
| 687 |
+
NPROC=1 \
|
| 688 |
+
bash shell/launch_train_spatial_beats_qwen3.sh
|
| 689 |
+
```
|
| 690 |
+
|
| 691 |
+
> 单卡 30B 极可能 OOM,需要先把 DS 接入或先用 `device_map=auto`。**这是阶段 3+5 的真正接入点**。
|
| 692 |
+
|
| 693 |
+
#### Step 3:DeepSpeed 接入(阶段 3 finalize)
|
| 694 |
+
|
| 695 |
+
按 §4.4 在 `train_spatial_beats_qa.py` 加 `deepspeed.initialize` 调用,`shell/launch_train_spatial_beats_qwen3.sh` 加 `--deepspeed configs/ds_zero3_qwen3.json` arg 透传,runtime 用 `deepspeed --num_gpus=8 train_spatial_beats_qa_qwen3.py ...`(或 torchrun + DS 自动检测)。
|
| 696 |
+
|
| 697 |
+
#### Step 4:真实 stage1(阶段 5 主体)
|
| 698 |
+
|
| 699 |
+
```bash
|
| 700 |
+
# 8 卡 ZeRO-3,1 epoch easy_filtered (~787K samples → ~12K opt step)
|
| 701 |
+
conda activate spur-qwen3
|
| 702 |
+
START_STAGE=1 STAGE1_EPOCHS=1 \
|
| 703 |
+
BATCH_SIZE=1 GRAD_ACCUM_STEPS=8 \
|
| 704 |
+
bash shell/launch_train_spatial_beats_qwen3.sh
|
| 705 |
+
```
|
| 706 |
+
|
| 707 |
+
预期墙钟时间:~24 h / epoch(参考 Qwen2.5-7B v13d 是 ~6 h,30B + ZeRO-3 offload ~4× slower)。
|
| 708 |
+
|
| 709 |
+
#### Step 5:bench(阶段 4 应用)
|
| 710 |
+
|
| 711 |
+
```bash
|
| 712 |
+
torchrun --nproc_per_node=8 scripts/run_bench.py \
|
| 713 |
+
--baseline spatial-qwen3 \
|
| 714 |
+
--checkpoint-paths runs/qwen3_v1_easy_llmqa/stage1_projector/checkpoints/best_trainable.pt \
|
| 715 |
+
--qa-root /apdcephfs_cq10/.../easy_filtered \
|
| 716 |
+
--split test --batch-size 1 --num-workers 4
|
| 717 |
+
|
| 718 |
+
# 拿到 predictions.jsonl 后打分(CPU)
|
| 719 |
+
python scripts/score_test_predictions.py \
|
| 720 |
+
--predictions-jsonl runs/qwen3_v1_easy_llmqa/stage1_projector/bench/test/best/predictions.jsonl \
|
| 721 |
+
--qa-root /apdcephfs_cq10/.../easy_filtered --split test \
|
| 722 |
+
--llm-judge --llm-concurrency 8
|
| 723 |
+
```
|
| 724 |
+
|
| 725 |
+
#### Step 6:隔离验证(不该破坏老 Qwen2.5 路径)
|
| 726 |
+
|
| 727 |
+
```bash
|
| 728 |
+
# 切回 spur env,跑老 v13d 推理,对照已有 score_result.json
|
| 729 |
+
conda activate spur
|
| 730 |
+
bash shell/bench_easy_all.sh BASELINES=spatial-qwen
|
| 731 |
+
# 期望:score_result.json 的指标与之前完全一致
|
| 732 |
+
```
|
| 733 |
+
|
| 734 |
+
### 7.2 调试 / 故障排查
|
| 735 |
+
|
| 736 |
+
| 现象 | 排查 |
|
| 737 |
+
|---|---|
|
| 738 |
+
| import 时 `qwen3_omni_moe` 找不到 | `echo $QWEN3_OMNI_FORK`;fork editable install 是否在当前 env:`pip show transformers \| grep Location` |
|
| 739 |
+
| `Qwen3OmniMoeConfig.from_pretrained` 崩溃 | **不要**用顶层 config;按 §1.5.1 走 raw JSON |
|
| 740 |
+
| processor `__init__` 报 image_processor 类型错 | 不要直接 `Qwen3OmniMoeProcessor(...)`,用我们 subclass `Qwen3OmniMoeSpatialProcessor` |
|
| 741 |
+
| `<\|spatial\|>` 不在 vocab | processor 构造时会自动 `add_special_tokens`;如果用了不同 tokenizer,重跑 `proc.sync_spatial_tokenizer_with_model(model)` |
|
| 742 |
+
| forward 报 spatial token 数对不上 | 见 `_validate_spatial_mask_count`:placeholder count vs projected token count;通常是 shuffle_factor 计算不一致或 prompt 漏了 `<\|spatial\|>` |
|
| 743 |
+
| MoE router 出现 NaN aux loss | 我们已在 build_model 里 `router_aux_loss_coef=0.0`;如果 fork 行为变了重新 audit |
|
| 744 |
+
| 30B 单卡 OOM | 必须 ZeRO-3 + offload;先确认 DS wire 已完成(§4.4) |
|
| 745 |
+
| spur 老训练受影响 | 不应该,所有 Qwen2.5 文件都没动;如果 spur env 里 `import transformers` 也变成 5.0.0.dev0,说明 pip 装错 env 了 |
|
| 746 |
+
|
| 747 |
+
### 7.3 路径锚点
|
| 748 |
+
|
| 749 |
+
```
|
| 750 |
+
仓库根 : /apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen
|
| 751 |
+
transformers fork : /apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers/src
|
| 752 |
+
fork 快照 : /apdcephfs_cq10/share_1603164/user/schmittzhu/model/transformers.snapshot-pre-qwen3
|
| 753 |
+
Qwen3-30B 权重 : /apdcephfs_cq12/share_302080740/model/Qwen3-Omni-30B-A3B-Instruct
|
| 754 |
+
BEATs ckpt (v13d) : /apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/checkpoints/spatial_beats_ov1_unified_v13d_exp/03_ov123_top4/best.pt
|
| 755 |
+
QA easy_filtered : /apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2/easy_filtered
|
| 756 |
+
RUN_ROOT (Qwen3) : runs/qwen3_v1_easy_llmqa
|
| 757 |
+
RUN_ROOT (Qwen2.5) : runs/v13d_easy_llmqa ← 不动
|
| 758 |
+
```
|
| 759 |
+
|
| 760 |
+
### 7.4 工程不变量(绝不可破坏)
|
| 761 |
+
|
| 762 |
+
1. spur conda env 不能装新包;新包只装 spur-qwen3。
|
| 763 |
+
2. 任何 Qwen2.5 / IV / AF3 文件不修改(包括 shell)。
|
| 764 |
+
3. `runs/v13d_easy_llmqa/` 等历史 ckpt 不被覆盖。
|
| 765 |
+
4. `scripts/run_bench.py` 的修改只是新增 dict 项,旧 baseline 行为完全保持。
|
| 766 |
+
5. fork 自身不修改;如果发现 fork bug 必须改,先在 spur-qwen3 私有 fork copy 上改,记录在本文档 §1.5。
|
| 767 |
+
|
| 768 |
+
---
|
| 769 |
+
|
| 770 |
+
## 8. 风险登记 / 回滚
|
| 771 |
+
|
| 772 |
+
| 风险 | 触发概率 | 缓解 |
|
| 773 |
+
|---|---|---|
|
| 774 |
+
| fork 上游 API 与我们的 subclass 假设不一致 | 中 | 阶段 1d pytest 覆盖关键 path(forward shape、generate、masked_scatter) |
|
| 775 |
+
| MoE 训练梯度不稳 | 低-中 | 已关 aux loss;stage1 lr 沿用 v13d 的 5e-5 保守值;首次 32-sample smoke 必跑 |
|
| 776 |
+
| ZeRO-3 + 自定义 spatial 模块(不在 DS 视野里)的状态管理 | 中 | spatial encoder 走 `model.spatial_beats_encoder` 直接挂在 thinker 上,DS Z3 会自动 partition;如果有问题,按 train_spatial_beats_qa.py 已有的 unfreeze_modules 模式手动 register |
|
| 777 |
+
| 30B + 8 卡 + offload 一个 epoch 跑不完 | 中-高 | 阶段 5 先用 `--max-train-samples=50000` 测节奏,看 24h 跑不跑得完 |
|
| 778 |
+
| pip 升级污染了 spur env | 低(已隔离) | 一律先 `conda activate spur-qwen3`;若发生用 `pip install -r requirements.txt --force-reinstall` 修 spur |
|
| 779 |
+
| fork 快照与本地 fork 在我不知情的情况下分叉 | 低 | 阶段 5 跑前 `diff -r transformers/src transformers.snapshot-pre-qwen3/src \| head` 检查 |
|
| 780 |
+
|
| 781 |
+
### 回滚步骤
|
| 782 |
+
|
| 783 |
+
1. 删除 spur-qwen3:`conda env remove -n spur-qwen3`
|
| 784 |
+
2. 删除新建的 10 个文件(见 §6.1)
|
| 785 |
+
3. revert `scripts/run_bench.py` 的 1 处改动(删除 `spatial-qwen3` / `zero-spatial-qwen3` 两个 dict 项)
|
| 786 |
+
4. 用快照恢复 fork(仅当确实改坏过 fork):`rm -rf transformers/src && cp -r transformers.snapshot-pre-qwen3/src transformers/`
|
| 787 |
+
|
| 788 |
+
---
|
| 789 |
+
|
| 790 |
+
## 9. 验收清单
|
| 791 |
+
|
| 792 |
+
| 阶段 | 验收点 | 状态 |
|
| 793 |
+
|---|---|---|
|
| 794 |
+
| 0 | conda env list 里有 spur-qwen3,`from transformers.models.qwen3_omni_moe import ...` 成功 | ✅ |
|
| 795 |
+
| 1a | `Qwen3OmniMoeSpatialThinkerConfig` 从真实 30B config.json 实例化 + roundtrip 保留所有 spatial 字段 | ✅ |
|
| 796 |
+
| 1b | spatial processor 对 FOA 5s 输入产出 12 spatial token + 65 audio token,mixed-batch padding 正确 | ✅ |
|
| 797 |
+
| 1c | spatial Thinker subclass 静态 import 通过,wrapper class `model.thinker == model` | ✅(forward 实测留 1d) |
|
| 798 |
+
| 1d | pytest tests/test_spatial_qwen3_pipeline.py 全部通过 | ⏳ TODO |
|
| 799 |
+
| 2 | `python train_spatial_beats_qa_qwen3.py --help` 输出完整 arg 列表 | ✅ |
|
| 800 |
+
| 2 | shell 前置检查(路径存在)通过 | ✅ |
|
| 801 |
+
| 3 | configs/ds_zero3_qwen3.json 合法 | ✅ |
|
| 802 |
+
| 3 | DS 接入 trainer(engine.backward / engine.step) | ⏳ TODO |
|
| 803 |
+
| 4 | `python scripts/run_bench.py --help` 显示 `spatial-qwen3` / `zero-spatial-qwen3` 选项 | ✅ |
|
| 804 |
+
| 4 | `python scripts/bench_test_generate_qwen3.py --help` 输出完整 arg | ✅ |
|
| 805 |
+
| 5 | smoke:32 样本 stage1 projector_only 5 步 loss 单调下降 | ⏳ TODO |
|
| 806 |
+
| 5 | 真实:1 epoch easy_filtered stage1 训练完成,valid loss 收敛 | ⏳ TODO |
|
| 807 |
+
| 隔离 | `bash shell/bench_easy_all.sh BASELINES=spatial-qwen` 在 spur env 下结果与之前一致 | ⏳ 跑过即可 |
|
| 808 |
+
|
| 809 |
+
---
|
| 810 |
+
|
| 811 |
+
## 10. 备忘 / 延展
|
| 812 |
+
|
| 813 |
+
- **IV / Neural-IV / SELD233 在 Qwen3 上的支持**:本期不做。等 Spatial-BEATs 验证通过后再给 modeling_spatial_qwen3_thinker.py 加分支(结构与 Qwen2.5 spatial 一致,区别只是 projector output_dim=2048)。
|
| 814 |
+
- **Talker 接入**:长期来看 talker 能让 Qwen3 输出语音回答;非空间 QA 任务用不上,暂不做。
|
| 815 |
+
- **flash-attn**:本机 CUDA 12.8 装 flash-attn 2.x 编译耗时 ~30 min,对 30B prompt+spatial ~1k token 的注意力大概给 +15% 吞吐。值得装但不阻塞 stage5。
|
| 816 |
+
- **`device_map="auto"` + ZeRO-3 互斥**:`from_pretrained` 时不要同时传两者;DS 内部会处理 sharding。
|
| 817 |
+
- **更长上下文 / 更多 spatial token**:当前 50 token / 20 s clip。若要扩�� 1 min 音频(150 token),需要改 `spatial_beats_max_audio_seconds=60.0`,processor side `_truncate_audio_list` 会自动 truncate;attention 上 50 vs 150 token 对 30B 来说仍可忽略。
|
| 818 |
+
|
| 819 |
+
---
|
| 820 |
+
|
| 821 |
+
**文档结束**
|
docs/spur_seld_handover.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPUR SELD / Encoder-Only Handover Summary
|
| 2 |
+
|
| 3 |
+
## 1. Goal Evolution
|
| 4 |
+
The work went through two phases:
|
| 5 |
+
|
| 6 |
+
1. `encoder-only probing / pretraining`
|
| 7 |
+
- Train only SPUR spatial frontend + encoder
|
| 8 |
+
- Use lightweight heads
|
| 9 |
+
- Verify whether encoder tokens contain usable spatial information
|
| 10 |
+
- This line is useful as a probe / pretraining result
|
| 11 |
+
|
| 12 |
+
2. `paper-quality main result`
|
| 13 |
+
- The current conclusion is that the custom encoder-only line is not strong enough to be the paper's main SELD result
|
| 14 |
+
- The recommended main-result route is:
|
| 15 |
+
- keep `DCASE2024_seld_baseline` official head / ADPIT / decoding / metrics
|
| 16 |
+
- replace only the backbone with SPUR
|
| 17 |
+
|
| 18 |
+
## 2. Repos Involved
|
| 19 |
+
Main repo:
|
| 20 |
+
- `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/spur-qwen-2.5-omni`
|
| 21 |
+
|
| 22 |
+
Reference repos:
|
| 23 |
+
- `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline`
|
| 24 |
+
- `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-AST`
|
| 25 |
+
|
| 26 |
+
## 3. Data Understanding
|
| 27 |
+
### STARSS23 metadata
|
| 28 |
+
File:
|
| 29 |
+
- `/apdcephfs_cq10/share_1603164/user/schmittzhu/data/metadata/STARSS23.json`
|
| 30 |
+
|
| 31 |
+
Current metadata semantics:
|
| 32 |
+
- `trajectory.npy` is `active-only`, not full-length with NaNs
|
| 33 |
+
- static sources:
|
| 34 |
+
- `DoA` and `distance` are directly present
|
| 35 |
+
- `trajectory` is nearly constant
|
| 36 |
+
- dynamic sources:
|
| 37 |
+
- `DoA=[]`
|
| 38 |
+
- `distance=""`
|
| 39 |
+
- but `trajectory.npy` contains per-frame `az/el/dist`
|
| 40 |
+
|
| 41 |
+
Important conclusion:
|
| 42 |
+
- data itself is not broken
|
| 43 |
+
- but random chunk sampling originally did **not** guarantee event-rich chunks
|
| 44 |
+
- this was later changed to `event-aware chunk sampling`
|
| 45 |
+
|
| 46 |
+
### STARSS23 concurrency stats (already computed)
|
| 47 |
+
Per-scene total concurrency roughly:
|
| 48 |
+
- `P90 = 3`
|
| 49 |
+
- `P95 = 3`
|
| 50 |
+
- `P99 = 4`
|
| 51 |
+
|
| 52 |
+
Per-class concurrency roughly:
|
| 53 |
+
- `P90 = 2`
|
| 54 |
+
- `P95 = 3`
|
| 55 |
+
- `P99 = 3`
|
| 56 |
+
- `max = 4`
|
| 57 |
+
|
| 58 |
+
This supported `per-class K=3` for the encoder-only ADPIT line.
|
| 59 |
+
|
| 60 |
+
### Scene durations
|
| 61 |
+
STARSS23 scenes are long.
|
| 62 |
+
Previously measured:
|
| 63 |
+
- shortest about `32.5s`
|
| 64 |
+
- mean about `157.9s`
|
| 65 |
+
- median about `141.0s`
|
| 66 |
+
- longest about `569.2s`
|
| 67 |
+
|
| 68 |
+
This is why whole-scene training OOMed and chunk training was introduced.
|
| 69 |
+
|
| 70 |
+
## 4. Encoder-Only Line That Was Implemented
|
| 71 |
+
A custom encoder-only training line was built inside this repo.
|
| 72 |
+
|
| 73 |
+
### Core architecture
|
| 74 |
+
- `SpurSpatialFeatureExtractor`
|
| 75 |
+
- `SpurSpatialEncoder`
|
| 76 |
+
- lightweight heads for:
|
| 77 |
+
- SED/activity
|
| 78 |
+
- multi-ACCDOA
|
| 79 |
+
- distance (`logr`)
|
| 80 |
+
|
| 81 |
+
### Time axis
|
| 82 |
+
Final version for this line used:
|
| 83 |
+
- `10 Hz`
|
| 84 |
+
- strict axis alignment to labels
|
| 85 |
+
- no interpolation in the training target definition
|
| 86 |
+
|
| 87 |
+
### Key files added / modified
|
| 88 |
+
Main training line:
|
| 89 |
+
- `training-qwen-omni/spatial_encoder_adpit_dataset.py`
|
| 90 |
+
- `training-qwen-omni/spatial_encoder_adpit_collator.py`
|
| 91 |
+
- `training-qwen-omni/adpit_loss.py`
|
| 92 |
+
- `training-qwen-omni/spatial_encoder_adpit_metrics.py`
|
| 93 |
+
- `training-qwen-omni/train_spatial_encoder_adpit.py`
|
| 94 |
+
- `qwen2_5_omni_spur/modules/spatial_encoder_adpit_model.py`
|
| 95 |
+
- `examples/pretrain/spatial_encoder_adpit_10hz.yaml`
|
| 96 |
+
- `scripts/check_spatial_encoder_adpit_batch.py`
|
| 97 |
+
- `scripts/eval_spatial_encoder_probe.py`
|
| 98 |
+
- `scripts/run_spatial_encoder_sweep.py`
|
| 99 |
+
- `examples/pretrain/spatial_encoder_adpit_sweep.yaml`
|
| 100 |
+
|
| 101 |
+
### Important implementation details
|
| 102 |
+
- active-only trajectories are mapped back to full 10 Hz timeline
|
| 103 |
+
- event-aware chunk sampling was added later
|
| 104 |
+
- class-wise ADPIT target formatting was changed to be closer to DCASE style
|
| 105 |
+
- official-style DCASE metrics were integrated
|
| 106 |
+
- train/val split was changed from fold-based to scene-random split (`143/25` style) for convenience in this probe line
|
| 107 |
+
- later debug JSON dumping was added for eval samples
|
| 108 |
+
|
| 109 |
+
## 5. UFB / Frontend Situation
|
| 110 |
+
Important context:
|
| 111 |
+
- local dev environment often could not import the intended UFB path directly
|
| 112 |
+
- a mel fallback path was temporarily used for local debugging / validation
|
| 113 |
+
- on the real training machine, importing from merged `transformers` worked:
|
| 114 |
+
- `from transformers.models.qwen2_5_omni.modules.spur_spatial_features import SpurSpatialFeatureExtractor`
|
| 115 |
+
- `_use_ufb == True`
|
| 116 |
+
|
| 117 |
+
We changed the custom training builder so it tries to import from merged `transformers` first when available.
|
| 118 |
+
|
| 119 |
+
Still, for final paper experiments, relying on the official DCASE pipeline plus SPUR backbone is preferred over expanding this custom line further.
|
| 120 |
+
|
| 121 |
+
## 6. Main Findings From Encoder-Only Experiments
|
| 122 |
+
### What was demonstrated
|
| 123 |
+
The encoder-only line did show that SPUR encoder outputs contain usable spatial information:
|
| 124 |
+
- matched predictions had non-random DOA
|
| 125 |
+
- distance predictions were not meaningless
|
| 126 |
+
- the system was no longer in an all-zero / degenerate regime after several fixes
|
| 127 |
+
|
| 128 |
+
### But the line is not good enough for main result
|
| 129 |
+
Main persistent problem:
|
| 130 |
+
- SED / class-activity prediction was much weaker than desired
|
| 131 |
+
- F-score stayed very low
|
| 132 |
+
- often severe class bias / false positives / false negatives
|
| 133 |
+
|
| 134 |
+
In other words:
|
| 135 |
+
- this line is acceptable as `encoder probe / pretraining evidence`
|
| 136 |
+
- it is not a good main SELD system for the paper
|
| 137 |
+
|
| 138 |
+
## 7. Important Bugs / Fixes That Happened
|
| 139 |
+
### 7.1 Time-axis mismatch bug
|
| 140 |
+
Problem:
|
| 141 |
+
- GT token count computed by `round(duration * token_rate)`
|
| 142 |
+
- model produced STFT-frame-count-based length
|
| 143 |
+
- mismatch by 1 frame on some samples
|
| 144 |
+
|
| 145 |
+
Fix:
|
| 146 |
+
- dataset token count switched to the exact STFT/frame formula
|
| 147 |
+
- dataset got `hop_length`, `win_length`, `stft_center` from config
|
| 148 |
+
|
| 149 |
+
### 7.2 OOM on full scenes
|
| 150 |
+
Problem:
|
| 151 |
+
- long scenes + covariance-like frontend tensors caused OOM
|
| 152 |
+
|
| 153 |
+
Fix:
|
| 154 |
+
- introduced random `10-15s` chunk training
|
| 155 |
+
- later changed to event-aware chunk sampling
|
| 156 |
+
|
| 157 |
+
### 7.3 Dist loss was zero / not learning
|
| 158 |
+
Problem:
|
| 159 |
+
- early custom ADPIT implementation not fully aligned with official DCASE logic
|
| 160 |
+
- winning pattern selection and distance supervision were not stable
|
| 161 |
+
|
| 162 |
+
Fix:
|
| 163 |
+
- moved toward fixed DCASE-style ADPIT patterns
|
| 164 |
+
- later integrated explicit `loss_sed + loss_accdoa + loss_dist`
|
| 165 |
+
|
| 166 |
+
### 7.4 Track-level SED experiment
|
| 167 |
+
We tried changing class-level SED to track-level SED aligned with ADPIT tracks.
|
| 168 |
+
|
| 169 |
+
Result:
|
| 170 |
+
- this did **not** improve the custom line
|
| 171 |
+
- likely made classification / activity learning less stable
|
| 172 |
+
- final judgment: not a good direction for the custom probe line's main result
|
| 173 |
+
|
| 174 |
+
## 8. Debug Instrumentation Added
|
| 175 |
+
The user explicitly asked to add debug outputs to understand why predicted classes differ so much from GT.
|
| 176 |
+
|
| 177 |
+
Implemented in:
|
| 178 |
+
- `training-qwen-omni/spatial_encoder_adpit_metrics.py`
|
| 179 |
+
- `training-qwen-omni/train_spatial_encoder_adpit.py`
|
| 180 |
+
- config flags in `examples/pretrain/spatial_encoder_adpit_10hz.yaml`
|
| 181 |
+
|
| 182 |
+
### Debug output path
|
| 183 |
+
- `outputs/spatial_encoder_adpit_10hz/debug/epoch_XXX_eval_debug.json`
|
| 184 |
+
|
| 185 |
+
### Debug contents
|
| 186 |
+
For first N eval batches, the JSON contains:
|
| 187 |
+
- GT vs Pred class lists
|
| 188 |
+
- false positive classes
|
| 189 |
+
- missed classes
|
| 190 |
+
- top SED classes
|
| 191 |
+
- top score classes
|
| 192 |
+
- per-sample metadata:
|
| 193 |
+
- `sample_id`
|
| 194 |
+
- `scene_id`
|
| 195 |
+
- `audio_path`
|
| 196 |
+
- `start_token`
|
| 197 |
+
- `end_token`
|
| 198 |
+
- `valid_tokens`
|
| 199 |
+
- per-class stats:
|
| 200 |
+
- `gt_frame_count`
|
| 201 |
+
- `pred_frame_count`
|
| 202 |
+
- `matched_frame_count`
|
| 203 |
+
- `fp_frame_count`
|
| 204 |
+
- `fn_frame_count`
|
| 205 |
+
- `gt_instance_count`
|
| 206 |
+
- `pred_instance_count`
|
| 207 |
+
|
| 208 |
+
### Debug analysis already done
|
| 209 |
+
The latest debug JSON showed a strong class bias:
|
| 210 |
+
|
| 211 |
+
Frequent false-positive classes:
|
| 212 |
+
- `Domestic_sounds`
|
| 213 |
+
- `Music`
|
| 214 |
+
- `Female_speech_and_woman_speaking`
|
| 215 |
+
- `Male_speech_and_man_speaking`
|
| 216 |
+
- `Musical_instrument`
|
| 217 |
+
|
| 218 |
+
Frequent false-negative / poorly learned classes:
|
| 219 |
+
- `Water_tap_and_faucet`
|
| 220 |
+
- `Walk_and_footsteps`
|
| 221 |
+
- `Bell`
|
| 222 |
+
- `Knock`
|
| 223 |
+
- `Laughter`
|
| 224 |
+
|
| 225 |
+
Interpretation:
|
| 226 |
+
- the custom line learned a biased class prior
|
| 227 |
+
- low `F` is mainly caused by class-level SED bias and miscalibration
|
| 228 |
+
- DOA is not the main bottleneck
|
| 229 |
+
|
| 230 |
+
## 9. Current Assessment of Custom Encoder-Only Line
|
| 231 |
+
### Useful for
|
| 232 |
+
- encoder probing
|
| 233 |
+
- pretraining evidence
|
| 234 |
+
- showing SPUR tokens contain spatial information
|
| 235 |
+
|
| 236 |
+
### Not suitable for
|
| 237 |
+
- final paper main result
|
| 238 |
+
- fair direct comparison against DCASE baseline as a complete SELD system
|
| 239 |
+
|
| 240 |
+
### Best achieved regime in custom line
|
| 241 |
+
Depending on run, best custom-line checkpoints reached roughly:
|
| 242 |
+
- `F` only a few percent (`~0.03 to 0.07` range)
|
| 243 |
+
- `AngE` around `30-40°`
|
| 244 |
+
- `DistE` around `0.29-0.45`
|
| 245 |
+
- still much worse than desired baseline-level detection performance
|
| 246 |
+
|
| 247 |
+
The user explicitly noted baseline-level references such as:
|
| 248 |
+
- baseline around `13%` F
|
| 249 |
+
- best results around `54%` F
|
| 250 |
+
|
| 251 |
+
We agreed the custom line should not be forced into the main-result role anymore.
|
| 252 |
+
|
| 253 |
+
## 10. Agreed Strategic Direction
|
| 254 |
+
The user agreed that the next main-result route should be:
|
| 255 |
+
|
| 256 |
+
> integrate SPUR backbone into `DCASE2024_seld_baseline`
|
| 257 |
+
|
| 258 |
+
This means:
|
| 259 |
+
- keep official DCASE2024 data flow, target construction, ADPIT loss, decoding, metrics
|
| 260 |
+
- replace only the backbone with SPUR
|
| 261 |
+
|
| 262 |
+
Why this is preferred:
|
| 263 |
+
1. fairer comparison
|
| 264 |
+
2. detection / decoding path is already validated
|
| 265 |
+
3. isolates SPUR backbone contribution
|
| 266 |
+
4. stronger paper argument
|
| 267 |
+
|
| 268 |
+
## 11. Recommended Next Task in New Conversation
|
| 269 |
+
The next conversation should focus on:
|
| 270 |
+
|
| 271 |
+
### Main-result integration plan
|
| 272 |
+
Target repo:
|
| 273 |
+
- `/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline`
|
| 274 |
+
|
| 275 |
+
Suggested approach:
|
| 276 |
+
1. inspect official model input/output requirements
|
| 277 |
+
2. identify where the baseline backbone lives
|
| 278 |
+
3. create a new model variant that uses:
|
| 279 |
+
- `SpurSpatialFeatureExtractor`
|
| 280 |
+
- `SpurSpatialEncoder`
|
| 281 |
+
4. add a projection/adaptation layer if needed
|
| 282 |
+
5. keep official:
|
| 283 |
+
- label format
|
| 284 |
+
- `MSELoss_ADPIT`
|
| 285 |
+
- decoding
|
| 286 |
+
- metrics
|
| 287 |
+
6. run baseline-compatible training with SPUR backbone
|
| 288 |
+
|
| 289 |
+
### Avoid in next conversation
|
| 290 |
+
- do not continue pushing the current custom encoder-only line as the main result line
|
| 291 |
+
- do not keep iterating on custom SED head designs unless strictly for probe/ablation purposes
|
| 292 |
+
|
| 293 |
+
## 12. If Continuing the Custom Line Anyway
|
| 294 |
+
If the user still wants to use the current custom line for analysis only, the most relevant future improvement mentioned was:
|
| 295 |
+
- add `per-class pos_weight` for SED
|
| 296 |
+
- maybe per-class threshold sweep
|
| 297 |
+
|
| 298 |
+
But this was explicitly judged lower priority than moving to the official DCASE2024 baseline route for the paper's main result.
|
| 299 |
+
|
| 300 |
+
## 13. User Preferences / Constraints
|
| 301 |
+
- Prefer concise, factual communication in Chinese
|
| 302 |
+
- User is comfortable running experiments on another machine with merged `transformers`
|
| 303 |
+
- User wants debugging outputs when investigating poor predictions
|
| 304 |
+
- User cares about paper-quality experiments, not just toy success
|
| 305 |
+
|
| 306 |
+
## 14. Immediate Recommendation to Future Assistant
|
| 307 |
+
Do this next:
|
| 308 |
+
1. analyze `DCASE2024_seld_baseline` model / data / loss interfaces
|
| 309 |
+
2. produce a minimal SPUR-backbone integration plan
|
| 310 |
+
3. then implement the baseline-compatible SPUR model
|
| 311 |
+
|
| 312 |
+
Do **not** spend more time polishing the current custom encoder-only line as the main result system.
|
docs/unified_foa_fsd63_dataset.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# unified_spatial_foa_fsd63_all 数据集说明
|
| 2 |
+
|
| 3 |
+
## 概述
|
| 4 |
+
|
| 5 |
+
`unified_spatial_foa_fsd63_all` 是一批大规模统一格式的空间 FOA 数据集,将多个子集整合为统一的 schema(`spatial_foa_scene_v1`)。数据位于:
|
| 6 |
+
|
| 7 |
+
```
|
| 8 |
+
/apdcephfs_cq12/share_302080740/user/schmittzhu/data/unified_spatial_foa_fsd63_all/
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
**规模(scene/clip 数):**
|
| 12 |
+
|
| 13 |
+
| split | 总计 | sim_static | qa_sim | dcase_real |
|
| 14 |
+
|-------|----------|------------|---------|------------|
|
| 15 |
+
| train | 329,610 | 250,761 | 63,439 | 15,410 |
|
| 16 |
+
| valid | 35,093 | 25,158 | 5,303 | 4,632 |
|
| 17 |
+
| test | 35,237 | 28,507 | 6,149 | 581 |
|
| 18 |
+
| **合计** | **399,940** | **304,426** | **74,891** | **20,623** |
|
| 19 |
+
|
| 20 |
+
source 实例总数:**865,965**(含多源场景)。
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## 目录结构
|
| 25 |
+
|
| 26 |
+
```
|
| 27 |
+
unified_spatial_foa_fsd63_all/
|
| 28 |
+
├── train.jsonl # 329,610 行,每行一个 scene record
|
| 29 |
+
├── valid.jsonl # 35,093 行
|
| 30 |
+
├── test.jsonl # 35,237 行
|
| 31 |
+
├── label_mapping.json # 63 类 FSD 类别映射
|
| 32 |
+
├── summary.json # 整体统计
|
| 33 |
+
└── annotations/ # 逐 scene CSV 标注
|
| 34 |
+
├── train/
|
| 35 |
+
│ ├── sim_static/ # 仿真静态场景
|
| 36 |
+
│ ├── qa_sim/ # 仿真问答场景(lr_pair)
|
| 37 |
+
│ └── dcase_real/ # 真实录音子集
|
| 38 |
+
│ ├── realfoa/ # 自录 FOA(含 inf elevation / -1 distance)
|
| 39 |
+
│ ├── starss22/
|
| 40 |
+
│ ├── starss23/
|
| 41 |
+
│ ├── tau2019/
|
| 42 |
+
│ ├── tau2020/
|
| 43 |
+
│ ├── tau2021/
|
| 44 |
+
│ ├── tau2636586/
|
| 45 |
+
│ └── tau2636594/
|
| 46 |
+
├── valid/ (同结构)
|
| 47 |
+
└── test/ (同结构)
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
## JSONL Schema(每行字段)
|
| 53 |
+
|
| 54 |
+
```jsonc
|
| 55 |
+
{
|
| 56 |
+
"schema_version": "spatial_foa_scene_v1",
|
| 57 |
+
"split": "train", // "train" / "valid" / "test"
|
| 58 |
+
"data_source": "sim_static", // 见下文子集说明
|
| 59 |
+
"dataset": "hm3d", // 细分数据集名(如 hm3d, starss22, realfoa …)
|
| 60 |
+
"scene_id": "train/hm3d/…/000016-foa__354626",
|
| 61 |
+
|
| 62 |
+
"audio": {
|
| 63 |
+
"foa_path": "/path/to/foa.wav", // 4ch B-format FOA 音频,16 kHz
|
| 64 |
+
"duration_seconds": 7.37675
|
| 65 |
+
},
|
| 66 |
+
|
| 67 |
+
"scene_annotation_csv_path": "/path/to/scene.csv", // 场景级 10Hz 逐帧 CSV(见下)
|
| 68 |
+
|
| 69 |
+
"scene_meta": {
|
| 70 |
+
"listener_position_cm": [x, y, z], // 仿真子集有值,真实子集为 null
|
| 71 |
+
"receiver_yaw_deg": 140.99,
|
| 72 |
+
"room": "00009-vLpv2VX547B"
|
| 73 |
+
},
|
| 74 |
+
|
| 75 |
+
"sources": [ // 每个音源的元信息列表
|
| 76 |
+
{
|
| 77 |
+
"label": "wind_instrument", // FSD63 类别名
|
| 78 |
+
"label_id": 59, // 类别 ID(0–62)
|
| 79 |
+
"track_id": 0, // 对应 CSV 中的 track_id
|
| 80 |
+
"source_id": "src00",
|
| 81 |
+
"active_duration_seconds": 4.05,
|
| 82 |
+
"active_times": [[1.0, 5.05]], // 活跃时间段列表
|
| 83 |
+
"direction_start": ["front","left","up"], // 粗粒度方向(可为 null)
|
| 84 |
+
"direction_end": ["front","left","up"],
|
| 85 |
+
"motion": {
|
| 86 |
+
"is_moving": false,
|
| 87 |
+
"pattern": null,
|
| 88 |
+
"description": null,
|
| 89 |
+
"scene_description": null
|
| 90 |
+
},
|
| 91 |
+
"mono_audio_path": "/path/to/mono.wav", // 仿真子集有,真实子集为 null
|
| 92 |
+
"per_source_foa_path": "…",
|
| 93 |
+
"rir_path": "…",
|
| 94 |
+
"source_trajectory_csv_path": "…" // 单源逐帧 CSV(可选用)
|
| 95 |
+
}
|
| 96 |
+
],
|
| 97 |
+
"task_type": null
|
| 98 |
+
}
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### 与旧 JSONL 格式(`load_segments()` 期望格式)的对比
|
| 102 |
+
|
| 103 |
+
| 旧格式字段 | 新格式对应位置 |
|
| 104 |
+
|------------|----------------------------------|
|
| 105 |
+
| `foa_path` | `audio.foa_path` |
|
| 106 |
+
| `csv_path` | `scene_annotation_csv_path` |
|
| 107 |
+
| `length` | `audio.duration_seconds` |
|
| 108 |
+
| `stem` | `scene_id`(需截取最后段作 stem) |
|
| 109 |
+
| `split` | `split`(同名) |
|
| 110 |
+
| `dataset` | `data_source`(或 `dataset`) |
|
| 111 |
+
|
| 112 |
+
> **注意**:新格式与 `generate_segment_qa_pairs.base.load_segments()` **不兼容**,后者期望 `foa_path`、`csv_path`、`stem`、`length` 为扁平键。接入 QA 生成脚本时需要新增适配函数(参见 [待办事项](#待办事项))。
|
| 113 |
+
|
| 114 |
+
---
|
| 115 |
+
|
| 116 |
+
## 场景级 CSV 格式
|
| 117 |
+
|
| 118 |
+
与 DCASE 2024 SELD 基线格式**相同**(无 header 行,6 列,10 Hz 逐帧):
|
| 119 |
+
|
| 120 |
+
```
|
| 121 |
+
frame_idx,class_id,track_id,azimuth_deg,elevation_deg,distance_cm
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
**示例(sim_static,完整标注):**
|
| 125 |
+
```
|
| 126 |
+
10,59,0,13.934,11.313,184
|
| 127 |
+
11,59,0,13.934,11.313,184
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
**示例(dcase_real/realfoa,部分缺失标注):**
|
| 131 |
+
```
|
| 132 |
+
49,17,5,111.000,-inf,-1
|
| 133 |
+
75,17,5,111.000,inf,-1
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
> **重要**:CSV 文件**无 header 行**,可直接被 `parse_csv_rows()` 按现有逻辑解析。
|
| 137 |
+
|
| 138 |
+
---
|
| 139 |
+
|
| 140 |
+
## 特殊标注值(realfoa 子集)
|
| 141 |
+
|
| 142 |
+
`dcase_real/realfoa` 子集��自真实自录 FOA,存在两类标注缺失:
|
| 143 |
+
|
| 144 |
+
### `distance_cm = -1`(距离未知)
|
| 145 |
+
|
| 146 |
+
- 含义:该音源距离完全未知,无法估计。
|
| 147 |
+
- **现有代码已正确处理**:`parse_csv_rows()` 执行 `distance_m = None if distance_cm < 0 else …`,后续所有距离 QA 任务均 gate 在 `span.distance_m is not None` 上,无需改动。
|
| 148 |
+
|
| 149 |
+
### `elevation_deg = ±inf`(仰角符号已知,幅度未知)
|
| 150 |
+
|
| 151 |
+
- `+inf`:确知音源在水平面**以上**,但仰角具体数值未知。
|
| 152 |
+
- `-inf`:确知音源在水平面**以下**,但仰角具体数值未知。
|
| 153 |
+
- **现有代码存在问题**:`float('inf')` 可无声地通过 `parse_csv_rows()`,但会导致:
|
| 154 |
+
- `finalize_event_span()` 中 `median([inf,...]) = inf` → `span.elevation_deg = inf`
|
| 155 |
+
- `format_angle(inf)` → `"inf degrees"`(垃圾答案)
|
| 156 |
+
- v3 elevation bin 分配失败(超出 [-90,90] 范围)
|
| 157 |
+
- `classify_motion()` 中 `elevation_delta = inf` → 错误标记"moving upward"
|
| 158 |
+
- `is_unique_doa_at_frame()` 中 `abs(inf - finite) = inf` → 判断错误
|
| 159 |
+
- **处理方向(待实现,见待办)**:检测 `math.isinf(elevation_deg)` 后,跳过所有仰角幅度相关 QA,仅保留上/下方向(above/below horizon)判断类问题。
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
## 子集说明
|
| 164 |
+
|
| 165 |
+
### `sim_static`(304,426 条)
|
| 166 |
+
|
| 167 |
+
- 来源:基于 HM3D 房间的仿真 FOA,单源静态场景
|
| 168 |
+
- 音源:FSD50K 音频 + 房间 RIR 卷积
|
| 169 |
+
- 标注:完整(azimuth、elevation、distance 均有值)
|
| 170 |
+
- 特点:方位角、仰角覆盖均匀,适合空间定位训练
|
| 171 |
+
|
| 172 |
+
### `qa_sim`(74,891 条)
|
| 173 |
+
|
| 174 |
+
- 来源:QA lr_pair 仿真场景(HM3D 房间,多源)
|
| 175 |
+
- 标注:完整,含多源同时活跃的重叠场景
|
| 176 |
+
- 特点:为 QA 训练特别构造,重叠事件比例较高
|
| 177 |
+
|
| 178 |
+
### `dcase_real`(20,623 条)
|
| 179 |
+
|
| 180 |
+
真实录音子集,包含以下 8 个来源:
|
| 181 |
+
|
| 182 |
+
| 子集 | train | valid | test | 特点 |
|
| 183 |
+
|------|-------|-------|------|------|
|
| 184 |
+
| realfoa | 2,492 | 0 | 70 | 自录 FOA;**含 ±inf elevation、-1 distance** |
|
| 185 |
+
| starss22 | 545 | 355 | 33 | Sony-TAu STARSS 2022 |
|
| 186 |
+
| starss23 | 789 | 556 | 63 | Sony-TAu STARSS 2023 |
|
| 187 |
+
| tau2019 | 994 | 292 | 34 | TAU 2019 空间音频 |
|
| 188 |
+
| tau2020 | 1,050 | 675 | 75 | TAU 2020 |
|
| 189 |
+
| tau2021 | 900 | 810 | 90 | TAU 2021 |
|
| 190 |
+
| tau2636586 | 4,320 | 972 | 108 | TAU 合成扩充 |
|
| 191 |
+
| tau2636594 | 4,320 | 972 | 108 | TAU 合成扩充 |
|
| 192 |
+
|
| 193 |
+
---
|
| 194 |
+
|
| 195 |
+
## 类别体系(FSD63)
|
| 196 |
+
|
| 197 |
+
63 类,定义见 `label_mapping.json`,ID 0–62。
|
| 198 |
+
|
| 199 |
+
常见高频类别(scene 数 top-10,来自 summary.json label_counts):
|
| 200 |
+
`speech (115k)`, `wind_instrument (25k)`, `human_vocalization (24k)`, `singing (24k)`, `tool (23k)`, `laughter (21k)`, `telephone_alarm (19k)`, `breathing (19k)`, `metal_clink (19k)`, `string_instrument (20k)`
|
| 201 |
+
|
| 202 |
+
完整类别列表:
|
| 203 |
+
```
|
| 204 |
+
aircraft, alarm, animal, appliance, bell, bird, body_sound, breathing,
|
| 205 |
+
camera, car, cat, clock, cooking, crack, crackle, crushing, dog, door,
|
| 206 |
+
drawer_cabinet, drum, female_speech, finger_snapping, fire, footsteps,
|
| 207 |
+
frog, glass, gong, guitar, home_sound, human_vocalization, insect,
|
| 208 |
+
keyboard_instrument, kitchenware, knock, laughter, machine, male_speech,
|
| 209 |
+
metal_clink, musical_instrument, ocean, paper, percussion, printer, rain,
|
| 210 |
+
scratch, singing, speech, string_instrument, tape, tearing, telephone_alarm,
|
| 211 |
+
thunderstorm, tool, train, typing, vehicle, war_sound, water, wind,
|
| 212 |
+
wind_instrument, wood, writing, zipper
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
QA 生成时需通过 `--class-mapping-path label_mapping.json` 传入类别映射。
|
| 216 |
+
|
| 217 |
+
---
|
| 218 |
+
|
| 219 |
+
## 与已有训练流程的兼容性
|
| 220 |
+
|
| 221 |
+
### 兼容项
|
| 222 |
+
|
| 223 |
+
- CSV 格式与 DCASE 2024 基线完全一致(无 header,6 列,10 Hz)
|
| 224 |
+
- `distance=-1` 已被 `parse_csv_rows()` 正确转为 `None`,所有距离 QA 已跳过
|
| 225 |
+
- `float('inf')` 在 Python `csv.reader` + `float()` 下可正常解析,不会 crash
|
| 226 |
+
- `scene_annotation_csv_path` 可直接作为 `csv_path` 传入 `parse_csv_rows()`
|
| 227 |
+
|
| 228 |
+
### 不兼容项 / 待处理
|
| 229 |
+
|
| 230 |
+
1. **JSONL 格式不兼容**:`load_segments()` 期望扁平 `{foa_path, csv_path, stem, length, ...}`,新数据为嵌套格式。需新增 `load_segments_unified()` 适配函数。
|
| 231 |
+
|
| 232 |
+
2. **`elevation=±inf` 导致 QA 垃圾输出**:当前代码无 `math.isinf()` 保护,会生成 "inf degrees" 等无效答案,以及错误的运动检测结果。需在 QA 生成层加以处理(跳过 elevation 幅度 QA,仅保留上/下判断)。
|
| 233 |
+
|
| 234 |
+
3. **类别 ID 空间扩展**:FSD63 的 63 个类别 ID(0–62)与旧有 DCASE 29 类不同,QA 生成时须正确传入 `label_mapping.json`。
|
| 235 |
+
|
| 236 |
+
---
|
| 237 |
+
|
| 238 |
+
## 待办事项
|
| 239 |
+
|
| 240 |
+
- [ ] 在 `generate_segment_qa_pairs.py` 中新增 `load_segments_unified(dataset_root, limit_per_split)` 函数,解析新 JSONL schema 并输出 `SegmentRecord` 列表
|
| 241 |
+
- [ ] 为 `elevation=±inf` 添加保护:`finalize_event_span()` 检测 `math.isinf(elevation_deg)`,为 `EventSpan` 增加 `elevation_sign_only: bool` 标志;`add_angle_records()`(v3)在 `elevation_sign_only=True` 时跳过 bin-choice 任务,可选生成新的 `above_below_horizon` 判断题
|
| 242 |
+
- [ ] `classify_motion()` 中 `elevation_delta` 含 inf 时忽略垂直分量,避免误判"moving upward/downward"
|
| 243 |
+
- [ ] `is_unique_doa_at_frame()` 中 elevation=inf 时跳过 elevation 比较维度
|
| 244 |
+
- [ ] 用新数据生成 v6c QA pairs(建议单独输出目录,与旧 all_qa 合并后再做 v12 训练)
|
| 245 |
+
- [ ] 开启 v12 训练,从 v11a stage1 `best_trainable.pt` 继承
|
| 246 |
+
|
| 247 |
+
---
|
| 248 |
+
|
| 249 |
+
## 参考
|
| 250 |
+
|
| 251 |
+
- 数据路径:`/apdcephfs_cq12/share_302080740/user/schmittzhu/data/unified_spatial_foa_fsd63_all/`
|
| 252 |
+
- 类别映射:同目录 `label_mapping.json`
|
| 253 |
+
- 统计汇总:同目录 `summary.json`
|
| 254 |
+
- QA 生成脚本:`DCASE2024_seld_baseline/generate_segment_qa_pairs_v6c.py`
|
| 255 |
+
- 上游训练入口:`train_spatial_beats_qa.py`(BEATs 路径)
|
runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/epoch_metrics.jsonl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"epoch": 1, "train_loss": 0.664092443883419, "train_supervised_tokens": 168.0, "optimizer_steps": 1.0, "epoch_seconds": 2.743562936782837, "micro_steps": 1.0, "valid_loss": 0.7183872366560142, "valid_supervised_tokens": 69109.0, "valid_generate_examples": 4000.0, "valid_exact_match": 0.02575, "step_valid_subset_size": 200.0, "valid_subset_size": 4000.0, "valid_generation_size": 4000.0, "global_optimizer_step": 1.0}
|
runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/processor/processor_config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"feature_extractor": {
|
| 3 |
+
"chunk_length": 30,
|
| 4 |
+
"dither": 0.0,
|
| 5 |
+
"feature_extractor_type": "WhisperFeatureExtractor",
|
| 6 |
+
"feature_size": 128,
|
| 7 |
+
"hop_length": 160,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.5,
|
| 10 |
+
0.5,
|
| 11 |
+
0.5
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 14 |
+
"image_std": [
|
| 15 |
+
0.5,
|
| 16 |
+
0.5,
|
| 17 |
+
0.5
|
| 18 |
+
],
|
| 19 |
+
"max_pixels": 12845056,
|
| 20 |
+
"merge_size": 2,
|
| 21 |
+
"min_pixels": 3136,
|
| 22 |
+
"n_fft": 400,
|
| 23 |
+
"n_samples": 480000,
|
| 24 |
+
"nb_max_frames": 3000,
|
| 25 |
+
"padding_side": "right",
|
| 26 |
+
"padding_value": 0.0,
|
| 27 |
+
"patch_size": 16,
|
| 28 |
+
"return_attention_mask": true,
|
| 29 |
+
"sampling_rate": 16000,
|
| 30 |
+
"temporal_patch_size": 2
|
| 31 |
+
},
|
| 32 |
+
"image_processor": null,
|
| 33 |
+
"processor_class": "Qwen3OmniMoeSpatialProcessor",
|
| 34 |
+
"video_processor": null
|
| 35 |
+
}
|
runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/processor/tokenizer_config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"extra_special_tokens": [
|
| 12 |
+
"<|spatial|>"
|
| 13 |
+
],
|
| 14 |
+
"image_token": "<|image_pad|>",
|
| 15 |
+
"is_local": true,
|
| 16 |
+
"model_max_length": 131072,
|
| 17 |
+
"model_specific_special_tokens": {
|
| 18 |
+
"audio_bos_token": "<|audio_start|>",
|
| 19 |
+
"audio_eos_token": "<|audio_end|>",
|
| 20 |
+
"audio_token": "<|audio_pad|>",
|
| 21 |
+
"image_token": "<|image_pad|>",
|
| 22 |
+
"video_token": "<|video_pad|>",
|
| 23 |
+
"vision_bos_token": "<|vision_start|>",
|
| 24 |
+
"vision_eos_token": "<|vision_end|>"
|
| 25 |
+
},
|
| 26 |
+
"pad_token": "<|endoftext|>",
|
| 27 |
+
"processor_class": "Qwen3OmniMoeSpatialProcessor",
|
| 28 |
+
"split_special_tokens": false,
|
| 29 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 30 |
+
"unk_token": null,
|
| 31 |
+
"video_token": "<|video_pad|>",
|
| 32 |
+
"vision_bos_token": "<|vision_start|>",
|
| 33 |
+
"vision_eos_token": "<|vision_end|>"
|
| 34 |
+
}
|
runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/train_args.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"attn_impl": "flash_attention_2",
|
| 3 |
+
"audio_feature_cache_manifest": null,
|
| 4 |
+
"audio_feature_cache_max_entries": 256,
|
| 5 |
+
"batch_size": 1,
|
| 6 |
+
"beats_checkpoint": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/checkpoints/spatial_beats_ov1_unified_v13d_exp/03_ov123_top4/best.pt",
|
| 7 |
+
"beats_lr": null,
|
| 8 |
+
"beats_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats",
|
| 9 |
+
"device": "cuda:0",
|
| 10 |
+
"device_map": null,
|
| 11 |
+
"distributed": true,
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
+
"encoder_token_rate": 10.0,
|
| 14 |
+
"epochs": 1,
|
| 15 |
+
"grad_accum_steps": 1,
|
| 16 |
+
"gradient_checkpointing": true,
|
| 17 |
+
"local_rank": 0,
|
| 18 |
+
"log_every": 10,
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_dropout": 0.05,
|
| 21 |
+
"lora_lr": null,
|
| 22 |
+
"lora_r": 16,
|
| 23 |
+
"lora_target_modules": [
|
| 24 |
+
"q_proj",
|
| 25 |
+
"k_proj",
|
| 26 |
+
"v_proj",
|
| 27 |
+
"o_proj"
|
| 28 |
+
],
|
| 29 |
+
"lora_target_prefixes": [
|
| 30 |
+
"model.layers"
|
| 31 |
+
],
|
| 32 |
+
"lr": 0.0001,
|
| 33 |
+
"max_grad_norm": 1.0,
|
| 34 |
+
"max_train_samples": 1,
|
| 35 |
+
"max_valid_samples": null,
|
| 36 |
+
"model_id": "/tmp/Qwen3-Omni-30B-A3B-Instruct",
|
| 37 |
+
"num_workers": 4,
|
| 38 |
+
"optimizer_step_per_batch": false,
|
| 39 |
+
"output_dir": "runs/qwen3_curriculum/bench_v4_via_train/easy",
|
| 40 |
+
"persistent_workers": false,
|
| 41 |
+
"prefetch_factor": 2,
|
| 42 |
+
"projector_fp32": false,
|
| 43 |
+
"projector_lr": null,
|
| 44 |
+
"projector_shuffle_factor": 4,
|
| 45 |
+
"projector_type": "pixel_shuffle",
|
| 46 |
+
"projector_weight_decay": null,
|
| 47 |
+
"qa_root": "/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced_v4_prompted/easy",
|
| 48 |
+
"qa_roots": [
|
| 49 |
+
"/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced_v4_prompted/easy"
|
| 50 |
+
],
|
| 51 |
+
"rank": 0,
|
| 52 |
+
"resume_checkpoint_path": "runs/qwen3_curriculum/easy/stage3_beats_lora/checkpoints/best_trainable.pt",
|
| 53 |
+
"resume_model_only": true,
|
| 54 |
+
"resume_tag": null,
|
| 55 |
+
"save_every_epoch": true,
|
| 56 |
+
"save_every_n_optimizer_steps": 1000,
|
| 57 |
+
"save_full_model": false,
|
| 58 |
+
"seed": 1234,
|
| 59 |
+
"spatial_qwen_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen",
|
| 60 |
+
"step_valid_subset_ratio": 0.05,
|
| 61 |
+
"train_mode": "beats_lora",
|
| 62 |
+
"train_split": "test",
|
| 63 |
+
"valid_do_sample": false,
|
| 64 |
+
"valid_every_n_optimizer_steps": 1000,
|
| 65 |
+
"valid_generate_batch_size": 1,
|
| 66 |
+
"valid_generate_full": true,
|
| 67 |
+
"valid_generate_max_samples": 32,
|
| 68 |
+
"valid_max_new_tokens": 80,
|
| 69 |
+
"valid_num_beams": 1,
|
| 70 |
+
"valid_split": "test",
|
| 71 |
+
"valid_subset_ratio": 0.1,
|
| 72 |
+
"warmup_ratio": 0.03,
|
| 73 |
+
"weight_decay": 0.01,
|
| 74 |
+
"world_size": 8
|
| 75 |
+
}
|
runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/valid_predictions/epoch_001.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/valid_predictions/epoch_001.score.json
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"examples": 4000,
|
| 3 |
+
"llm_used_rate": 0.0,
|
| 4 |
+
"overall_correct": 0.3130372081801082,
|
| 5 |
+
"overall_correct_parseable": 0.3194257226327635,
|
| 6 |
+
"parse_rate": 0.98,
|
| 7 |
+
"parse_status_counts": {
|
| 8 |
+
"fail_empty": 0,
|
| 9 |
+
"fail_llm_extract": 0,
|
| 10 |
+
"fail_no_answer_meta": 0,
|
| 11 |
+
"fail_regex": 80,
|
| 12 |
+
"ok": 3920
|
| 13 |
+
},
|
| 14 |
+
"per_task": {
|
| 15 |
+
"detect_source": {
|
| 16 |
+
"correct_all": 0.29439208966945096,
|
| 17 |
+
"correct_parseable": 0.29616821087409323,
|
| 18 |
+
"examples": 667,
|
| 19 |
+
"f1_mean": 0.29616821087409323,
|
| 20 |
+
"llm_used_rate": 0.0,
|
| 21 |
+
"metric_type": "detect_source_f1",
|
| 22 |
+
"parse_rate": 0.9940029985007496,
|
| 23 |
+
"parse_status_counts": {
|
| 24 |
+
"fail_empty": 0,
|
| 25 |
+
"fail_llm_extract": 0,
|
| 26 |
+
"fail_no_answer_meta": 0,
|
| 27 |
+
"fail_regex": 4,
|
| 28 |
+
"ok": 663
|
| 29 |
+
},
|
| 30 |
+
"precision_mean": 0.33056812468577174,
|
| 31 |
+
"recall_mean": 0.28179989944695827
|
| 32 |
+
},
|
| 33 |
+
"detect_time": {
|
| 34 |
+
"correct_all": 0.5529075096115579,
|
| 35 |
+
"correct_parseable": 0.5554055857092005,
|
| 36 |
+
"end_error_mean_s": 2.6058618222891567,
|
| 37 |
+
"examples": 667,
|
| 38 |
+
"iou_at_threshold": 0.6024096385542169,
|
| 39 |
+
"iou_mean": 0.5554055857092005,
|
| 40 |
+
"iou_median": 0.6086956521739131,
|
| 41 |
+
"llm_used_rate": 0.0,
|
| 42 |
+
"metric_type": "time_span_iou",
|
| 43 |
+
"parse_rate": 0.9955022488755623,
|
| 44 |
+
"parse_status_counts": {
|
| 45 |
+
"fail_empty": 0,
|
| 46 |
+
"fail_llm_extract": 0,
|
| 47 |
+
"fail_no_answer_meta": 0,
|
| 48 |
+
"fail_regex": 3,
|
| 49 |
+
"ok": 664
|
| 50 |
+
},
|
| 51 |
+
"start_error_mean_s": 2.066867469879518
|
| 52 |
+
},
|
| 53 |
+
"estimate_azimuth": {
|
| 54 |
+
"acc_gain_over_constant": 0.005641519381977406,
|
| 55 |
+
"acc_macro_by_gt_bin": 0.14531420552003743,
|
| 56 |
+
"acc_per_gt_bin": {
|
| 57 |
+
"[-180,-90)": {
|
| 58 |
+
"acc": 0.0,
|
| 59 |
+
"n": 173
|
| 60 |
+
},
|
| 61 |
+
"[-30,30)": {
|
| 62 |
+
"acc": 0.5943396226415094,
|
| 63 |
+
"n": 106
|
| 64 |
+
},
|
| 65 |
+
"[-90,-30)": {
|
| 66 |
+
"acc": 0.1322314049586777,
|
| 67 |
+
"n": 121
|
| 68 |
+
},
|
| 69 |
+
"[30,90)": {
|
| 70 |
+
"acc": 0.0,
|
| 71 |
+
"n": 100
|
| 72 |
+
},
|
| 73 |
+
"[90,180)": {
|
| 74 |
+
"acc": 0.0,
|
| 75 |
+
"n": 155
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"const_median_baseline_acc": 0.11297709923664122,
|
| 79 |
+
"const_median_baseline_mean_err": 89.39981908396948,
|
| 80 |
+
"const_median_baseline_median_err": 90.09300000000002,
|
| 81 |
+
"const_median_baseline_value_deg": -10.711,
|
| 82 |
+
"correct_all": 0.11861861861861862,
|
| 83 |
+
"correct_is_within_threshold": 0.11861861861861862,
|
| 84 |
+
"correct_parseable": 0.12061068702290076,
|
| 85 |
+
"error_deg_mean": 87.53453816793893,
|
| 86 |
+
"error_deg_median": 87.72200000000001,
|
| 87 |
+
"examples": 666,
|
| 88 |
+
"llm_used_rate": 0.0,
|
| 89 |
+
"median_err_reduction_vs_constant": 2.3710000000000093,
|
| 90 |
+
"metric_type": "er20_angle",
|
| 91 |
+
"parse_rate": 0.9834834834834835,
|
| 92 |
+
"parse_status_counts": {
|
| 93 |
+
"fail_empty": 0,
|
| 94 |
+
"fail_llm_extract": 0,
|
| 95 |
+
"fail_no_answer_meta": 0,
|
| 96 |
+
"fail_regex": 11,
|
| 97 |
+
"ok": 655
|
| 98 |
+
},
|
| 99 |
+
"top1_prediction": -18.1,
|
| 100 |
+
"top1_prediction_share": 0.1648854961832061,
|
| 101 |
+
"unique_prediction_count": 88,
|
| 102 |
+
"unique_prediction_ratio": 0.13435114503816795
|
| 103 |
+
},
|
| 104 |
+
"estimate_elevation": {
|
| 105 |
+
"acc_gain_over_constant": -0.04618186774381405,
|
| 106 |
+
"acc_macro_by_gt_bin": 0.22468907305785274,
|
| 107 |
+
"acc_per_gt_bin": {
|
| 108 |
+
"[-10,10)": {
|
| 109 |
+
"acc": 0.35960591133004927,
|
| 110 |
+
"n": 203
|
| 111 |
+
},
|
| 112 |
+
"[-30,-10)": {
|
| 113 |
+
"acc": 0.6467065868263473,
|
| 114 |
+
"n": 167
|
| 115 |
+
},
|
| 116 |
+
"[-90,-30)": {
|
| 117 |
+
"acc": 0.011363636363636364,
|
| 118 |
+
"n": 88
|
| 119 |
+
},
|
| 120 |
+
"[10,30)": {
|
| 121 |
+
"acc": 0.10576923076923077,
|
| 122 |
+
"n": 104
|
| 123 |
+
},
|
| 124 |
+
"[30,90)": {
|
| 125 |
+
"acc": 0.0,
|
| 126 |
+
"n": 42
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"const_median_baseline_acc": 0.33553719008264465,
|
| 130 |
+
"const_median_baseline_mean_err": Infinity,
|
| 131 |
+
"const_median_baseline_median_err": 15.631,
|
| 132 |
+
"const_median_baseline_value_deg": -3.45,
|
| 133 |
+
"correct_all": 0.2893553223388306,
|
| 134 |
+
"correct_is_within_threshold": 0.2893553223388306,
|
| 135 |
+
"correct_parseable": 0.31900826446280994,
|
| 136 |
+
"error_deg_mean": Infinity,
|
| 137 |
+
"error_deg_median": 16.734,
|
| 138 |
+
"examples": 667,
|
| 139 |
+
"llm_used_rate": 0.0,
|
| 140 |
+
"median_err_reduction_vs_constant": -1.1030000000000015,
|
| 141 |
+
"metric_type": "abs10_angle",
|
| 142 |
+
"parse_rate": 0.9070464767616192,
|
| 143 |
+
"parse_status_counts": {
|
| 144 |
+
"fail_empty": 0,
|
| 145 |
+
"fail_llm_extract": 0,
|
| 146 |
+
"fail_no_answer_meta": 0,
|
| 147 |
+
"fail_regex": 62,
|
| 148 |
+
"ok": 605
|
| 149 |
+
},
|
| 150 |
+
"top1_prediction": -18.1,
|
| 151 |
+
"top1_prediction_share": 0.24462809917355371,
|
| 152 |
+
"unique_prediction_count": 68,
|
| 153 |
+
"unique_prediction_ratio": 0.11239669421487604
|
| 154 |
+
},
|
| 155 |
+
"identify_source_by_doa": {
|
| 156 |
+
"correct_all": 0.2158920539730135,
|
| 157 |
+
"correct_parseable": 0.2158920539730135,
|
| 158 |
+
"examples": 667,
|
| 159 |
+
"llm_used_rate": 0.0,
|
| 160 |
+
"match_stage_counts": {
|
| 161 |
+
"none": 523,
|
| 162 |
+
"substring": 144
|
| 163 |
+
},
|
| 164 |
+
"metric_type": "source_label_match",
|
| 165 |
+
"parse_rate": 1.0,
|
| 166 |
+
"parse_status_counts": {
|
| 167 |
+
"fail_empty": 0,
|
| 168 |
+
"fail_llm_extract": 0,
|
| 169 |
+
"fail_no_answer_meta": 0,
|
| 170 |
+
"fail_regex": 0,
|
| 171 |
+
"ok": 667
|
| 172 |
+
}
|
| 173 |
+
},
|
| 174 |
+
"identify_source_by_location": {
|
| 175 |
+
"correct_all": 0.4069069069069069,
|
| 176 |
+
"correct_parseable": 0.4069069069069069,
|
| 177 |
+
"examples": 666,
|
| 178 |
+
"llm_used_rate": 0.0,
|
| 179 |
+
"match_stage_counts": {
|
| 180 |
+
"none": 395,
|
| 181 |
+
"substring": 271
|
| 182 |
+
},
|
| 183 |
+
"metric_type": "source_label_match",
|
| 184 |
+
"parse_rate": 1.0,
|
| 185 |
+
"parse_status_counts": {
|
| 186 |
+
"fail_empty": 0,
|
| 187 |
+
"fail_llm_extract": 0,
|
| 188 |
+
"fail_no_answer_meta": 0,
|
| 189 |
+
"fail_regex": 0,
|
| 190 |
+
"ok": 666
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"thresholds": {
|
| 195 |
+
"angle_deg": 20.0,
|
| 196 |
+
"azimuth_deg": 20.0,
|
| 197 |
+
"distance_rel": 0.3,
|
| 198 |
+
"elevation_deg": 10.0,
|
| 199 |
+
"iou": 0.5,
|
| 200 |
+
"onset_s": 0.4
|
| 201 |
+
}
|
| 202 |
+
}
|
runs/qwen3_curriculum/bench_v4_via_train/easy.PRE_GEN_FIX_20260519_0014/valid_predictions/epoch_001.scored.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/epoch_metrics.jsonl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"epoch": 1, "train_loss": 0.7423601821064949, "train_supervised_tokens": 168.0, "optimizer_steps": 1.0, "epoch_seconds": 2.3404576778411865, "micro_steps": 1.0, "valid_loss": 0.719199836174988, "valid_supervised_tokens": 69109.0, "valid_generate_examples": 4000.0, "valid_exact_match": 0.02425, "step_valid_subset_size": 200.0, "valid_subset_size": 4000.0, "valid_generation_size": 4000.0, "global_optimizer_step": 1.0}
|
runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/processor/processor_config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"feature_extractor": {
|
| 3 |
+
"chunk_length": 30,
|
| 4 |
+
"dither": 0.0,
|
| 5 |
+
"feature_extractor_type": "WhisperFeatureExtractor",
|
| 6 |
+
"feature_size": 128,
|
| 7 |
+
"hop_length": 160,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.5,
|
| 10 |
+
0.5,
|
| 11 |
+
0.5
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 14 |
+
"image_std": [
|
| 15 |
+
0.5,
|
| 16 |
+
0.5,
|
| 17 |
+
0.5
|
| 18 |
+
],
|
| 19 |
+
"max_pixels": 12845056,
|
| 20 |
+
"merge_size": 2,
|
| 21 |
+
"min_pixels": 3136,
|
| 22 |
+
"n_fft": 400,
|
| 23 |
+
"n_samples": 480000,
|
| 24 |
+
"nb_max_frames": 3000,
|
| 25 |
+
"padding_side": "right",
|
| 26 |
+
"padding_value": 0.0,
|
| 27 |
+
"patch_size": 16,
|
| 28 |
+
"return_attention_mask": true,
|
| 29 |
+
"sampling_rate": 16000,
|
| 30 |
+
"temporal_patch_size": 2
|
| 31 |
+
},
|
| 32 |
+
"image_processor": null,
|
| 33 |
+
"processor_class": "Qwen3OmniMoeSpatialProcessor",
|
| 34 |
+
"video_processor": null
|
| 35 |
+
}
|
runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/processor/tokenizer_config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"extra_special_tokens": [
|
| 12 |
+
"<|spatial|>"
|
| 13 |
+
],
|
| 14 |
+
"image_token": "<|image_pad|>",
|
| 15 |
+
"is_local": true,
|
| 16 |
+
"model_max_length": 131072,
|
| 17 |
+
"model_specific_special_tokens": {
|
| 18 |
+
"audio_bos_token": "<|audio_start|>",
|
| 19 |
+
"audio_eos_token": "<|audio_end|>",
|
| 20 |
+
"audio_token": "<|audio_pad|>",
|
| 21 |
+
"image_token": "<|image_pad|>",
|
| 22 |
+
"video_token": "<|video_pad|>",
|
| 23 |
+
"vision_bos_token": "<|vision_start|>",
|
| 24 |
+
"vision_eos_token": "<|vision_end|>"
|
| 25 |
+
},
|
| 26 |
+
"pad_token": "<|endoftext|>",
|
| 27 |
+
"processor_class": "Qwen3OmniMoeSpatialProcessor",
|
| 28 |
+
"split_special_tokens": false,
|
| 29 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 30 |
+
"unk_token": null,
|
| 31 |
+
"video_token": "<|video_pad|>",
|
| 32 |
+
"vision_bos_token": "<|vision_start|>",
|
| 33 |
+
"vision_eos_token": "<|vision_end|>"
|
| 34 |
+
}
|
runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/train_args.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"attn_impl": "flash_attention_2",
|
| 3 |
+
"audio_feature_cache_manifest": null,
|
| 4 |
+
"audio_feature_cache_max_entries": 256,
|
| 5 |
+
"batch_size": 1,
|
| 6 |
+
"beats_checkpoint": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/checkpoints/spatial_beats_ov1_unified_v13d_exp/03_ov123_top4/best.pt",
|
| 7 |
+
"beats_lr": null,
|
| 8 |
+
"beats_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats",
|
| 9 |
+
"device": "cuda:0",
|
| 10 |
+
"device_map": null,
|
| 11 |
+
"distributed": true,
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
+
"encoder_token_rate": 10.0,
|
| 14 |
+
"epochs": 1,
|
| 15 |
+
"grad_accum_steps": 1,
|
| 16 |
+
"gradient_checkpointing": true,
|
| 17 |
+
"local_rank": 0,
|
| 18 |
+
"log_every": 10,
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_dropout": 0.05,
|
| 21 |
+
"lora_lr": null,
|
| 22 |
+
"lora_r": 16,
|
| 23 |
+
"lora_target_modules": [
|
| 24 |
+
"q_proj",
|
| 25 |
+
"k_proj",
|
| 26 |
+
"v_proj",
|
| 27 |
+
"o_proj"
|
| 28 |
+
],
|
| 29 |
+
"lora_target_prefixes": [
|
| 30 |
+
"model.layers"
|
| 31 |
+
],
|
| 32 |
+
"lr": 0.0001,
|
| 33 |
+
"max_grad_norm": 1.0,
|
| 34 |
+
"max_train_samples": 1,
|
| 35 |
+
"max_valid_samples": null,
|
| 36 |
+
"model_id": "/tmp/Qwen3-Omni-30B-A3B-Instruct",
|
| 37 |
+
"num_workers": 4,
|
| 38 |
+
"optimizer_step_per_batch": false,
|
| 39 |
+
"output_dir": "runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy",
|
| 40 |
+
"persistent_workers": true,
|
| 41 |
+
"prefetch_factor": 2,
|
| 42 |
+
"projector_fp32": false,
|
| 43 |
+
"projector_lr": null,
|
| 44 |
+
"projector_shuffle_factor": 4,
|
| 45 |
+
"projector_type": "pixel_shuffle",
|
| 46 |
+
"projector_weight_decay": null,
|
| 47 |
+
"qa_root": "/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced_v4_prompted/easy",
|
| 48 |
+
"qa_roots": [
|
| 49 |
+
"/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced_v4_prompted/easy"
|
| 50 |
+
],
|
| 51 |
+
"rank": 0,
|
| 52 |
+
"resume_checkpoint_path": "runs/qwen3_curriculum/easy/stage3_beats_lora/checkpoints/best_trainable.pt",
|
| 53 |
+
"resume_model_only": true,
|
| 54 |
+
"resume_tag": null,
|
| 55 |
+
"save_every_epoch": true,
|
| 56 |
+
"save_every_n_optimizer_steps": 999999,
|
| 57 |
+
"save_full_model": false,
|
| 58 |
+
"seed": 1234,
|
| 59 |
+
"spatial_qwen_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen",
|
| 60 |
+
"step_valid_subset_ratio": 0.05,
|
| 61 |
+
"train_mode": "beats_lora",
|
| 62 |
+
"train_split": "test",
|
| 63 |
+
"valid_do_sample": false,
|
| 64 |
+
"valid_every_n_optimizer_steps": 999999,
|
| 65 |
+
"valid_generate_batch_size": 1,
|
| 66 |
+
"valid_generate_full": true,
|
| 67 |
+
"valid_generate_max_samples": 32,
|
| 68 |
+
"valid_max_new_tokens": 80,
|
| 69 |
+
"valid_num_beams": 1,
|
| 70 |
+
"valid_split": "test",
|
| 71 |
+
"valid_subset_ratio": 0.1,
|
| 72 |
+
"warmup_ratio": 0.03,
|
| 73 |
+
"weight_decay": 0.01,
|
| 74 |
+
"world_size": 8
|
| 75 |
+
}
|
runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/valid_predictions/epoch_001.score.json
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"examples": 4000,
|
| 3 |
+
"llm_used_rate": 0.0,
|
| 4 |
+
"overall_correct": 0.3090666965864644,
|
| 5 |
+
"overall_correct_parseable": 0.316019117164074,
|
| 6 |
+
"parse_rate": 0.978,
|
| 7 |
+
"parse_status_counts": {
|
| 8 |
+
"fail_empty": 0,
|
| 9 |
+
"fail_llm_extract": 0,
|
| 10 |
+
"fail_no_answer_meta": 0,
|
| 11 |
+
"fail_regex": 88,
|
| 12 |
+
"ok": 3912
|
| 13 |
+
},
|
| 14 |
+
"per_task": {
|
| 15 |
+
"detect_source": {
|
| 16 |
+
"correct_all": 0.2994038694938245,
|
| 17 |
+
"correct_parseable": 0.30303851434352197,
|
| 18 |
+
"examples": 667,
|
| 19 |
+
"f1_mean": 0.30303851434352197,
|
| 20 |
+
"llm_used_rate": 0.0,
|
| 21 |
+
"metric_type": "detect_source_f1",
|
| 22 |
+
"parse_rate": 0.9880059970014993,
|
| 23 |
+
"parse_status_counts": {
|
| 24 |
+
"fail_empty": 0,
|
| 25 |
+
"fail_llm_extract": 0,
|
| 26 |
+
"fail_no_answer_meta": 0,
|
| 27 |
+
"fail_regex": 8,
|
| 28 |
+
"ok": 659
|
| 29 |
+
},
|
| 30 |
+
"precision_mean": 0.34673748103186647,
|
| 31 |
+
"recall_mean": 0.2862923621648963
|
| 32 |
+
},
|
| 33 |
+
"detect_time": {
|
| 34 |
+
"correct_all": 0.5480725718043127,
|
| 35 |
+
"correct_parseable": 0.5522120927393905,
|
| 36 |
+
"end_error_mean_s": 2.5945502265861027,
|
| 37 |
+
"examples": 667,
|
| 38 |
+
"iou_at_threshold": 0.6057401812688822,
|
| 39 |
+
"iou_mean": 0.5522120927393905,
|
| 40 |
+
"iou_median": 0.606203007518797,
|
| 41 |
+
"llm_used_rate": 0.0,
|
| 42 |
+
"metric_type": "time_span_iou",
|
| 43 |
+
"parse_rate": 0.992503748125937,
|
| 44 |
+
"parse_status_counts": {
|
| 45 |
+
"fail_empty": 0,
|
| 46 |
+
"fail_llm_extract": 0,
|
| 47 |
+
"fail_no_answer_meta": 0,
|
| 48 |
+
"fail_regex": 5,
|
| 49 |
+
"ok": 662
|
| 50 |
+
},
|
| 51 |
+
"start_error_mean_s": 2.058308157099698
|
| 52 |
+
},
|
| 53 |
+
"estimate_azimuth": {
|
| 54 |
+
"acc_gain_over_constant": 0.0009918175055789735,
|
| 55 |
+
"acc_macro_by_gt_bin": 0.13834095673718314,
|
| 56 |
+
"acc_per_gt_bin": {
|
| 57 |
+
"[-180,-90)": {
|
| 58 |
+
"acc": 0.0,
|
| 59 |
+
"n": 174
|
| 60 |
+
},
|
| 61 |
+
"[-30,30)": {
|
| 62 |
+
"acc": 0.5566037735849056,
|
| 63 |
+
"n": 106
|
| 64 |
+
},
|
| 65 |
+
"[-90,-30)": {
|
| 66 |
+
"acc": 0.125,
|
| 67 |
+
"n": 120
|
| 68 |
+
},
|
| 69 |
+
"[30,90)": {
|
| 70 |
+
"acc": 0.010101010101010102,
|
| 71 |
+
"n": 99
|
| 72 |
+
},
|
| 73 |
+
"[90,180)": {
|
| 74 |
+
"acc": 0.0,
|
| 75 |
+
"n": 155
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"const_median_baseline_acc": 0.11162079510703364,
|
| 79 |
+
"const_median_baseline_mean_err": 89.5508264525994,
|
| 80 |
+
"const_median_baseline_median_err": 90.50300000000001,
|
| 81 |
+
"const_median_baseline_value_deg": -11.294,
|
| 82 |
+
"correct_all": 0.11261261261261261,
|
| 83 |
+
"correct_is_within_threshold": 0.11261261261261261,
|
| 84 |
+
"correct_parseable": 0.11467889908256881,
|
| 85 |
+
"error_deg_mean": 87.97856039755351,
|
| 86 |
+
"error_deg_median": 88.28200000000001,
|
| 87 |
+
"examples": 666,
|
| 88 |
+
"llm_used_rate": 0.0,
|
| 89 |
+
"median_err_reduction_vs_constant": 2.2210000000000036,
|
| 90 |
+
"metric_type": "er20_angle",
|
| 91 |
+
"parse_rate": 0.9819819819819819,
|
| 92 |
+
"parse_status_counts": {
|
| 93 |
+
"fail_empty": 0,
|
| 94 |
+
"fail_llm_extract": 0,
|
| 95 |
+
"fail_no_answer_meta": 0,
|
| 96 |
+
"fail_regex": 12,
|
| 97 |
+
"ok": 654
|
| 98 |
+
},
|
| 99 |
+
"top1_prediction": -18.1,
|
| 100 |
+
"top1_prediction_share": 0.16055045871559634,
|
| 101 |
+
"unique_prediction_count": 88,
|
| 102 |
+
"unique_prediction_ratio": 0.1345565749235474
|
| 103 |
+
},
|
| 104 |
+
"estimate_elevation": {
|
| 105 |
+
"acc_gain_over_constant": -0.0476111282107291,
|
| 106 |
+
"acc_macro_by_gt_bin": 0.22207134493831174,
|
| 107 |
+
"acc_per_gt_bin": {
|
| 108 |
+
"[-10,10)": {
|
| 109 |
+
"acc": 0.3382352941176471,
|
| 110 |
+
"n": 204
|
| 111 |
+
},
|
| 112 |
+
"[-30,-10)": {
|
| 113 |
+
"acc": 0.6463414634146342,
|
| 114 |
+
"n": 164
|
| 115 |
+
},
|
| 116 |
+
"[-90,-30)": {
|
| 117 |
+
"acc": 0.011494252873563218,
|
| 118 |
+
"n": 87
|
| 119 |
+
},
|
| 120 |
+
"[10,30)": {
|
| 121 |
+
"acc": 0.11428571428571428,
|
| 122 |
+
"n": 105
|
| 123 |
+
},
|
| 124 |
+
"[30,90)": {
|
| 125 |
+
"acc": 0.0,
|
| 126 |
+
"n": 43
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"const_median_baseline_acc": 0.3294701986754967,
|
| 130 |
+
"const_median_baseline_mean_err": Infinity,
|
| 131 |
+
"const_median_baseline_median_err": 15.6485,
|
| 132 |
+
"const_median_baseline_value_deg": -2.452,
|
| 133 |
+
"correct_all": 0.2818590704647676,
|
| 134 |
+
"correct_is_within_threshold": 0.2818590704647676,
|
| 135 |
+
"correct_parseable": 0.31125827814569534,
|
| 136 |
+
"error_deg_mean": Infinity,
|
| 137 |
+
"error_deg_median": 17.038,
|
| 138 |
+
"examples": 667,
|
| 139 |
+
"llm_used_rate": 0.0,
|
| 140 |
+
"median_err_reduction_vs_constant": -1.3895,
|
| 141 |
+
"metric_type": "abs10_angle",
|
| 142 |
+
"parse_rate": 0.9055472263868066,
|
| 143 |
+
"parse_status_counts": {
|
| 144 |
+
"fail_empty": 0,
|
| 145 |
+
"fail_llm_extract": 0,
|
| 146 |
+
"fail_no_answer_meta": 0,
|
| 147 |
+
"fail_regex": 63,
|
| 148 |
+
"ok": 604
|
| 149 |
+
},
|
| 150 |
+
"top1_prediction": -18.1,
|
| 151 |
+
"top1_prediction_share": 0.23344370860927152,
|
| 152 |
+
"unique_prediction_count": 70,
|
| 153 |
+
"unique_prediction_ratio": 0.11589403973509933
|
| 154 |
+
},
|
| 155 |
+
"identify_source_by_doa": {
|
| 156 |
+
"correct_all": 0.21739130434782608,
|
| 157 |
+
"correct_parseable": 0.21739130434782608,
|
| 158 |
+
"examples": 667,
|
| 159 |
+
"llm_used_rate": 0.0,
|
| 160 |
+
"match_stage_counts": {
|
| 161 |
+
"none": 522,
|
| 162 |
+
"substring": 145
|
| 163 |
+
},
|
| 164 |
+
"metric_type": "source_label_match",
|
| 165 |
+
"parse_rate": 1.0,
|
| 166 |
+
"parse_status_counts": {
|
| 167 |
+
"fail_empty": 0,
|
| 168 |
+
"fail_llm_extract": 0,
|
| 169 |
+
"fail_no_answer_meta": 0,
|
| 170 |
+
"fail_regex": 0,
|
| 171 |
+
"ok": 667
|
| 172 |
+
}
|
| 173 |
+
},
|
| 174 |
+
"identify_source_by_location": {
|
| 175 |
+
"correct_all": 0.3948948948948949,
|
| 176 |
+
"correct_parseable": 0.3948948948948949,
|
| 177 |
+
"examples": 666,
|
| 178 |
+
"llm_used_rate": 0.0,
|
| 179 |
+
"match_stage_counts": {
|
| 180 |
+
"none": 403,
|
| 181 |
+
"substring": 263
|
| 182 |
+
},
|
| 183 |
+
"metric_type": "source_label_match",
|
| 184 |
+
"parse_rate": 1.0,
|
| 185 |
+
"parse_status_counts": {
|
| 186 |
+
"fail_empty": 0,
|
| 187 |
+
"fail_llm_extract": 0,
|
| 188 |
+
"fail_no_answer_meta": 0,
|
| 189 |
+
"fail_regex": 0,
|
| 190 |
+
"ok": 666
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"thresholds": {
|
| 195 |
+
"angle_deg": 20.0,
|
| 196 |
+
"azimuth_deg": 20.0,
|
| 197 |
+
"distance_rel": 0.3,
|
| 198 |
+
"elevation_deg": 10.0,
|
| 199 |
+
"iou": 0.5,
|
| 200 |
+
"onset_s": 0.4
|
| 201 |
+
}
|
| 202 |
+
}
|
runs/qwen3_curriculum/easy/stage3_beats_lora/bench_v4_via_train/easy/valid_predictions/epoch_001.scored.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/qwen3_curriculum/easy/stage3_beats_lora/epoch_metrics.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"epoch": 1, "train_loss": 0.3592844999662934, "train_supervised_tokens": 11843369.0, "optimizer_steps": 9796.0, "epoch_seconds": 51669.55358290672, "micro_steps": 39181.0, "valid_loss": 0.4098466007066923, "valid_supervised_tokens": 1289631.0, "valid_generate_examples": 32.0, "valid_exact_match": 0.0, "step_valid_subset_size": 3292.0, "valid_subset_size": 65850.0, "valid_generation_size": 32.0, "global_optimizer_step": 9796.0}
|
| 2 |
+
{"epoch": 2, "train_loss": 0.3392781011698098, "train_supervised_tokens": 11843369.0, "optimizer_steps": 9796.0, "epoch_seconds": 53220.040230989456, "micro_steps": 39181.0, "valid_loss": 0.39830992954270594, "valid_supervised_tokens": 1289631.0, "valid_generate_examples": 32.0, "valid_exact_match": 0.0, "step_valid_subset_size": 3292.0, "valid_subset_size": 65850.0, "valid_generation_size": 32.0, "global_optimizer_step": 19592.0}
|
| 3 |
+
{"epoch": 3, "train_loss": 0.32576761328400655, "train_supervised_tokens": 11843369.0, "optimizer_steps": 9796.0, "epoch_seconds": 54061.63148808479, "micro_steps": 39181.0, "valid_loss": 0.3947276146043098, "valid_supervised_tokens": 1289631.0, "valid_generate_examples": 32.0, "valid_exact_match": 0.0, "step_valid_subset_size": 3292.0, "valid_subset_size": 65850.0, "valid_generation_size": 32.0, "global_optimizer_step": 29388.0}
|
runs/qwen3_curriculum/easy/stage3_beats_lora/train_args.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"attn_impl": "flash_attention_2",
|
| 3 |
+
"audio_feature_cache_manifest": null,
|
| 4 |
+
"audio_feature_cache_max_entries": 256,
|
| 5 |
+
"batch_size": 2,
|
| 6 |
+
"beats_checkpoint": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/checkpoints/spatial_beats_ov1_unified_v13d_exp/03_ov123_top4/best.pt",
|
| 7 |
+
"beats_lr": 1e-06,
|
| 8 |
+
"beats_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats",
|
| 9 |
+
"device": "cuda:0",
|
| 10 |
+
"device_map": null,
|
| 11 |
+
"distributed": true,
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
+
"encoder_token_rate": 10.0,
|
| 14 |
+
"epochs": 3,
|
| 15 |
+
"grad_accum_steps": 4,
|
| 16 |
+
"gradient_checkpointing": true,
|
| 17 |
+
"local_rank": 0,
|
| 18 |
+
"log_every": 10,
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_dropout": 0.05,
|
| 21 |
+
"lora_lr": 3e-05,
|
| 22 |
+
"lora_r": 16,
|
| 23 |
+
"lora_target_modules": [
|
| 24 |
+
"q_proj",
|
| 25 |
+
"k_proj",
|
| 26 |
+
"v_proj",
|
| 27 |
+
"o_proj"
|
| 28 |
+
],
|
| 29 |
+
"lora_target_prefixes": [
|
| 30 |
+
"model.layers"
|
| 31 |
+
],
|
| 32 |
+
"lr": 3e-05,
|
| 33 |
+
"max_grad_norm": 1.0,
|
| 34 |
+
"max_train_samples": null,
|
| 35 |
+
"max_valid_samples": null,
|
| 36 |
+
"model_id": "/tmp/Qwen3-Omni-30B-A3B-Instruct",
|
| 37 |
+
"num_workers": 4,
|
| 38 |
+
"optimizer_step_per_batch": false,
|
| 39 |
+
"output_dir": "./runs/qwen3_curriculum/easy/stage3_beats_lora",
|
| 40 |
+
"persistent_workers": true,
|
| 41 |
+
"prefetch_factor": 2,
|
| 42 |
+
"projector_fp32": false,
|
| 43 |
+
"projector_lr": 1e-06,
|
| 44 |
+
"projector_shuffle_factor": 4,
|
| 45 |
+
"projector_type": "pixel_shuffle",
|
| 46 |
+
"projector_weight_decay": null,
|
| 47 |
+
"qa_root": "/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced/easy",
|
| 48 |
+
"qa_roots": [
|
| 49 |
+
"/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced/easy"
|
| 50 |
+
],
|
| 51 |
+
"rank": 0,
|
| 52 |
+
"resume_checkpoint_path": "./runs/qwen3_curriculum/easy/stage2_encoder_lora/checkpoints/best_trainable.pt",
|
| 53 |
+
"resume_model_only": true,
|
| 54 |
+
"resume_tag": null,
|
| 55 |
+
"save_every_epoch": true,
|
| 56 |
+
"save_every_n_optimizer_steps": 500,
|
| 57 |
+
"save_full_model": false,
|
| 58 |
+
"seed": 1234,
|
| 59 |
+
"spatial_qwen_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen",
|
| 60 |
+
"step_valid_subset_ratio": 0.05,
|
| 61 |
+
"train_mode": "beats_lora",
|
| 62 |
+
"train_split": "train",
|
| 63 |
+
"valid_do_sample": false,
|
| 64 |
+
"valid_every_n_optimizer_steps": 500,
|
| 65 |
+
"valid_generate_batch_size": 1,
|
| 66 |
+
"valid_generate_full": false,
|
| 67 |
+
"valid_generate_max_samples": 32,
|
| 68 |
+
"valid_max_new_tokens": 96,
|
| 69 |
+
"valid_num_beams": 1,
|
| 70 |
+
"valid_split": "valid",
|
| 71 |
+
"valid_subset_ratio": 0.1,
|
| 72 |
+
"warmup_ratio": 0.03,
|
| 73 |
+
"weight_decay": 0.01,
|
| 74 |
+
"world_size": 8
|
| 75 |
+
}
|
runs/qwen3_full_v4_easy/stage_encoder_lora/epoch_metrics.jsonl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"epoch": 1, "train_loss": 0.4386036706659937, "train_supervised_tokens": 11843369.0, "optimizer_steps": 9796.0, "epoch_seconds": 43788.69994306564, "micro_steps": 39181.0, "valid_loss": 0.4266115554512279, "valid_supervised_tokens": 69109.0, "valid_generate_examples": 4000.0, "valid_exact_match": 0.1125, "step_valid_subset_size": 1.0, "valid_subset_size": 4000.0, "valid_generation_size": 4000.0, "global_optimizer_step": 9796.0}
|
runs/qwen3_full_v4_easy/stage_encoder_lora/processor/processor_config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"feature_extractor": {
|
| 3 |
+
"chunk_length": 30,
|
| 4 |
+
"dither": 0.0,
|
| 5 |
+
"feature_extractor_type": "WhisperFeatureExtractor",
|
| 6 |
+
"feature_size": 128,
|
| 7 |
+
"hop_length": 160,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.5,
|
| 10 |
+
0.5,
|
| 11 |
+
0.5
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 14 |
+
"image_std": [
|
| 15 |
+
0.5,
|
| 16 |
+
0.5,
|
| 17 |
+
0.5
|
| 18 |
+
],
|
| 19 |
+
"max_pixels": 12845056,
|
| 20 |
+
"merge_size": 2,
|
| 21 |
+
"min_pixels": 3136,
|
| 22 |
+
"n_fft": 400,
|
| 23 |
+
"n_samples": 480000,
|
| 24 |
+
"nb_max_frames": 3000,
|
| 25 |
+
"padding_side": "right",
|
| 26 |
+
"padding_value": 0.0,
|
| 27 |
+
"patch_size": 16,
|
| 28 |
+
"return_attention_mask": true,
|
| 29 |
+
"sampling_rate": 16000,
|
| 30 |
+
"temporal_patch_size": 2
|
| 31 |
+
},
|
| 32 |
+
"image_processor": null,
|
| 33 |
+
"processor_class": "Qwen3OmniMoeSpatialProcessor",
|
| 34 |
+
"video_processor": null
|
| 35 |
+
}
|
runs/qwen3_full_v4_easy/stage_encoder_lora/processor/tokenizer_config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"extra_special_tokens": [
|
| 12 |
+
"<|spatial|>"
|
| 13 |
+
],
|
| 14 |
+
"image_token": "<|image_pad|>",
|
| 15 |
+
"is_local": true,
|
| 16 |
+
"model_max_length": 131072,
|
| 17 |
+
"model_specific_special_tokens": {
|
| 18 |
+
"audio_bos_token": "<|audio_start|>",
|
| 19 |
+
"audio_eos_token": "<|audio_end|>",
|
| 20 |
+
"audio_token": "<|audio_pad|>",
|
| 21 |
+
"image_token": "<|image_pad|>",
|
| 22 |
+
"video_token": "<|video_pad|>",
|
| 23 |
+
"vision_bos_token": "<|vision_start|>",
|
| 24 |
+
"vision_eos_token": "<|vision_end|>"
|
| 25 |
+
},
|
| 26 |
+
"pad_token": "<|endoftext|>",
|
| 27 |
+
"processor_class": "Qwen3OmniMoeSpatialProcessor",
|
| 28 |
+
"split_special_tokens": false,
|
| 29 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 30 |
+
"unk_token": null,
|
| 31 |
+
"video_token": "<|video_pad|>",
|
| 32 |
+
"vision_bos_token": "<|vision_start|>",
|
| 33 |
+
"vision_eos_token": "<|vision_end|>"
|
| 34 |
+
}
|
runs/qwen3_full_v4_easy/stage_encoder_lora/train_args.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"attn_impl": "flash_attention_2",
|
| 3 |
+
"audio_feature_cache_manifest": null,
|
| 4 |
+
"audio_feature_cache_max_entries": 256,
|
| 5 |
+
"batch_size": 2,
|
| 6 |
+
"beats_checkpoint": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/checkpoints/spatial_beats_ov1_unified_v13d_exp/03_ov123_top4/best.pt",
|
| 7 |
+
"beats_lr": null,
|
| 8 |
+
"beats_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats",
|
| 9 |
+
"device": "cuda:0",
|
| 10 |
+
"device_map": null,
|
| 11 |
+
"distributed": true,
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
+
"encoder_token_rate": 10.0,
|
| 14 |
+
"epochs": 2,
|
| 15 |
+
"grad_accum_steps": 4,
|
| 16 |
+
"gradient_checkpointing": true,
|
| 17 |
+
"local_rank": 0,
|
| 18 |
+
"log_every": 10,
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_dropout": 0.05,
|
| 21 |
+
"lora_lr": 5e-05,
|
| 22 |
+
"lora_r": 16,
|
| 23 |
+
"lora_target_modules": [
|
| 24 |
+
"q_proj",
|
| 25 |
+
"k_proj",
|
| 26 |
+
"v_proj",
|
| 27 |
+
"o_proj"
|
| 28 |
+
],
|
| 29 |
+
"lora_target_prefixes": [
|
| 30 |
+
"model.layers"
|
| 31 |
+
],
|
| 32 |
+
"lr": 5e-05,
|
| 33 |
+
"max_grad_norm": 1.0,
|
| 34 |
+
"max_train_samples": null,
|
| 35 |
+
"max_valid_samples": null,
|
| 36 |
+
"model_id": "/tmp/Qwen3-Omni-30B-A3B-Instruct",
|
| 37 |
+
"num_workers": 4,
|
| 38 |
+
"optimizer_step_per_batch": false,
|
| 39 |
+
"output_dir": "/apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/zzy/Spatial-Qwen/runs/qwen3_full_v4_easy/stage_encoder_lora",
|
| 40 |
+
"persistent_workers": true,
|
| 41 |
+
"prefetch_factor": 2,
|
| 42 |
+
"projector_fp32": false,
|
| 43 |
+
"projector_lr": 3e-05,
|
| 44 |
+
"projector_shuffle_factor": 4,
|
| 45 |
+
"projector_type": "pixel_shuffle",
|
| 46 |
+
"projector_weight_decay": null,
|
| 47 |
+
"qa_root": "/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced_v4/easy",
|
| 48 |
+
"qa_roots": [
|
| 49 |
+
"/apdcephfs_cq10/share_1603164/user/schmittzhu/data/process_data/genQA/all_qa_llm_by_difficulty_v2_filtered_balanced_v4/easy"
|
| 50 |
+
],
|
| 51 |
+
"rank": 0,
|
| 52 |
+
"resume_checkpoint_path": "/apdcephfs_fsgm/share_303840540/hunyuan/jensenwang/zzy/Spatial-Qwen/runs/qwen3_quick_v4_easy_10pct/stage_encoder_lora_ep2-3/checkpoints/best_trainable.pt",
|
| 53 |
+
"resume_model_only": true,
|
| 54 |
+
"resume_tag": null,
|
| 55 |
+
"save_every_epoch": true,
|
| 56 |
+
"save_every_n_optimizer_steps": 5000,
|
| 57 |
+
"save_full_model": false,
|
| 58 |
+
"seed": 1234,
|
| 59 |
+
"spatial_qwen_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen",
|
| 60 |
+
"step_valid_subset_ratio": 0.0,
|
| 61 |
+
"train_mode": "encoder_lora",
|
| 62 |
+
"train_split": "train",
|
| 63 |
+
"valid_do_sample": false,
|
| 64 |
+
"valid_every_n_optimizer_steps": 999999,
|
| 65 |
+
"valid_generate_batch_size": 1,
|
| 66 |
+
"valid_generate_full": true,
|
| 67 |
+
"valid_generate_max_samples": 32,
|
| 68 |
+
"valid_max_new_tokens": 96,
|
| 69 |
+
"valid_num_beams": 1,
|
| 70 |
+
"valid_split": "test",
|
| 71 |
+
"valid_subset_ratio": 1.0,
|
| 72 |
+
"warmup_ratio": 0.03,
|
| 73 |
+
"weight_decay": 0.01,
|
| 74 |
+
"world_size": 8
|
| 75 |
+
}
|
runs/qwen3_full_v4_easy/stage_encoder_lora/valid_predictions/epoch_001.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/qwen3_full_v4_easy/stage_encoder_lora/valid_predictions/epoch_001.score.json
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"examples": 4000,
|
| 3 |
+
"llm_used_rate": 0.0,
|
| 4 |
+
"overall_correct": 0.5682040188178945,
|
| 5 |
+
"overall_correct_parseable": 0.5682040188178945,
|
| 6 |
+
"parse_rate": 1.0,
|
| 7 |
+
"parse_status_counts": {
|
| 8 |
+
"fail_empty": 0,
|
| 9 |
+
"fail_llm_extract": 0,
|
| 10 |
+
"fail_no_answer_meta": 0,
|
| 11 |
+
"fail_regex": 0,
|
| 12 |
+
"ok": 4000
|
| 13 |
+
},
|
| 14 |
+
"per_task": {
|
| 15 |
+
"detect_source": {
|
| 16 |
+
"correct_all": 0.2994716927250661,
|
| 17 |
+
"correct_parseable": 0.2994716927250661,
|
| 18 |
+
"examples": 667,
|
| 19 |
+
"f1_mean": 0.2994716927250661,
|
| 20 |
+
"llm_used_rate": 0.0,
|
| 21 |
+
"metric_type": "detect_source_f1",
|
| 22 |
+
"parse_rate": 1.0,
|
| 23 |
+
"parse_status_counts": {
|
| 24 |
+
"fail_empty": 0,
|
| 25 |
+
"fail_llm_extract": 0,
|
| 26 |
+
"fail_no_answer_meta": 0,
|
| 27 |
+
"fail_regex": 0,
|
| 28 |
+
"ok": 667
|
| 29 |
+
},
|
| 30 |
+
"precision_mean": 0.3038230884557721,
|
| 31 |
+
"recall_mean": 0.2975655029628043
|
| 32 |
+
},
|
| 33 |
+
"detect_time": {
|
| 34 |
+
"correct_all": 0.703251058806535,
|
| 35 |
+
"correct_parseable": 0.703251058806535,
|
| 36 |
+
"end_error_mean_s": 1.5427623688155923,
|
| 37 |
+
"examples": 667,
|
| 38 |
+
"iou_at_threshold": 0.7436281859070465,
|
| 39 |
+
"iou_mean": 0.703251058806535,
|
| 40 |
+
"iou_median": 0.8749999999999999,
|
| 41 |
+
"llm_used_rate": 0.0,
|
| 42 |
+
"metric_type": "time_span_iou",
|
| 43 |
+
"parse_rate": 1.0,
|
| 44 |
+
"parse_status_counts": {
|
| 45 |
+
"fail_empty": 0,
|
| 46 |
+
"fail_llm_extract": 0,
|
| 47 |
+
"fail_no_answer_meta": 0,
|
| 48 |
+
"fail_regex": 0,
|
| 49 |
+
"ok": 667
|
| 50 |
+
},
|
| 51 |
+
"start_error_mean_s": 1.9649175412293851
|
| 52 |
+
},
|
| 53 |
+
"estimate_azimuth": {
|
| 54 |
+
"acc_gain_over_constant": 0.49549549549549554,
|
| 55 |
+
"acc_macro_by_gt_bin": 0.6013221746381812,
|
| 56 |
+
"acc_per_gt_bin": {
|
| 57 |
+
"[-180,-90)": {
|
| 58 |
+
"acc": 0.7068965517241379,
|
| 59 |
+
"n": 174
|
| 60 |
+
},
|
| 61 |
+
"[-30,30)": {
|
| 62 |
+
"acc": 0.6542056074766355,
|
| 63 |
+
"n": 107
|
| 64 |
+
},
|
| 65 |
+
"[-90,-30)": {
|
| 66 |
+
"acc": 0.5983606557377049,
|
| 67 |
+
"n": 122
|
| 68 |
+
},
|
| 69 |
+
"[30,90)": {
|
| 70 |
+
"acc": 0.5533980582524272,
|
| 71 |
+
"n": 103
|
| 72 |
+
},
|
| 73 |
+
"[90,180)": {
|
| 74 |
+
"acc": 0.49375,
|
| 75 |
+
"n": 160
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"const_median_baseline_acc": 0.10810810810810811,
|
| 79 |
+
"const_median_baseline_mean_err": 89.60612087087087,
|
| 80 |
+
"const_median_baseline_median_err": 91.30099999999999,
|
| 81 |
+
"const_median_baseline_value_deg": -9.4565,
|
| 82 |
+
"correct_all": 0.6036036036036037,
|
| 83 |
+
"correct_is_within_threshold": 0.6036036036036037,
|
| 84 |
+
"correct_parseable": 0.6036036036036037,
|
| 85 |
+
"error_deg_mean": 31.44257282282282,
|
| 86 |
+
"error_deg_median": 14.547999999999996,
|
| 87 |
+
"examples": 666,
|
| 88 |
+
"llm_used_rate": 0.0,
|
| 89 |
+
"median_err_reduction_vs_constant": 76.75299999999999,
|
| 90 |
+
"metric_type": "er20_angle",
|
| 91 |
+
"parse_rate": 1.0,
|
| 92 |
+
"parse_status_counts": {
|
| 93 |
+
"fail_empty": 0,
|
| 94 |
+
"fail_llm_extract": 0,
|
| 95 |
+
"fail_no_answer_meta": 0,
|
| 96 |
+
"fail_regex": 0,
|
| 97 |
+
"ok": 666
|
| 98 |
+
},
|
| 99 |
+
"top1_prediction": -144.2,
|
| 100 |
+
"top1_prediction_share": 0.036036036036036036,
|
| 101 |
+
"unique_prediction_count": 250,
|
| 102 |
+
"unique_prediction_ratio": 0.37537537537537535
|
| 103 |
+
},
|
| 104 |
+
"estimate_elevation": {
|
| 105 |
+
"acc_gain_over_constant": 0.3148425787106447,
|
| 106 |
+
"acc_macro_by_gt_bin": 0.567338611760575,
|
| 107 |
+
"acc_per_gt_bin": {
|
| 108 |
+
"[-10,10)": {
|
| 109 |
+
"acc": 0.7022222222222222,
|
| 110 |
+
"n": 225
|
| 111 |
+
},
|
| 112 |
+
"[-30,-10)": {
|
| 113 |
+
"acc": 0.7821229050279329,
|
| 114 |
+
"n": 179
|
| 115 |
+
},
|
| 116 |
+
"[-90,-30)": {
|
| 117 |
+
"acc": 0.422680412371134,
|
| 118 |
+
"n": 97
|
| 119 |
+
},
|
| 120 |
+
"[10,30)": {
|
| 121 |
+
"acc": 0.6470588235294118,
|
| 122 |
+
"n": 119
|
| 123 |
+
},
|
| 124 |
+
"[30,90)": {
|
| 125 |
+
"acc": 0.2826086956521739,
|
| 126 |
+
"n": 46
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"const_median_baseline_acc": 0.328335832083958,
|
| 130 |
+
"const_median_baseline_mean_err": Infinity,
|
| 131 |
+
"const_median_baseline_median_err": 15.456999999999999,
|
| 132 |
+
"const_median_baseline_value_deg": -2.844,
|
| 133 |
+
"correct_all": 0.6431784107946027,
|
| 134 |
+
"correct_is_within_threshold": 0.6431784107946027,
|
| 135 |
+
"correct_parseable": 0.6431784107946027,
|
| 136 |
+
"error_deg_mean": Infinity,
|
| 137 |
+
"error_deg_median": 6.688999999999999,
|
| 138 |
+
"examples": 667,
|
| 139 |
+
"llm_used_rate": 0.0,
|
| 140 |
+
"median_err_reduction_vs_constant": 8.768,
|
| 141 |
+
"metric_type": "abs10_angle",
|
| 142 |
+
"parse_rate": 1.0,
|
| 143 |
+
"parse_status_counts": {
|
| 144 |
+
"fail_empty": 0,
|
| 145 |
+
"fail_llm_extract": 0,
|
| 146 |
+
"fail_no_answer_meta": 0,
|
| 147 |
+
"fail_regex": 0,
|
| 148 |
+
"ok": 667
|
| 149 |
+
},
|
| 150 |
+
"top1_prediction": -10.0,
|
| 151 |
+
"top1_prediction_share": 0.10944527736131934,
|
| 152 |
+
"unique_prediction_count": 83,
|
| 153 |
+
"unique_prediction_ratio": 0.12443778110944528
|
| 154 |
+
},
|
| 155 |
+
"identify_source_by_doa": {
|
| 156 |
+
"correct_all": 0.6101949025487257,
|
| 157 |
+
"correct_parseable": 0.6101949025487257,
|
| 158 |
+
"examples": 667,
|
| 159 |
+
"llm_used_rate": 0.0,
|
| 160 |
+
"match_stage_counts": {
|
| 161 |
+
"none": 260,
|
| 162 |
+
"substring": 407
|
| 163 |
+
},
|
| 164 |
+
"metric_type": "source_label_match",
|
| 165 |
+
"parse_rate": 1.0,
|
| 166 |
+
"parse_status_counts": {
|
| 167 |
+
"fail_empty": 0,
|
| 168 |
+
"fail_llm_extract": 0,
|
| 169 |
+
"fail_no_answer_meta": 0,
|
| 170 |
+
"fail_regex": 0,
|
| 171 |
+
"ok": 667
|
| 172 |
+
}
|
| 173 |
+
},
|
| 174 |
+
"identify_source_by_location": {
|
| 175 |
+
"correct_all": 0.5495495495495496,
|
| 176 |
+
"correct_parseable": 0.5495495495495496,
|
| 177 |
+
"examples": 666,
|
| 178 |
+
"llm_used_rate": 0.0,
|
| 179 |
+
"match_stage_counts": {
|
| 180 |
+
"none": 300,
|
| 181 |
+
"substring": 366
|
| 182 |
+
},
|
| 183 |
+
"metric_type": "source_label_match",
|
| 184 |
+
"parse_rate": 1.0,
|
| 185 |
+
"parse_status_counts": {
|
| 186 |
+
"fail_empty": 0,
|
| 187 |
+
"fail_llm_extract": 0,
|
| 188 |
+
"fail_no_answer_meta": 0,
|
| 189 |
+
"fail_regex": 0,
|
| 190 |
+
"ok": 666
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"thresholds": {
|
| 195 |
+
"angle_deg": 20.0,
|
| 196 |
+
"azimuth_deg": 20.0,
|
| 197 |
+
"distance_rel": 0.3,
|
| 198 |
+
"elevation_deg": 10.0,
|
| 199 |
+
"iou": 0.5,
|
| 200 |
+
"onset_s": 0.4
|
| 201 |
+
}
|
| 202 |
+
}
|
runs/qwen3_full_v4_easy/stage_encoder_lora/valid_predictions/epoch_001.scored.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/stage2_lower_lr/epoch_metrics.jsonl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"epoch": 1, "train_loss": 4.902002878892228, "train_supervised_tokens": 81176545.0, "optimizer_steps": 11339.0, "epoch_seconds": 39650.56145262718, "micro_steps": 22677.0, "valid_loss": 7.3201918202545215, "valid_supervised_tokens": 2296239.0, "valid_generate_examples": 32.0, "valid_exact_match": 0.0, "step_valid_subset_size": 1909.0, "valid_subset_size": 38186.0, "valid_generation_size": 32.0, "global_optimizer_step": 11339.0}
|
runs/stage2_lower_lr/processor/added_tokens.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"</tool_call>": 151658,
|
| 3 |
+
"<tool_call>": 151657,
|
| 4 |
+
"<|AUDIO|>": 151646,
|
| 5 |
+
"<|IMAGE|>": 151655,
|
| 6 |
+
"<|VIDEO|>": 151656,
|
| 7 |
+
"<|audio_bos|>": 151647,
|
| 8 |
+
"<|audio_eos|>": 151648,
|
| 9 |
+
"<|box_end|>": 151649,
|
| 10 |
+
"<|endoftext|>": 151643,
|
| 11 |
+
"<|file_sep|>": 151664,
|
| 12 |
+
"<|fim_middle|>": 151660,
|
| 13 |
+
"<|fim_pad|>": 151662,
|
| 14 |
+
"<|fim_prefix|>": 151659,
|
| 15 |
+
"<|fim_suffix|>": 151661,
|
| 16 |
+
"<|im_end|>": 151645,
|
| 17 |
+
"<|im_start|>": 151644,
|
| 18 |
+
"<|quad_end|>": 151651,
|
| 19 |
+
"<|quad_start|>": 151650,
|
| 20 |
+
"<|repo_name|>": 151663,
|
| 21 |
+
"<|spatial|>": 151665,
|
| 22 |
+
"<|vision_bos|>": 151652,
|
| 23 |
+
"<|vision_eos|>": 151653,
|
| 24 |
+
"<|vision_pad|>": 151654
|
| 25 |
+
}
|
runs/stage2_lower_lr/processor/chat_template.jinja
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% set audio_count = namespace(value=0) %}{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system
|
| 2 |
+
You are a helpful assistant.<|im_end|>
|
| 3 |
+
{% endif %}<|im_start|>{{ message['role'] }}
|
| 4 |
+
{% if message['content'] is string %}{{ message['content'] }}<|im_end|>
|
| 5 |
+
{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_bos|><|IMAGE|><|vision_eos|>{% elif content['type'] == 'audio' or 'audio' in content or 'audio_url' in content %}{% set audio_count.value = audio_count.value + 1 %}{% if add_audio_id %}Audio {{ audio_count.value }}: {% endif %}<|audio_bos|><|AUDIO|><|audio_eos|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_bos|><|VIDEO|><|vision_eos|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>
|
| 6 |
+
{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
| 7 |
+
{% endif %}
|
runs/stage2_lower_lr/processor/merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/stage2_lower_lr/processor/preprocessor_config.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"chunk_length": 300,
|
| 3 |
+
"dither": 0.0,
|
| 4 |
+
"feature_extractor_type": "WhisperFeatureExtractor",
|
| 5 |
+
"feature_size": 128,
|
| 6 |
+
"hop_length": 160,
|
| 7 |
+
"image_mean": [
|
| 8 |
+
0.48145466,
|
| 9 |
+
0.4578275,
|
| 10 |
+
0.40821073
|
| 11 |
+
],
|
| 12 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 13 |
+
"image_std": [
|
| 14 |
+
0.26862954,
|
| 15 |
+
0.26130258,
|
| 16 |
+
0.27577711
|
| 17 |
+
],
|
| 18 |
+
"max_pixels": 12845056,
|
| 19 |
+
"merge_size": 2,
|
| 20 |
+
"min_pixels": 3136,
|
| 21 |
+
"n_fft": 400,
|
| 22 |
+
"n_samples": 4800000,
|
| 23 |
+
"nb_max_frames": 30000,
|
| 24 |
+
"padding_side": "right",
|
| 25 |
+
"padding_value": 0.0,
|
| 26 |
+
"patch_size": 14,
|
| 27 |
+
"processor_class": "Qwen2_5OmniSpatialProcessor",
|
| 28 |
+
"return_attention_mask": true,
|
| 29 |
+
"sampling_rate": 16000,
|
| 30 |
+
"temporal_patch_size": 2
|
| 31 |
+
}
|
runs/stage2_lower_lr/processor/special_tokens_map.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
{
|
| 4 |
+
"content": "<|spatial|>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false
|
| 9 |
+
}
|
| 10 |
+
],
|
| 11 |
+
"audio_bos_token": "<|audio_bos|>",
|
| 12 |
+
"audio_eos_token": "<|audio_eos|>",
|
| 13 |
+
"audio_token": "<|AUDIO|>",
|
| 14 |
+
"eos_token": {
|
| 15 |
+
"content": "<|im_end|>",
|
| 16 |
+
"lstrip": false,
|
| 17 |
+
"normalized": false,
|
| 18 |
+
"rstrip": false,
|
| 19 |
+
"single_word": false
|
| 20 |
+
},
|
| 21 |
+
"image_token": "<|IMAGE|>",
|
| 22 |
+
"pad_token": {
|
| 23 |
+
"content": "<|endoftext|>",
|
| 24 |
+
"lstrip": false,
|
| 25 |
+
"normalized": false,
|
| 26 |
+
"rstrip": false,
|
| 27 |
+
"single_word": false
|
| 28 |
+
},
|
| 29 |
+
"video_token": "<|VIDEO|>",
|
| 30 |
+
"vision_bos_token": "<|vision_bos|>",
|
| 31 |
+
"vision_eos_token": "<|vision_eos|>"
|
| 32 |
+
}
|
runs/stage2_lower_lr/processor/tokenizer_config.json
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"151643": {
|
| 5 |
+
"content": "<|endoftext|>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": false,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
},
|
| 12 |
+
"151644": {
|
| 13 |
+
"content": "<|im_start|>",
|
| 14 |
+
"lstrip": false,
|
| 15 |
+
"normalized": false,
|
| 16 |
+
"rstrip": false,
|
| 17 |
+
"single_word": false,
|
| 18 |
+
"special": true
|
| 19 |
+
},
|
| 20 |
+
"151645": {
|
| 21 |
+
"content": "<|im_end|>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false,
|
| 26 |
+
"special": true
|
| 27 |
+
},
|
| 28 |
+
"151646": {
|
| 29 |
+
"content": "<|AUDIO|>",
|
| 30 |
+
"lstrip": false,
|
| 31 |
+
"normalized": false,
|
| 32 |
+
"rstrip": false,
|
| 33 |
+
"single_word": false,
|
| 34 |
+
"special": true
|
| 35 |
+
},
|
| 36 |
+
"151647": {
|
| 37 |
+
"content": "<|audio_bos|>",
|
| 38 |
+
"lstrip": false,
|
| 39 |
+
"normalized": false,
|
| 40 |
+
"rstrip": false,
|
| 41 |
+
"single_word": false,
|
| 42 |
+
"special": true
|
| 43 |
+
},
|
| 44 |
+
"151648": {
|
| 45 |
+
"content": "<|audio_eos|>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": false,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false,
|
| 50 |
+
"special": true
|
| 51 |
+
},
|
| 52 |
+
"151649": {
|
| 53 |
+
"content": "<|box_end|>",
|
| 54 |
+
"lstrip": false,
|
| 55 |
+
"normalized": false,
|
| 56 |
+
"rstrip": false,
|
| 57 |
+
"single_word": false,
|
| 58 |
+
"special": true
|
| 59 |
+
},
|
| 60 |
+
"151650": {
|
| 61 |
+
"content": "<|quad_start|>",
|
| 62 |
+
"lstrip": false,
|
| 63 |
+
"normalized": false,
|
| 64 |
+
"rstrip": false,
|
| 65 |
+
"single_word": false,
|
| 66 |
+
"special": true
|
| 67 |
+
},
|
| 68 |
+
"151651": {
|
| 69 |
+
"content": "<|quad_end|>",
|
| 70 |
+
"lstrip": false,
|
| 71 |
+
"normalized": false,
|
| 72 |
+
"rstrip": false,
|
| 73 |
+
"single_word": false,
|
| 74 |
+
"special": true
|
| 75 |
+
},
|
| 76 |
+
"151652": {
|
| 77 |
+
"content": "<|vision_bos|>",
|
| 78 |
+
"lstrip": false,
|
| 79 |
+
"normalized": false,
|
| 80 |
+
"rstrip": false,
|
| 81 |
+
"single_word": false,
|
| 82 |
+
"special": true
|
| 83 |
+
},
|
| 84 |
+
"151653": {
|
| 85 |
+
"content": "<|vision_eos|>",
|
| 86 |
+
"lstrip": false,
|
| 87 |
+
"normalized": false,
|
| 88 |
+
"rstrip": false,
|
| 89 |
+
"single_word": false,
|
| 90 |
+
"special": true
|
| 91 |
+
},
|
| 92 |
+
"151654": {
|
| 93 |
+
"content": "<|vision_pad|>",
|
| 94 |
+
"lstrip": false,
|
| 95 |
+
"normalized": false,
|
| 96 |
+
"rstrip": false,
|
| 97 |
+
"single_word": false,
|
| 98 |
+
"special": true
|
| 99 |
+
},
|
| 100 |
+
"151655": {
|
| 101 |
+
"content": "<|IMAGE|>",
|
| 102 |
+
"lstrip": false,
|
| 103 |
+
"normalized": false,
|
| 104 |
+
"rstrip": false,
|
| 105 |
+
"single_word": false,
|
| 106 |
+
"special": true
|
| 107 |
+
},
|
| 108 |
+
"151656": {
|
| 109 |
+
"content": "<|VIDEO|>",
|
| 110 |
+
"lstrip": false,
|
| 111 |
+
"normalized": false,
|
| 112 |
+
"rstrip": false,
|
| 113 |
+
"single_word": false,
|
| 114 |
+
"special": true
|
| 115 |
+
},
|
| 116 |
+
"151657": {
|
| 117 |
+
"content": "<tool_call>",
|
| 118 |
+
"lstrip": false,
|
| 119 |
+
"normalized": false,
|
| 120 |
+
"rstrip": false,
|
| 121 |
+
"single_word": false,
|
| 122 |
+
"special": false
|
| 123 |
+
},
|
| 124 |
+
"151658": {
|
| 125 |
+
"content": "</tool_call>",
|
| 126 |
+
"lstrip": false,
|
| 127 |
+
"normalized": false,
|
| 128 |
+
"rstrip": false,
|
| 129 |
+
"single_word": false,
|
| 130 |
+
"special": false
|
| 131 |
+
},
|
| 132 |
+
"151659": {
|
| 133 |
+
"content": "<|fim_prefix|>",
|
| 134 |
+
"lstrip": false,
|
| 135 |
+
"normalized": false,
|
| 136 |
+
"rstrip": false,
|
| 137 |
+
"single_word": false,
|
| 138 |
+
"special": false
|
| 139 |
+
},
|
| 140 |
+
"151660": {
|
| 141 |
+
"content": "<|fim_middle|>",
|
| 142 |
+
"lstrip": false,
|
| 143 |
+
"normalized": false,
|
| 144 |
+
"rstrip": false,
|
| 145 |
+
"single_word": false,
|
| 146 |
+
"special": false
|
| 147 |
+
},
|
| 148 |
+
"151661": {
|
| 149 |
+
"content": "<|fim_suffix|>",
|
| 150 |
+
"lstrip": false,
|
| 151 |
+
"normalized": false,
|
| 152 |
+
"rstrip": false,
|
| 153 |
+
"single_word": false,
|
| 154 |
+
"special": false
|
| 155 |
+
},
|
| 156 |
+
"151662": {
|
| 157 |
+
"content": "<|fim_pad|>",
|
| 158 |
+
"lstrip": false,
|
| 159 |
+
"normalized": false,
|
| 160 |
+
"rstrip": false,
|
| 161 |
+
"single_word": false,
|
| 162 |
+
"special": false
|
| 163 |
+
},
|
| 164 |
+
"151663": {
|
| 165 |
+
"content": "<|repo_name|>",
|
| 166 |
+
"lstrip": false,
|
| 167 |
+
"normalized": false,
|
| 168 |
+
"rstrip": false,
|
| 169 |
+
"single_word": false,
|
| 170 |
+
"special": false
|
| 171 |
+
},
|
| 172 |
+
"151664": {
|
| 173 |
+
"content": "<|file_sep|>",
|
| 174 |
+
"lstrip": false,
|
| 175 |
+
"normalized": false,
|
| 176 |
+
"rstrip": false,
|
| 177 |
+
"single_word": false,
|
| 178 |
+
"special": false
|
| 179 |
+
},
|
| 180 |
+
"151665": {
|
| 181 |
+
"content": "<|spatial|>",
|
| 182 |
+
"lstrip": false,
|
| 183 |
+
"normalized": false,
|
| 184 |
+
"rstrip": false,
|
| 185 |
+
"single_word": false,
|
| 186 |
+
"special": true
|
| 187 |
+
}
|
| 188 |
+
},
|
| 189 |
+
"additional_special_tokens": [
|
| 190 |
+
"<|spatial|>"
|
| 191 |
+
],
|
| 192 |
+
"audio_bos_token": "<|audio_bos|>",
|
| 193 |
+
"audio_eos_token": "<|audio_eos|>",
|
| 194 |
+
"audio_token": "<|AUDIO|>",
|
| 195 |
+
"bos_token": null,
|
| 196 |
+
"clean_up_tokenization_spaces": false,
|
| 197 |
+
"eos_token": "<|im_end|>",
|
| 198 |
+
"errors": "replace",
|
| 199 |
+
"extra_special_tokens": {
|
| 200 |
+
"audio_bos_token": "<|audio_bos|>",
|
| 201 |
+
"audio_eos_token": "<|audio_eos|>",
|
| 202 |
+
"audio_token": "<|AUDIO|>",
|
| 203 |
+
"image_token": "<|IMAGE|>",
|
| 204 |
+
"video_token": "<|VIDEO|>",
|
| 205 |
+
"vision_bos_token": "<|vision_bos|>",
|
| 206 |
+
"vision_eos_token": "<|vision_eos|>"
|
| 207 |
+
},
|
| 208 |
+
"image_token": "<|IMAGE|>",
|
| 209 |
+
"model_max_length": 32768,
|
| 210 |
+
"pad_token": "<|endoftext|>",
|
| 211 |
+
"processor_class": "Qwen2_5OmniSpatialProcessor",
|
| 212 |
+
"split_special_tokens": false,
|
| 213 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 214 |
+
"unk_token": null,
|
| 215 |
+
"video_token": "<|VIDEO|>",
|
| 216 |
+
"vision_bos_token": "<|vision_bos|>",
|
| 217 |
+
"vision_eos_token": "<|vision_eos|>"
|
| 218 |
+
}
|
runs/stage2_lower_lr/processor/vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/stage2_lower_lr/train_args.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_feature_cache_manifest": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen/qwen_audio_cache_ov1_v6c/manifest.json",
|
| 3 |
+
"audio_feature_cache_max_entries": 256,
|
| 4 |
+
"batch_size": 4,
|
| 5 |
+
"beats_checkpoint": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats/checkpoints/spatial_beats_ov1_local_spatial_v2_exp/02_spatial/best.pt",
|
| 6 |
+
"beats_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/unilm/beats",
|
| 7 |
+
"device": "cuda:0",
|
| 8 |
+
"distributed": true,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"epochs": 3,
|
| 11 |
+
"grad_accum_steps": 2,
|
| 12 |
+
"gradient_checkpointing": true,
|
| 13 |
+
"local_rank": 0,
|
| 14 |
+
"log_every": 10,
|
| 15 |
+
"lora_alpha": 32,
|
| 16 |
+
"lora_dropout": 0.05,
|
| 17 |
+
"lora_r": 16,
|
| 18 |
+
"lora_target_modules": [
|
| 19 |
+
"q_proj",
|
| 20 |
+
"k_proj",
|
| 21 |
+
"v_proj",
|
| 22 |
+
"o_proj",
|
| 23 |
+
"gate_proj",
|
| 24 |
+
"up_proj",
|
| 25 |
+
"down_proj"
|
| 26 |
+
],
|
| 27 |
+
"lora_target_prefixes": [
|
| 28 |
+
"thinker.model"
|
| 29 |
+
],
|
| 30 |
+
"lr": 1e-05,
|
| 31 |
+
"max_grad_norm": 1.0,
|
| 32 |
+
"max_train_samples": null,
|
| 33 |
+
"max_valid_samples": null,
|
| 34 |
+
"model_id": "/apdcephfs_cq10/share_1603164/user/schmittzhu/model/Qwen2.5-Omni-7B",
|
| 35 |
+
"num_workers": 0,
|
| 36 |
+
"optimizer_step_per_batch": false,
|
| 37 |
+
"output_dir": "./runs/stage2_lower_lr",
|
| 38 |
+
"persistent_workers": false,
|
| 39 |
+
"prefetch_factor": 2,
|
| 40 |
+
"projector_fp32": false,
|
| 41 |
+
"qa_root": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/prepared_datasets/ov1_qa_pairs_v6c",
|
| 42 |
+
"qa_roots": [
|
| 43 |
+
"/apdcephfs_cq10/share_1603164/user/schmittzhu/code/DCASE2024_seld_baseline/prepared_datasets/ov1_qa_pairs_v6c"
|
| 44 |
+
],
|
| 45 |
+
"rank": 0,
|
| 46 |
+
"resume_checkpoint_path": "./runs/stage1/checkpoints/best_trainable.pt",
|
| 47 |
+
"resume_model_only": true,
|
| 48 |
+
"resume_tag": null,
|
| 49 |
+
"save_every_epoch": true,
|
| 50 |
+
"save_every_n_optimizer_steps": 1000,
|
| 51 |
+
"save_full_model": false,
|
| 52 |
+
"seed": 1234,
|
| 53 |
+
"spatial_qwen_repo": "/apdcephfs_cq10/share_1603164/user/schmittzhu/code/Spatial-Qwen",
|
| 54 |
+
"step_valid_subset_ratio": 0.05,
|
| 55 |
+
"train_mode": "encoder_lora",
|
| 56 |
+
"train_split": "train",
|
| 57 |
+
"valid_do_sample": false,
|
| 58 |
+
"valid_every_n_optimizer_steps": 1000,
|
| 59 |
+
"valid_generate_batch_size": 1,
|
| 60 |
+
"valid_generate_max_samples": 32,
|
| 61 |
+
"valid_max_new_tokens": 48,
|
| 62 |
+
"valid_num_beams": 1,
|
| 63 |
+
"valid_split": "valid",
|
| 64 |
+
"valid_subset_ratio": 0.1,
|
| 65 |
+
"warmup_ratio": 0.03,
|
| 66 |
+
"weight_decay": 0.01,
|
| 67 |
+
"world_size": 8
|
| 68 |
+
}
|
runs/stage2_lower_lr/valid_predictions/epoch_001.jsonl
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"epoch": 1, "pair_id": "valid/0000052", "task_name": "detect_time", "prompt": "Question: When is the thunderstorm audible in this clip?\n\nAnswer with only the time span.\nUse the format \"Xs to Ys\" with one decimal place.", "answer": "0.0s to 17.8s", "prediction": "00000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 2 |
+
{"epoch": 1, "pair_id": "valid/0000645", "task_name": "classify_source_class_choice", "prompt": "Question: Pick the correct event type for this clip.\nOptions:\nA. speech\nB. clock\nC. footsteps\nD. guitar\n\nAnswer with only the option letter.", "answer": "D", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 3 |
+
{"epoch": 1, "pair_id": "valid/0000750", "task_name": "detect_source_active_at_time", "prompt": "Question: Would an annotator mark the wind present at 5.3s?\n\nAnswer with only yes or no.", "answer": "yes", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 4 |
+
{"epoch": 1, "pair_id": "valid/0000932", "task_name": "classify_source_class_choice", "prompt": "Question: Which option matches the sound event in this recording?\nOptions:\nA. body sound\nB. gong\nC. dog\nD. footsteps\n\nAnswer with only the option letter.", "answer": "B", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 5 |
+
{"epoch": 1, "pair_id": "valid/0003540", "task_name": "detect_source_active_at_time", "prompt": "Question: Would an annotator mark the tool present at 1.6s?\n\nAnswer with only yes or no.", "answer": "no", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 6 |
+
{"epoch": 1, "pair_id": "valid/0005627", "task_name": "caption_source_inventory", "prompt": "Question: Determine the sound class in this recording.\n\nAnswer with semicolon-separated bracketed entries.\nUse the format \"[class_1]; [class_2]; ...\".\nKeep the class names short and lowercase.", "answer": "[glass]", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 7 |
+
{"epoch": 1, "pair_id": "valid/0006468", "task_name": "classify_elevation_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Which vertical angle bin matches the wind instrument?\nOptions:\nA. -50 to -30 degrees\nB. -30 to -10 degrees\nC. -10 to 10 degrees\nD. 70 to 90 degrees\n\nAnswer with only the option letter.", "answer": "B", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 8 |
+
{"epoch": 1, "pair_id": "valid/0010040", "task_name": "classify_distance_bin_choice", "prompt": "Interpret distance as the straight-line distance from the listener to the active sound source.\nDistances are grouped into coarse bins in meters.\n\nQuestion: Choose the distance category for this sound event.\nOptions:\nA. 2.8m to 3.9m meters\nB. 0.5m to 1.8m meters\nC. 3.9m to 6.5m meters\nD. 1.8m to 2.8m meters\n\nAnswer with only the option letter.", "answer": "C", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 9 |
+
{"epoch": 1, "pair_id": "valid/0010467", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Which azimuth interval should be assigned to the source?\nOptions:\nA. 160 to 180 degrees\nB. 40 to 60 degrees\nC. -160 to -140 degrees\nD. -120 to -100 degrees\n\nAnswer with only the option letter.", "answer": "B", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 10 |
+
{"epoch": 1, "pair_id": "valid/0011275", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Select the correct horizontal sector for the laughter.\nOptions:\nA. 100 to 120 degrees\nB. 140 to 160 degrees\nC. -80 to -60 degrees\nD. -160 to -140 degrees\n\nAnswer with only the option letter.", "answer": "A", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 11 |
+
{"epoch": 1, "pair_id": "valid/0011711", "task_name": "detect_source_active_at_time", "prompt": "Question: Is the musical instrument audible at 7.9s in this recording?\n\nAnswer with only yes or no.", "answer": "no", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 12 |
+
{"epoch": 1, "pair_id": "valid/0011785", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Select the azimuth range of the target sound source.\nOptions:\nA. -160 to -140 degrees\nB. 160 to 180 degrees\nC. -20 to 0 degrees\nD. 140 to 160 degrees\n\nAnswer with only the option letter.", "answer": "C", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 13 |
+
{"epoch": 1, "pair_id": "valid/0011903", "task_name": "detect_source_active_at_time", "prompt": "Question: Would an annotator mark the keyboard instrument present at 5.2s?\n\nAnswer with only yes or no.", "answer": "no", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 14 |
+
{"epoch": 1, "pair_id": "valid/0012503", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Which azimuth bin best matches the source location?\nOptions:\nA. -160 to -140 degrees\nB. -140 to -120 degrees\nC. -180 to -160 degrees\nD. 160 to 180 degrees\n\nAnswer with only the option letter.", "answer": "B", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 15 |
+
{"epoch": 1, "pair_id": "valid/0015163", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Which azimuth interval should be assigned to the source?\nOptions:\nA. 140 to 160 degrees\nB. 120 to 140 degrees\nC. -140 to -120 degrees\nD. -160 to -140 degrees\n\nAnswer with only the option letter.", "answer": "D", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 16 |
+
{"epoch": 1, "pair_id": "valid/0016118", "task_name": "detect_time", "prompt": "Question: What are the start and end timestamps of the target event?\n\nAnswer with only the time span.\nUse the format \"Xs to Ys\" with one decimal place.", "answer": "0.5s to 18.6s", "prediction": "00000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 17 |
+
{"epoch": 1, "pair_id": "valid/0018207", "task_name": "detect_source_active_at_time", "prompt": "Question: At 3.2s, is the target source active?\n\nAnswer with only yes or no.", "answer": "no", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 18 |
+
{"epoch": 1, "pair_id": "valid/0019842", "task_name": "detect_source_active_at_time", "prompt": "Question: Is the target class audible at 2.4s?\n\nAnswer with only yes or no.", "answer": "yes", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 19 |
+
{"epoch": 1, "pair_id": "valid/0019881", "task_name": "detect_source_active_at_time", "prompt": "Question: At 5.3s, should the machine be considered present?\n\nAnswer with only yes or no.", "answer": "yes", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 20 |
+
{"epoch": 1, "pair_id": "valid/0020552", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Choose the correct 20-degree azimuth bin for the guitar.\nOptions:\nA. 100 to 120 degrees\nB. -160 to -140 degrees\nC. -100 to -80 degrees\nD. -40 to -20 degrees\n\nAnswer with only the option letter.", "answer": "D", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 21 |
+
{"epoch": 1, "pair_id": "valid/0021505", "task_name": "classify_distance_bin_choice", "prompt": "Interpret distance as the straight-line distance from the listener to the active sound source.\nDistances are grouped into coarse bins in meters.\n\nQuestion: Which option marks the distance bin of the event?\nOptions:\nA. 3.9m to 6.5m meters\nB. 2.8m to 3.9m meters\nC. 0.5m to 1.8m meters\nD. 1.8m to 2.8m meters\n\nAnswer with only the option letter.", "answer": "B", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 22 |
+
{"epoch": 1, "pair_id": "valid/0021877", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Choose the source azimuth category.\nOptions:\nA. -20 to 0 degrees\nB. 140 to 160 degrees\nC. -80 to -60 degrees\nD. -120 to -100 degrees\n\nAnswer with only the option letter.", "answer": "D", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 23 |
+
{"epoch": 1, "pair_id": "valid/0024184", "task_name": "detect_source_active_at_time", "prompt": "Question: At 11.7s, is the target source active?\n\nAnswer with only yes or no.", "answer": "yes", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 24 |
+
{"epoch": 1, "pair_id": "valid/0025482", "task_name": "detect_time", "prompt": "Question: At what times does the zipper occur?\n\nAnswer with only the time span.\nUse the format \"Xs to Ys\" with one decimal place.", "answer": "3.0s to 16.2s", "prediction": "00000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 25 |
+
{"epoch": 1, "pair_id": "valid/0025719", "task_name": "detect_source_active_at_time", "prompt": "Question: Would you answer that the drum is active at 3.0s?\n\nAnswer with only yes or no.", "answer": "yes", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 26 |
+
{"epoch": 1, "pair_id": "valid/0029014", "task_name": "classify_elevation_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Select the source direction bin on the vertical axis.\nOptions:\nA. -90 to -70 degrees\nB. 10 to 30 degrees\nC. -50 to -30 degrees\nD. -10 to 10 degrees\n\nAnswer with only the option letter.", "answer": "C", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 27 |
+
{"epoch": 1, "pair_id": "valid/0029104", "task_name": "caption_source_inventory", "prompt": "Question: List the sound class present in this clip.\n\nAnswer with semicolon-separated bracketed entries.\nUse the format \"[class_1]; [class_2]; ...\".\nKeep the class names short and lowercase.", "answer": "[keyboard instrument]", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 28 |
+
{"epoch": 1, "pair_id": "valid/0029768", "task_name": "classify_distance_bin_choice", "prompt": "Interpret distance as the straight-line distance from the listener to the active sound source.\nDistances are grouped into coarse bins in meters.\n\nQuestion: Select the correct radial range for the sound source.\nOptions:\nA. 3.9m to 6.5m meters\nB. 2.8m to 3.9m meters\nC. 0.5m to 1.8m meters\nD. 1.8m to 2.8m meters\n\nAnswer with only the option letter.", "answer": "C", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 29 |
+
{"epoch": 1, "pair_id": "valid/0035090", "task_name": "classify_distance_bin_choice", "prompt": "Interpret distance as the straight-line distance from the listener to the active sound source.\nDistances are grouped into coarse bins in meters.\n\nQuestion: Choose the distance category for this sound event.\nOptions:\nA. 2.8m to 3.9m meters\nB. 3.9m to 6.5m meters\nC. 1.8m to 2.8m meters\nD. 0.5m to 1.8m meters\n\nAnswer with only the option letter.", "answer": "C", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 30 |
+
{"epoch": 1, "pair_id": "valid/0035987", "task_name": "detect_source_active_at_time", "prompt": "Question: Would you answer that the singing is active at 3.4s?\n\nAnswer with only yes or no.", "answer": "no", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 31 |
+
{"epoch": 1, "pair_id": "valid/0036316", "task_name": "classify_azimuth_bin_choice", "prompt": "Use the DCASE FOA coordinate system.\nThe +x axis points forward, +y points left, and +z points up.\nAzimuth increases counterclockwise when viewed from above.\nLeft corresponds to positive azimuth and right corresponds to negative azimuth.\nAzimuth is reported in degrees in [-180, 180], and elevation is reported in degrees in [-90, 90].\n\nQuestion: Pick the correct horizontal angle interval for the keyboard instrument.\nOptions:\nA. 20 to 40 degrees\nB. 40 to 60 degrees\nC. -20 to 0 degrees\nD. -180 to -160 degrees\n\nAnswer with only the option letter.", "answer": "C", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
| 32 |
+
{"epoch": 1, "pair_id": "valid/0037564", "task_name": "classify_source_class_choice", "prompt": "Question: Select the source class that best describes this segment.\nOptions:\nA. thunderstorm\nB. camera\nC. alarm\nD. tool\n\nAnswer with only the option letter.", "answer": "C", "prediction": "000000000000000000000000000000000000000000000000", "exact_match": 0}
|
runs/v13d_easy_llmqa_af3/stage1_projector/epoch_metrics.jsonl
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"epoch": 1, "train_loss": 0.5010758844768967, "train_supervised_tokens": 16150791.0, "optimizer_steps": 16354.0, "epoch_seconds": 26248.89346075058, "micro_steps": 49060.0, "valid_loss": 0.5031168303269897, "valid_supervised_tokens": 1804356.0, "valid_generate_examples": 32.0, "valid_exact_match": 0.03125, "step_valid_subset_size": 4160.0, "valid_subset_size": 83193.0, "valid_generation_size": 32.0, "global_optimizer_step": 16354.0}
|
| 2 |
+
{"epoch": 2, "train_loss": 0.43175358717016993, "train_supervised_tokens": 16150806.0, "optimizer_steps": 16354.0, "epoch_seconds": 26422.265491247177, "micro_steps": 49060.0, "valid_loss": 0.502653176573906, "valid_supervised_tokens": 1804356.0, "valid_generate_examples": 32.0, "valid_exact_match": 0.0625, "step_valid_subset_size": 4160.0, "valid_subset_size": 83193.0, "valid_generation_size": 32.0, "global_optimizer_step": 32708.0}
|
runs/v13d_easy_llmqa_af3/stage1_projector/processor/chat_template.jinja
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% if messages[0]['role'] != 'system' %}<|im_start|>system
|
| 2 |
+
You are a helpful assistant.<|im_end|>
|
| 3 |
+
{% endif %}{% for m in messages if m['content'] is not none %}<|im_start|>{{ m['role'] }}
|
| 4 |
+
{% if m['content'] is string %}{{ m['content'] }}{% else %}{% set audio = namespace(found=False) %}{% set text_buf = namespace(v='') %}{% for c in m['content'] %}{% if c.get('type') == 'audio' or 'audio' in c %}{% set audio.found = True %}{% elif c.get('type') == 'text' or 'text' in c %}{% set text_buf.v = text_buf.v + c['text'] %}{% endif %}{% endfor %}{% if audio.found %}{{ '<sound>' }}{% endif %}{{ text_buf.v }}{% endif %}<|im_end|>
|
| 5 |
+
{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
| 6 |
+
{% endif %}
|
runs/v13d_easy_llmqa_af3/stage1_projector/processor/processor_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_token": "<sound>",
|
| 3 |
+
"default_transcription_prompt": "Transcribe the input speech.",
|
| 4 |
+
"feature_extractor": {
|
| 5 |
+
"chunk_length": 30,
|
| 6 |
+
"dither": 0.0,
|
| 7 |
+
"feature_extractor_type": "WhisperFeatureExtractor",
|
| 8 |
+
"feature_size": 128,
|
| 9 |
+
"hop_length": 160,
|
| 10 |
+
"n_fft": 400,
|
| 11 |
+
"n_samples": 480000,
|
| 12 |
+
"nb_max_frames": 3000,
|
| 13 |
+
"padding_side": "right",
|
| 14 |
+
"padding_value": 0.0,
|
| 15 |
+
"return_attention_mask": true,
|
| 16 |
+
"sampling_rate": 16000
|
| 17 |
+
},
|
| 18 |
+
"max_audio_len": 600,
|
| 19 |
+
"processor_class": "AudioFlamingo3SpatialProcessor",
|
| 20 |
+
"spatial_audio_max_seconds": 20.0,
|
| 21 |
+
"spatial_beats_target_token_rate": 2.5,
|
| 22 |
+
"spatial_token": "<spatial>"
|
| 23 |
+
}
|
runs/v13d_easy_llmqa_af3/stage1_projector/processor/tokenizer_config.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "[BOS]",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<spatial>"
|
| 10 |
+
],
|
| 11 |
+
"is_local": true,
|
| 12 |
+
"legacy": false,
|
| 13 |
+
"model_max_length": 32768,
|
| 14 |
+
"pad_token": "[PAD]",
|
| 15 |
+
"padding_side": "right",
|
| 16 |
+
"processor_class": "AudioFlamingo3SpatialProcessor",
|
| 17 |
+
"split_special_tokens": false,
|
| 18 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 19 |
+
"unk_token": null
|
| 20 |
+
}
|