sglang.multimodal_gen).
Contributor Guides
- Support New Models: implementation guide for adding new diffusion pipelines
- Helper ownership: where to put shared and model-specific utilities
- CI Performance: update and regenerate perf baselines
- SGLang Plugin System: package a hardware platform outside the SGLang repository
On AI-Assisted (“Vibe Coding”) PRs
Vibe-coded PRs are welcome — we judge code quality, not how it was produced. The bar is the same for all PRs:- No over-commenting. If the name says it all, skip the docstring.
- No over-catching. Don’t guard against errors that virtually never happen in practice.
- Test before submitting. AI-generated code can be subtly wrong — verify correctness end-to-end.
Pull request titles
Follow the repository-wide PR title convention. Usediffusion as the scope, or diffusion/<submodule-or-model> when a more specific scope helps.
diffusion belongs in the scope, not in a hardware tag or a separate [Diffusion] prefix. Omit the hardware tag unless the change is hardware-specific.
Performance Reporting
For PRs that impact latency, throughput, or memory usage, you should provide a performance comparison report.How to Generate a Report
-
Baseline: run the benchmark (for a single generation task)
-
New: run the same benchmark, without modifying any server_args or sampling_params
-
Compare: run the compare script, which will print a Markdown table to the console
- Paste: paste the table into the PR description
CI-Based Change Protection
Consider adding tests to thepr-test or nightly-test suites to safeguard your changes, especially for PRs that:
- support a new model
- add a testcase for this new model to
testcase_configs.py
- add a testcase for this new model to
- support or fix important features
- significantly improve performance
perf_baselines.json by following the instruction in console if applicable.
See test for examples
Host-sync regression tests
A denoising step or a DiT forward should not block the host on the device. Oneitem(), float(t), if t:, .cpu(), nonzero or pageable torch.tensor(..., device="cuda") per step stops the host from queueing the next step while the GPU runs this one. test/unit/host_sync_guard.py has three guards for unit tests:
no_cuda_sync(allow=...)andassert_no_cuda_sync(fn, ...)run the code undertorch.cuda.set_sync_debug_modeand fail with the call site of every sync whose issuing function is not listed inallow("<file suffix>:<function>"). They skip without CUDA. Call the code once outside the guard first, so first-use setup is not counted.SyncOnReadis a CPU stand-in for device tensors (timesteps, sigmas, masks): reading its values on the host raises. Run the step once with plain tensors and once with stand-ins, and require bitwise-equal outputs.forbid_host_syncs()is a dispatch mode for code that builds its own tensors: it fails on the ops that sync on CUDA whatever tensor they read (scalar reads,nonzero, boolean-mask indexing, data-dependent output shapes).
test_host_sync.py shows both on the shared denoising loop. Unit tests run in the multimodal-gen-unit-test CI job on an H100, so the CUDA guard runs there.
Out-of-tree platform changes
Use thesglang.multimodal_gen.platforms entry-point group when a hardware integration can live in a separately installed package. The plugin guide describes the activation callback, diffusion platform contract, and selection behavior.
When you change the platform interface or discovery implementation in SGLang:
- Add focused CPU-only tests with a fake OOT platform.
- Run the relevant SRT plugin tests when changing shared hook-registry behavior.
- Document workload-specific kernels or optimized paths that still require vendor integration.
