Skip to content

[diffusion] Support Ideogram TurboTime LoRA inference - #30487

Merged
mickqian merged 2 commits into
sgl-project:mainfrom
Jzz1943:dev-ideogram-turbotime-lora
Oct 6, 2026
Merged

mickqian merged 2 commits into
sgl-project:mainfrom
Jzz1943:dev-ideogram-turbotime-lora

Conversation

@Jzz1943

@Jzz1943 Jzz1943 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR adds support for Ideogram 4 TurboTime-style distilled LoRA inference, targeting the public ostris/ideogram_4_turbotime_lora adapter. This LoRA is designed for few-step generation with no CFG and no unconditional transformer branch.

Modifications

  • Add Ideogram 4 TurboTime LoRA presets:

    • V4_TURBOTIME_LORA_2
    • V4_TURBOTIME_LORA_4
    • V4_TURBOTIME_LORA_8
  • Add request-local LoRA scaling for diffusion LoRA layers.

    • Base Ideogram presets such as V4_DEFAULT_20, V4_QUALITY_48, and V4_TURBO_12 use runtime_lora_scale=0.0, so they can still run the base model even when the server is started with --lora-path.
    • TurboTime LoRA presets use runtime_lora_scale=1.0 and require an active LoRA on the main transformer.
  • Support request-local dynamic LoRA for Ideogram 4 quantized checkpoints.

    • NF4 uses the existing dynamic LoRA path.
    • FP8 is enabled by adding dynamic LoRA support for weight-only FP8 linear layers.
  • Update the Ideogram 4 denoising path to skip the unconditional transformer when the selected preset declares skip_unconditional=True.

  • Update progressive-resolution Cache-DiT refresh logic so that, when the unconditional branch is skipped, only the active transformer context is refreshed.

Accuracy Tests

Accuracy Tests

Manual smoke tests were run with Ideogram 4 FP8 and the public TurboTime LoRA adapter.

Server command:

sglang serve \
  --model-path ideogram-ai/ideogram-4-fp8 \
  --model-type diffusion \
  --num-gpus 1 \
  --performance-mode speed \
  --host 0.0.0.0 \
  --port 30010 \
  --lora-path ostris/ideogram_4_turbotime_lora \
  --lora-merge-mode dynamic \
  --lora-scale 1.0 \
  --enable-torch-compile

Tested presets:

  • Base: V4_DEFAULT_20, V4_QUALITY_48, V4_TURBO_12
  • LoRA: V4_TURBOTIME_LORA_2, V4_TURBOTIME_LORA_4, V4_TURBOTIME_LORA_8

Example request:

import json
import time
from openai import OpenAI

client = OpenAI(api_key="EMPTY", base_url="http://localhost:30010/v1")

caption = {
    "high_level_description": "A golden retriever riding a skateboard down a sunny sidewalk.",
    "style_description": {
        "aesthetics": "warm, playful, vibrant",
        "lighting": "bright afternoon sunlight, long soft shadows",
        "photo": "shallow depth of field, eye-level, 85mm lens",
        "medium": "photograph",
        "color_palette": ["#F5C542", "#87CEEB", "#4A4A4A", "#FFFFFF", "#2E8B57"],
    },
    "compositional_deconstruction": {
        "background": "A sun-drenched suburban sidewalk lined with green hedges and a white picket fence. Dappled light filters through overhead trees.",
        "elements": [
            {
                "type": "obj",
                "bbox": [200, 300, 800, 900],
                "desc": "A golden retriever with a fluffy coat, standing on a red skateboard with all four paws. Its tongue is out and ears are flapping in the wind.",
            },
            {
                "type": "obj",
                "bbox": [250, 750, 750, 950],
                "desc": "A worn red skateboard with black wheels rolling along the concrete sidewalk.",
            },
        ],
    },
}

t0 = time.perf_counter()
response = client.images.generate(
    model="ideogram-ai/ideogram-4-fp8",
    prompt=json.dumps(caption, separators=(",", ":"), ensure_ascii=False),
    size="1024x1024",
    n=1,
    response_format="b64_json",
    extra_body={
        "preset": "V4_TURBOTIME_LORA_8",
        "seed": 42,
    },
)
print("cost time:", round(time.perf_counter() - t0, 2), "s")
print("num images returned:", len(response.data))
assert len(response.data) == 1
assert response.data[0].b64_json is not None

Also verified request-local behavior with the same prompt and seed sequence:

  1. V4_DEFAULT_20
  2. V4_TURBOTIME_LORA_8
  3. V4_DEFAULT_20

The two V4_DEFAULT_20 requests used the base-model path, while V4_TURBOTIME_LORA_8 used the LoRA path and skipped the unconditional transformer branch.

Speed Tests and Profiling

  • GPU: NVIDIA B200
  • The following table compares the base Ideogram 4 preset with the TurboTime LoRA presets using the same prompt and seed.
Preset V4_DEFAULT_20 V4_TURBOTIME_
LORA_8
V4_TURBOTIME_
LORA_4
V4_TURBOTIME_
LORA_2
Output ideogram4_20steps LoRA_8steps LoRA_4steps LoRA_2steps
Denoising steps 20 8 4 2
Latency 3.46s 0.96s 0.58s 0.39s

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #37406235131
Latest PR Test (Extra): ❌ Run #37406234816
Latest PR Test (AMD ROCm 10): ❌ Run #37406235070

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@Jzz1943
Jzz1943 force-pushed the dev-ideogram-turbotime-lora branch from 44f855f to d19066d Compare July 8, 2026 07:55
@Jzz1943

Jzz1943 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Ideogram 4 TurboTime LoRA presets, dynamic-only LoRA for weight-only FP8 linear layers, and conditional-only denoising by skipping unconditional generation. The review feedback highlights critical issues regarding Tensor Parallelism compatibility, where other LoRA linear subclasses override the forward method and ignore the new lora scale helper. Additionally, it is recommended to move the import of get_forward_context to the module level to avoid overhead in the hot path, and to dynamically inspect the signature of _refresh_cache_dit_context to prevent TypeError crashes in other subclasses that do not yet accept the new ctx parameter.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Jzz1943
Jzz1943 force-pushed the dev-ideogram-turbotime-lora branch from d19066d to dff4c8d Compare July 8, 2026 08:40
@Jzz1943

Jzz1943 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for dynamic LoRA scaling, weight-only FP8 LoRA layers, and optimized denoising presets (such as skipping unconditional transformer steps) for Ideogram 4. The reviewer feedback suggests removing the dynamic inspect.signature check in the progressive resolution denoising stage by updating the base class and subclass signatures of _refresh_cache_dit_context to accept ctx directly. Additionally, it is recommended to add type annotations to the newly introduced _add_lora_delta helper method in linear.py for better static analysis and readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Jzz1943
Jzz1943 force-pushed the dev-ideogram-turbotime-lora branch from dff4c8d to d00f229 Compare July 8, 2026 08:57
@Jzz1943

Jzz1943 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Ideogram 4 Turbotime LoRA presets, enabling features like skipping unconditional denoising steps and scaling LoRA weights dynamically at runtime. It also adds a dynamic-only LoRA wrapper for storage-only FP8 linear layers. Feedback on the changes highlights a potential AttributeError in _runtime_lora_scale when accessing the forward context, and a potential TypeError in other models' progressive denoising stages if they override _refresh_cache_dit_context without accepting the new ctx parameter.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Jzz1943

Jzz1943 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@mickqian @AgainstEntropy Kindly review this PR, thanks!

@mickqian

mickqian commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 6, 2026
@mickqian
mickqian merged commit 1be3013 into sgl-project:main Oct 6, 2026
133 of 142 checks passed
detain added a commit to detain/sglang that referenced this pull request Oct 8, 2026
sgl-project#43028's base carries the old 4-site LoRA forwards plus the runtime scale
input from sgl-project#30487; this stack has the sgl-project#37460 rework and no runtime scale,
so the three commits land as their net final state: BaseLayerWithLoRA.
_scale_lora_delta folds alpha/rank and strength multiplies, skipping
elementwise muls entirely at unit scale (measured ~6%/multiply on LTX-2
refinement LoRA stages). Ported test counts aten.mul ops at 0/1 across
strength x {nn.Linear, ReplicatedLinear}.

PR commits: 051cf1c 6d9f811 17302ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion lora run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants