[diffusion] refactor: refactor utility ownership and document helper placement (#38699)
Co-authored-by: Mick Qian <mickqian@users.noreply.github.com>
This commit is contained in:
@@ -351,7 +351,7 @@ Header fields:
|
||||
**Encodings.** `application/x-raw-rgb` is uncompressed RGB24 (3 × uint8, `bytes_per_frame = width*height*3`). `application/x-raw-rgb-delta-gzip` is the zlib-compressed **per-frame XOR delta** against the preceding frame (each frame in the batch is XOR'd against the previous one; sent by default). `realtime_output_format: "raw"` forces uncompressed RGB; `"webp"` / `"jpeg"` send preview-encoded frames.
|
||||
|
||||
<Note>
|
||||
delta-gzip must be restored **frame-by-frame**: decompress the payload, then for each frame XOR it against the already-restored previous frame (the first frame of a batch references the last frame of the previous batch). See `restore_delta_gzip_raw_rgb_payload` in `runtime/utils/realtime_video.py`. The `"raw"` format below avoids this.
|
||||
delta-gzip must be restored **frame-by-frame**: decompress the payload, then for each frame XOR it against the already-restored previous frame (the first frame of a batch references the last frame of the previous batch). See `restore_delta_gzip_raw_rgb_payload` in `runtime/realtime/video.py`. The `"raw"` format below avoids this.
|
||||
</Note>
|
||||
|
||||
### Minimal client example
|
||||
|
||||
@@ -8,7 +8,8 @@ This guide outlines the requirements for contributing to the SGLang Diffusion mo
|
||||
|
||||
## Contributor Guides
|
||||
|
||||
- [Support New Models](./support_new_models): implementation guide for adding new diffusion pipelines
|
||||
- [Support New Models](/docs/sglang-diffusion/support_new_models): implementation guide for adding new diffusion pipelines
|
||||
- [Helper ownership](/docs/sglang-diffusion/support_new_models#place-helpers-with-their-owners): where to put shared and model-specific utilities
|
||||
- [CI Performance](./ci_perf): update and regenerate perf baselines
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,30 @@ utilities, and common action-policy helpers. Model packages may call these
|
||||
helpers. Keep ownership in shared runtime folders unless the code is truly
|
||||
architecture-specific.
|
||||
|
||||
## Place helpers with their owners
|
||||
|
||||
Use the narrowest existing owner before adding a utility module:
|
||||
|
||||
| Scope | Location |
|
||||
| --- | --- |
|
||||
| Used by one file, or specific to one operation | A private helper in the consuming file; inline short one-off expressions |
|
||||
| Shared within a domain | A purpose-named module in that domain, such as `runtime/realtime/video.py` or `runtime/layers/attention/mask_strategy.py` |
|
||||
| Shared across domains, without model or pipeline semantics | An existing focused module under `runtime/utils/`, such as `argparse.py`, `process.py`, or `precision.py` |
|
||||
|
||||
Do not create a top-level `utils/` package or grow a catch-all `utils.py` or
|
||||
`common.py`. Split large mixed-responsibility files along ownership boundaries,
|
||||
not arbitrary line counts. A helper folder is warranted only when several
|
||||
cohesive modules need it, not for a single function or hypothetical reuse.
|
||||
|
||||
Model code must not import pipeline stages. Put contracts shared by models and
|
||||
stages in a lower-level domain module; for example, realtime cache keys belong
|
||||
under `runtime/realtime/`. Keep GPU initialization, monkey patches, and model
|
||||
loading out of generic utility imports.
|
||||
|
||||
When moving internal helpers, update all callers, tests, and cookbook examples
|
||||
together. Preserve documented registration and serving entry points; do not
|
||||
add re-export chains just to retain obsolete internal utility paths.
|
||||
|
||||
## Out-of-Tree Models and Pipelines
|
||||
|
||||
An installed package can register native component models and a pipeline
|
||||
|
||||
Reference in New Issue
Block a user