#!/usr/bin/env python3
"""Render the schematic for Qwen30 Fixed-PD TTFT admission diagnosis."""

from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np


OUTPUT = Path(__file__).with_name("qwen30-fixed-pd-ttft-admission-mock.png")


def main() -> None:
    figure, axes = plt.subplots(1, 2, figsize=(10.8, 4.2))

    labels = ["TP2/MNS64", "TP4/MNS64"]
    x = np.arange(len(labels))
    axes[0].bar(x, [190, 135], label="Prefill execution (mock)", color="#4c78a8")
    axes[0].bar(
        x,
        [30, 6000],
        bottom=[190, 135],
        label="Admission wait (mock)",
        color="#f58518",
    )
    axes[0].set_xticks(x, labels)
    axes[0].set_yscale("log")
    axes[0].set_ylabel("TTFT decomposition (ms, log scale)")
    axes[0].set_title("(a) Execution error or queue amplification?")
    axes[0].legend(frameon=False)

    width = 0.34
    axes[1].bar(x - width / 2, [8, 15], width, label="Real required slots (mock)")
    axes[1].bar(x + width / 2, [58, 80], width, label="Frontier required slots (mock)")
    axes[1].axhline(64, color="#d62728", linestyle="--", label="MNS=64")
    axes[1].set_xticks(x, labels)
    axes[1].set_ylabel("arrival rate × residence time")
    axes[1].set_title("(b) Does modeled state cross admission cap?")
    axes[1].legend(frameon=False)
    axes[1].text(
        0.02,
        0.97,
        "SCHEMATIC / MOCK DATA",
        transform=axes[1].transAxes,
        va="top",
        fontsize=9,
        color="#8c2d04",
    )

    figure.suptitle("Qwen30 Fixed-PD TTFT diagnosis", fontsize=13)
    figure.tight_layout()
    figure.savefig(OUTPUT, dpi=180, bbox_inches="tight")


if __name__ == "__main__":
    main()
