Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions knowledge/repos/vllm-omni/components/diffusion/_index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Diffusion"
created: 2026-07-10
updated: 2026-08-13
updated: 2026-08-23
type: index
tags: [vllm-omni, components, diffusion]
sources: []
Expand All @@ -28,7 +28,7 @@ sources: []
| 遇到什么 | 查看哪里 |
|---|---|
| 理解共享职责和数据流 | [architecture](architecture.md) |
| 根据 PR 描述直达 execution parity、checkpoint/distributed、quality evidence 或 paged-cache system-runtime 规则组与第一批源码 | [rules 与代码地图](rules.md) |
| 根据 PR 描述直达 execution parity、checkpoint/artifact identity、quality evidence 或 system-runtime 异常清理规则组与第一批源码 | [rules 与代码地图](rules.md) |
| diffusion step 与 request/continuous batching | [step and batching](step-and-batching.md) |
| Cache-DiT、TeaCache 和 prefix cache | [cache acceleration](cache-acceleration.md) |
| TP/PP/SP/CFG/VAE/HSDP 等并行策略 | [parallelism](parallelism.md) |
51 changes: 38 additions & 13 deletions knowledge/repos/vllm-omni/components/diffusion/rules.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: "Diffusion 共享规则"
created: 2026-07-20
updated: 2026-08-13
updated: 2026-08-23
type: rule
tags: [vllm-omni, components, diffusion]
sources: ["PR #4341", "PR #5001", "PR #5087", "PR #5088", "PR #5136", "PR #6094", vllm_omni/diffusion/worker/diffusion_model_runner.py, vllm_omni/diffusion/model_loader/diffusers_loader.py, vllm_omni/diffusion/distributed/hsdp.py]
sources: ["PR #4341", "PR #5001", "PR #5087", "PR #5088", "PR #5136", "PR #6094", "PR #6385", "PR #6445", vllm_omni/diffusion/worker/diffusion_model_runner.py, vllm_omni/diffusion/model_loader/diffusers_loader.py, vllm_omni/diffusion/distributed/hsdp.py]
confidence: high
---

Expand All @@ -15,26 +15,28 @@ confidence: high

## Direct 代码快速入口

- **DIFF-0a — PR 描述先选共享执行地图。** Direct review 先按 title/body 声明的 graph、RNG、checkpoint、HSDP、quantization 或质量语义命中下表,再用 pinned changed files 验证是否确属共享 diffusion owner。
- **DIFF-0b — 共享 runner 与模型 pipeline 分层。** 先打开命中行的共享 producer;只有 live 调用链证明偏差属于某个模型 pipeline、checkpoint 或常量时才进入模型 owner,不能横向遍历所有 diffusion 模型。
- **DIFF-0a — PR 描述先选共享执行地图。** 按 title/body 的 graph、RNG、checkpoint、HSDP、quantization 或质量信号命中下表,再用 pinned files 验证 owner。
- **DIFF-0b — 共享 runner 与模型 pipeline 分层。** 先查命中行的共享 producer;只有 live 调用链落到单模型 pipeline/checkpoint/常量时才进入模型 owner,不横扫其他模型。

| PR 描述在做什么 | 精确规则组 | 第一批 live 源码 |
|---|---|---|
| CUDA Graph、compile、fused scheduler/solver、cache path、eager parity | `execution-parity`:`DIFF-1a` | `vllm_omni/diffusion/compile.py::regionally_compile` → `vllm_omni/diffusion/worker/diffusion_model_runner.py::{DiffusionModelRunner.execute_model,execute_model_batch}` → 命中模型的 denoise/solver consumer |
| seed、request-local generator、guidance=0、并发 RNG、batched generators | `execution-parity`:`DIFF-1b` | `vllm_omni/inputs/data.py::OmniDiffusionSamplingParams` → `diffusion_model_runner.py::DiffusionModelRunner._initialize_generator` → `request_batch.py::DiffusionRequestBatch.collate_sampling_param_generators` |
| ModelOpt/checkpoint adapter、weight/scale remap、unknown tensor、resolution path | `checkpoint-distributed`:`DIFF-2a` | `vllm_omni/diffusion/model_loader/diffusers_loader.py::{DiffusersPipelineLoader._get_checkpoint_adapter,load_weights}` → `checkpoint_adapters/modelopt.py::{ModelOptFp8CheckpointAdapter._resolve_target_and_output_names,adapt}` |
| HSDP/FSDP、`fully_shard`、DeviceMesh、packed/scalar parameter、FP8 | `checkpoint-distributed`:`DIFF-2b` | `vllm_omni/diffusion/distributed/hsdp.py::{apply_hsdp_to_model,shard_model}` → `model_loader/diffusers_loader.py::DiffusersPipelineLoader._load_model_with_hsdp` → `quantization/hsdp_fp8.py::prepare_fp8_layers_for_fsdp` |
| component quantization、text encoder/transformer/VAE 独立配置、owner prefix、meta/offload | `checkpoint-distributed`:`DIFF-2c` | `vllm_omni/diffusion/data.py::OmniDiffusionConfig._propagate_quantization_from_tf_config` → `model_loader/diffusers_loader.py::{DiffusersPipelineLoader._get_weight_sources,_process_weights_after_loading}` → 命中 component 的真实 linear consumer |
| LPIPS/PSNR/相似度阈值、CPU offload、量化质量证据 | `quality-evidence`:`DIFF-3a` | changed quality test 的 exact case → `vllm_omni/diffusion/worker/diffusion_model_runner.py::DiffusionModelRunner.execute_model` → 命中 pipeline;baseline/candidate 必须复用同一路径 |
| paged KV/cache、block manager、显存预算、warmup/profile、scheduler admission | `system-runtime`:`DIFF-4a`, `DIFF-4b`, `DIFF-4c` | `diffusion_engine.py` 初始化顺序 → `diffusion_kv/initialization.py` → `worker/diffusion_worker.py::determine_available_kv_memory` → native config/allocator → `sched/base_scheduler.py` 的 enabled 请求、异常和清理路径 |
| CUDA Graph、compile、fused scheduler/solver、cache path、eager parity | `execution-parity`:`DIFF-1a` | `compile.py::regionally_compile` → `diffusion_model_runner.py::{execute_model,execute_model_batch}` → model denoise/solver |
| seed、request-local generator、guidance=0、并发 RNG、batched generators | `execution-parity`:`DIFF-1b` | `inputs/data.py::OmniDiffusionSamplingParams` → runner `_initialize_generator` → request-batch generator collate |
| ModelOpt/checkpoint adapter、weight/scale remap、unknown tensor、resolution path | `checkpoint-distributed`:`DIFF-2a` | `diffusers_loader.py::{_get_checkpoint_adapter,load_weights}` → `modelopt.py::{_resolve_target_and_output_names,adapt}` |
| host-weight artifact、source identity、layout/dtype、warm restore | `checkpoint-distributed`:`DIFF-2d` | `model_loader/host_weights/{source_identity,contracts,identity_adapter}.py` → policy/restorer |
| HSDP/FSDP、`fully_shard`、DeviceMesh、packed/scalar parameter、FP8 | `checkpoint-distributed`:`DIFF-2b` | `distributed/hsdp.py::{apply_hsdp_to_model,shard_model}` → loader `_load_model_with_hsdp` → `hsdp_fp8.py` |
| component quantization、text encoder/transformer/VAE 独立配置、owner prefix、meta/offload | `checkpoint-distributed`:`DIFF-2c` | `data.py::_propagate_quantization_from_tf_config` → loader weight sources/post-load → component linear consumer |
| LPIPS/PSNR/相似度阈值、CPU offload、量化质量证据 | `quality-evidence`:`DIFF-3a` | changed exact case → runner `execute_model` → model pipeline;A/B 同路径 |
| paged KV/cache、block manager、显存预算、warmup/profile、scheduler admission | `system-runtime`:`DIFF-4a`, `DIFF-4b`, `DIFF-4c` | engine init → `diffusion_kv/initialization.py` → worker memory probe → native allocator → scheduler lifecycle |
| worker/RPC 异常、rank-status、traceback/device cache 清理 | `system-runtime`:`DIFF-4d` | `diffusion_worker.py::{_execute_rpc,_worker_busy_loop}` 的 raise/reply/status 路径 |

| 审查组 | 什么时候触发 | 规则 ID |
|---|---|---|
| `core` | 每次共享 diffusion 审查 | `DIFF-1a`, `DIFF-1b` |
| `execution-parity` | graph/eager、solver、RNG、generator、zero/default | `DIFF-1a`, `DIFF-1b` |
| `checkpoint-distributed` | checkpoint、quantization、HSDP/FSDP | `DIFF-2a`, `DIFF-2b`, `DIFF-2c` |
| `checkpoint-distributed` | checkpoint、quantization、HSDP/FSDP、artifact identity | `DIFF-2a`, `DIFF-2b`, `DIFF-2c`, `DIFF-2d` |
| `quality-evidence` | 质量阈值、offload、A/B case | `DIFF-3a` |
| `system-runtime` | cache/资源预算、native 边界、feature gate、异常或并发调度 | `DIFF-4a`, `DIFF-4b`, `DIFF-4c` |
| `system-runtime` | cache/资源预算、native 边界、feature gate、异常或并发调度 | `DIFF-4a`, `DIFF-4b`, `DIFF-4c`, `DIFF-4d` |
| `author-routing` | 只供 Direct reviewer 导航,不作为 finding 规则 | `DIFF-0a`, `DIFF-0b` |

## 优化路径与 eager 的等价合同
Expand Down Expand Up @@ -91,6 +93,18 @@ confidence: high
命中/排除集合,并验证 meta-device parameter 不会被提前 move。FLUX.2 的具体边界见
[FLUX.2 规则](../../models/flux2/rules.md)。 ^[PR #5136]

### DIFF-2d — Artifact identity 只信任已验证的不可变来源

- 触发:新增或修改 host-weight artifact、warm restore、source identity、layout/dtype policy。
- 强制:共享 identity、restore 和 model ABI 保持 representation-neutral,dtype/layout 只属于
具体 policy/producer;只有同时验证 source kind、snapshot revision、repo topology 和 blob
位置的内容寻址仓库,才可用 blob 名代替内容哈希,其他本地文件和 symlink 必须按内容定身份。
- 禁止:因 symlink 目标名看似 40/64 位十六进制就假设不可变;把 `bf16`、具体 layout 或首个
producer 名写进共享 identity/restorer API;用进程内 inode/mtime guard 代替跨启动身份校验。
- 验收:第二种 synthetic representation 复用共享 identity/restorer;任意本地十六进制命名
symlink 在同大小内容被替换后产生不同 identity;合法 Hub snapshot→blob 拓扑仍走受控快捷路径。
^[PR #6445]

## 质量阈值与资源辅助

### DIFF-3a — 质量阈值必须由完全相同的测试 case 产生
Expand Down Expand Up @@ -140,5 +154,16 @@ confidence: high
- 验收:path/lifecycle matrix 每行有 production-path 测试或明确 `MISSING_EVIDENCE`;enabled
关键行缺失时审查只能是 partial,不能输出 clean/no findings。 ^[PR #6094]

### DIFF-4d — 异常清理覆盖每种错误传递形态

- 触发:worker/RPC 在异常后清 traceback、释放 device tensor/cache,或把异常转换成
reply、rank-status envelope、`DiffusionOutput`。
- 强制:先保存对外所需的字符串化错误,再对 raise、普通错误回复和 collect-status 正常返回
三条路径逐一执行同一清理;调用方把异常折叠成成功返回形态时仍必须释放原异常引用。
- 禁止:只在最外层 `except` 清理,却让内部状态封装路径正常返回;清理后继续从异常对象读取
message/traceback;用单一路径 mock 证明所有 RPC mode 都不会保留 device tensor。
- 验收:测试分别覆盖 `collect_rank_status=true` 与抛出/错误回复路径,断言错误文本仍可见、
`exc.__traceback__ is None`、cache cleanup 被调用,后续健康 RPC 仍成功。 ^[PR #6385]

相关执行流见 [Diffusion architecture](architecture.md);benchmark 证据合同见
[performance evidence](../../benchmark/guides/performance-evidence.md)。
4 changes: 2 additions & 2 deletions knowledge/repos/vllm-omni/components/serving/_index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Serving"
created: 2026-07-10
updated: 2026-07-31
updated: 2026-08-23
type: index
tags: [vllm-omni, components, serving]
sources: []
Expand All @@ -28,4 +28,4 @@ sources: []
| 遇到什么 | 查看哪里 |
|---|---|
| 理解入口到 engine 的边界 | [architecture](architecture.md) |
| 根据 PR 描述直达 request contract、streaming format、artifact readiness 或 metrics 的规则组与第一批源码 | [rules 与代码地图](rules.md) |
| 根据 PR 描述直达 request contract、streaming format、artifact readiness、factory lifecycle 或 metrics 的规则组与第一批源码 | [rules 与代码地图](rules.md) |
19 changes: 16 additions & 3 deletions knowledge/repos/vllm-omni/components/serving/rules.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: "Serving 规则"
created: 2026-07-20
updated: 2026-07-31
updated: 2026-08-23
type: rule
tags: [vllm-omni, components, serving]
sources: ["PR #3576", "PR #4718", "PR #4834", "PR #4905", "PR #4912", "PR #5157", "claude-workflow-starter-private@09dca46", "zuiho-kai/claude-workflow-starter@c217fc6", vllm_omni/entrypoints/async_omni.py, vllm_omni/entrypoints/openai/diffusion_request_utils.py, vllm_omni/entrypoints/openai/serving_speech.py, vllm_omni/metrics/prometheus.py]
sources: ["PR #3576", "PR #4718", "PR #4834", "PR #4905", "PR #4912", "PR #5157", "PR #6138", "claude-workflow-starter-private@09dca46", "zuiho-kai/claude-workflow-starter@c217fc6", vllm_omni/entrypoints/async_omni.py, vllm_omni/entrypoints/openai/diffusion_request_utils.py, vllm_omni/entrypoints/openai/serving_speech.py, vllm_omni/metrics/prometheus.py]
confidence: high
---

Expand All @@ -23,6 +23,7 @@ confidence: high
| `chat_template_kwargs`、raw HTTP/SDK `extra_body`、text/audio modalities、choices、空音频 | `chat-multimodal-contract`:`SERV-4c` + 命中模型规则 | upstream `ChatCompletionRequest` → `serving_chat.py::{OmniOpenAIServingChat._preprocess_chat,OmniOpenAIServingChat.chat_completion_full_generator,OmniOpenAIServingChat._create_text_choice,OmniOpenAIServingChat._create_audio_choice}` |
| endpoint restriction、unsupported route、capability、completions/chat/speech 400 | `endpoint-capability`:`SERV-4c`, `SERV-4d` | `config/endpoint_policy.py::{OmniServingCapability,shutdown_unsupported_routes}` → `config/config_factory.py::StageConfigFactory.get_pipeline_endpoint_restrictions` → `engine/async_omni_engine.py::AsyncOmniEngine.__init__` → `entrypoints/openai/api_server.py::build_app` |
| sleep/wake、partial stage/tag、idempotency、ACK、generation admission | `engine-lifecycle`:`SERV-5a`, `SERV-5b` | `entrypoints/async_omni.py::{AsyncOmni.sleep,AsyncOmni.wake_up,AsyncOmni.generate}` → `worker/base.py::{handle_sleep_task,handle_wake_task}` / `diffusion/worker/diffusion_worker.py` |
| serving class/factory 重构、optional adapter、diffusion/no-TTS 实例、warmup | `engine-lifecycle`:`SERV-5c` | `entrypoints/openai/serving_speech.py` 的所有 factory/`__new__` 路径 → `warmup`、voice upload/list、speech request caller |
| SSE/streaming speech、audio format、PCM/WAV、speed、首 chunk 前校验 | `streaming-format`:`SERV-1a`, `SERV-1b` | `vllm_omni/entrypoints/openai/protocol/audio.py::{OpenAICreateSpeechRequest.validate_streaming_constraints,StreamingSpeechSessionConfig.validate_streaming_constraints}` → `serving_speech.py::{OmniOpenAIServingSpeech._validate_speech_streaming_request,OmniOpenAIServingSpeech.create_speech}` |
| `ref_audio`、x-vector/ICL、artifact cache、readiness、失败后 engine 存活 | `artifact-readiness`:`SERV-3a`, `SERV-3b` | `vllm_omni/entrypoints/openai/serving_speech.py::{_qwen3_tts_can_use_ref_audio_artifact_only,_track_ref_audio_artifact_warmup,_mark_ref_audio_artifact_ready_for_request,_discard_ref_audio_artifact_ready_if_unreferenced}` |
| Prometheus、waiting/running gauge、replica stats、throttle、collector lifecycle | `metrics-lifecycle`:`SERV-2a`, `SERV-2b` | `vllm_omni/entrypoints/omni_base.py::{OmniBase._log_summary_and_cleanup,OmniBase._process_stage_metrics_message}` → `vllm_omni/metrics/prometheus.py::{OmniPrometheusMetrics.__init__,set_running,set_waiting}` |
Expand All @@ -35,7 +36,7 @@ confidence: high
| `artifact-readiness` | artifact cache、capability、ready/mark/discard | `SERV-3a`, `SERV-3b` |
| `chat-multimodal-contract` | chat template kwargs、SDK flatten、text/audio response shape | `SERV-4c` + 命中模型规则 |
| `endpoint-capability` | endpoint restriction、unsupported route、公开 400 | `SERV-4c`, `SERV-4d` |
| `engine-lifecycle` | sleep/wake、partial stage/tag、ACK、generation admission | `SERV-5a`, `SERV-5b` |
| `engine-lifecycle` | sleep/wake、partial stage/tag、ACK、generation admission、factory 状态矩阵 | `SERV-5a`, `SERV-5b`, `SERV-5c` |
| `request-contract` | 请求字段、来源、冲突、dispatcher、consumer view | `SERV-4a`, `SERV-4b`, `SERV-4c`, `SERV-4d`, `SERV-4e`, `SERV-4f`, `SERV-4g`, `SERV-4h` |
| `author-routing` | 只供 Direct reviewer 导航,不作为 finding 规则 | `SERV-0a`, `SERV-0b` |

Expand Down Expand Up @@ -192,5 +193,17 @@ confidence: high
sleep → wake → generate,不支持的 stage 在调用 worker 前明确拒绝。
^[PR #4834] ^[PR #4905] ^[PR #4912]

### SERV-5c — 共享服务类重构必须闭合全部构造状态

- 触发:移动 model-specific capability 到 adapter、增加 factory/`__new__` 快路径,或让同一
serving class 同时承载普通、无对应 stage、diffusion-only 等实例。
- 强制:列出每个生产构造入口及其必有/可选属性;所有公共 caller 通过统一 accessor 或显式
`None` 状态访问 optional capability,startup warmup 与 request route 使用同一状态合同。
- 禁止:只测试目标 adapter 的正常构造;在 factory 实例上直接读取未初始化属性;用旧的
model-type early return 掩盖无 adapter 状态。
- 验收:至少覆盖普通 adapter、无 adapter 和 bypass-`__init__` factory 三类实例,并实际调用
startup warmup、voice list/upload 与对应 request route;每条路径保持重构前的成功或结构化
错误合同,不得出现 `AttributeError`。 ^[PR #6138]

请求到 engine 的边界见 [Serving architecture](architecture.md);公开协议通用检查见
[review contracts](../../../../general/review/guides/reviewer-lens-contracts.md)。
Loading