Skip to content

adding the triton docker build minimal example - #242

Merged
merrymercy merged 4 commits into
sgl-project:mainfrom
amirarsalan90:main
Mar 12, 2024
Merged

merrymercy merged 4 commits into
sgl-project:mainfrom
amirarsalan90:main

Conversation

@amirarsalan90

Copy link
Copy Markdown
Contributor

Adding a minimal example to build docker container to serve sglang with triton inference server using python backend.

@amirarsalan90 amirarsalan90 mentioned this pull request Feb 28, 2024
@isaac-vidas

isaac-vidas commented Feb 28, 2024 •

Copy link
Copy Markdown
Contributor

Thanks for this example!

Would it be possible to run the server from inside the model.py file with:

runtime = sgl.Runtime(model_path="mistralai/Mistral-7B-Instruct-v0.2")
sgl.set_default_backend(runtime)

@amirarsalan90

amirarsalan90 commented Feb 28, 2024 •

Copy link
Copy Markdown
Contributor Author

tritonserver --model-repository=/path/to/model/repository command halts when I try to run server in model.py with sgl.Runtime to load mistralai/Mistral-7B-Instruct-v0.2. I didn't try models other than mistralai/Mistral-7B-Instruct-v0.2 though

@merrymercy

Copy link
Copy Markdown
Collaborator

@amirarsalan90 Thanks for contributing to this! Could you document the files better?

  1. Why is the folder name called "1"?
  2. What is the purpose of examples/usage/triton/inference.ipynb? Can it be deleted?
  3. Can you share an example command to query the triton server?

@merrymercy merrymercy self-assigned this Mar 11, 2024
@isaac-vidas

Copy link
Copy Markdown
Contributor

@merrymercy this implementation follows Triton's convention for model registry. See here for more details. The schema of the API inputs / outputs is specified in the config.pbtxt and the model itself is then placed under 1 folder next to it.
While this is a working solution, I suspect that this is mostly running SGLang as is behind Triton where it's still required to run the backend process independently.

A different approach to this could be to run as a triton backend similar to what vLLM do here. I suspect this would be a bit more involved with how SGLang creates the backend processes as part of the server but haven't looked into it too closely.

@amirarsalan90

Copy link
Copy Markdown
Contributor Author

@merrymercy as @isaac-vidas explained, that is the directory convention for triton inference server for model registry. I removed the inference.ipynb notebook and added curl request to the readme file to query the triton server.

As far as I understand, vllm backend for triton inference server also disables some features of Triton (like batching) and has some limitations:
https://github.com/triton-inference-server/vllm_backend/blob/c1c88fa7dfbebcd3198ada913e127304d5ff0b46/src/model.py#L93

https://github.com/triton-inference-server/tutorials/blob/main/Quick_Deploy/vLLM/README.md

But I agree this is a very minimal and basic way to set up triton for sglang. I needed it for a project of mine, and thought it might be helpful for others too.

@merrymercy
merrymercy merged commit eb4308c into sgl-project:main Mar 12, 2024
@merrymercy

Copy link
Copy Markdown
Collaborator

@amirarsalan90 It is merged. Thanks!

timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
sammysun0711 added a commit to sammysun0711/sglang that referenced this pull request Apr 20, 2026
* Enable aiter flash attention for full atttention

Signed-off-by: Xiake Sun <[email protected]>

* Enable aiter backend in CI

Signed-off-by: Xiake Sun <[email protected]>

---------

Signed-off-by: Xiake Sun <[email protected]>
efschu added a commit to efschu/htsglang that referenced this pull request Jul 29, 2026
…t mit MoE-Experten-Spill-Maschinerie (sgl-project#77/sgl-project#123/sgl-project#125/sgl-project#236/sgl-project#242) — ein generisches VRAM-Posten-Tiering mit Klassen-Registrierung statt Parallel-Mechanismus; Slice beginnt mit Schnittstellen-Audit statt Neubau
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 4, 2026
…rop code that cannot run

VERDICT: liftable, not impossible -- but not blind, and not in this commit.

The refusal read, in full: "--enable-kv-session-offload is its own host tier;
it cannot be combined with --enable-hierarchical-cache or
--enable-unified-memory." That is a DESCRIPTION of the two features, not a
reason for the exclusion, and it left every reader unable to tell a physical
impossibility from an unbuilt piece.

Checked in the tree rather than assumed:
- the host buffers are two INDEPENDENT MHATokenToKVPoolHost objects with
  separate lifecycles (hiradix_cache.HiRadixCache.__init__ vs
  model_runner_kv_cache_mixin);
- the key spaces are DISJOINT: kvso addresses host rows by sentinel slot ids
  strictly above the device allocator's range (sentinel_base), HiCache by its
  own page indices and hash-derived storage keys -- no sgl-project#241-class collision;
- neither module reads the other's state.

What is actually missing:
(1) NOBODY SUMS THE PINNED HOST RAM. kvso validates its budget alone
    (host_ram_budget_error, once, in the launcher); HiCache sizes its pool from
    hicache_ratio/hicache_size and validates independently. Both are PINNED, so
    an over-commit is the OOM killer picking a victim on a swap-less box, not a
    swap. Buildable at the desk.
(2) THE TRANSFER CONTENTION IS UNMEASURED. kvso streams a spilled tail D2H/H2D
    on its own copy stream inside the decode loop's critical path; HiCache's
    controller runs backup/prefetch on its own threads and streams. Both cross
    the same link into pinned host memory. Latency, not correctness -- but the
    spill tick's latency budget IS the feature. Needs the rig.

THE SHARPER HALF -- DEAD INTEROP CODE. force_host_write_through (sgl-project#242) exists so
a kvso budget demotion hands its prefix over losslessly under HiCache: the
donating insert is exempted from HiCache's hit-count write-through heuristic,
which would otherwise drop exactly the leaves the session just produced. It has
ONE producer (kv_session_offload._budget_demote) and its readers are the prefix
caches, whose host tier exists only when hierarchical caching is initialised
(mem_cache/registry.py). The boot refuses that pair -- so the mechanism cannot
fire, while FEATURES_VS_UPSTREAM stated flatly that "the hand-over is lossless
under HiCache", describing behaviour no boot can reach. That row now says
written-and-unreachable until sgl-project#547.

This commit therefore keeps the exclusion and makes it honest: the refusal names
both blockers, states explicitly that this is not a physical impossibility, and
names the task that owns the lift.

Tests (CUDA_VISIBLE_DEVICES=99, hermetic, no GPU, no server):
  PYTHONPATH=python pytest test/registered/unit/server_args -q
  -> 551 passed, 19 warnings, 86 subtests passed in 12.32s

CAN-FAIL PROVEN: restoring the old one-sentence refusal turns 6 of the 11 new
tests red (sgl-project#547 absent, "Not a physical impossibility" absent, "PINNED host RAM"
absent, "never been measured" absent, the bare restatement back). The structural
half is a ratchet: it goes red the moment force_host_write_through gains a
producer outside kv-session-offload or a reader outside the prefix cache layer,
because either would invalidate the dead-interop reasoning rather than silently
outdate it.

FEATURE_CATALOG gains the unreachable-interop family entry.
Handoff: /spinning/spill-night-20260804/handoffs/TICKET_547_hicache_x_kvso.md --
ordered work (joint pinned-RAM budget -> opt-in flag -> A-vs-A-floored
measurement boot), and it explicitly needs its OWN boot rather than a change to
the running K-series recipes.

ruff check + format: clean. codespell: clean.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 28, 2026
…Borrow -- Aktivierung je Stufe, Stage-Fixed und Mamba-Rate gemessen auf NF

Befund (planer_befund_nvml2.md, nachgemessen 28.09. ueber 62 NF-Boots 26.-28.09., Schnitt 29,11,8, FR_P 0.324/0.637/0.734, Chunk 16384): das Pool-Modell eines NF-Boots bucht drei 27B-Zeilen und EINEN Skalar fuer alle Stufen:
- P_PP_STAGE_FIXED_MIB 2342/1106/3518 (27B, mit Draft-Kopf auf der letzten Stufe, den NF-P seit H25 nicht mehr traegt); NF misst 1584.0/527.1/1065.4 (Runtime 'weights + runtime state' 16.836/10.475/9.221 GiB minus Pool-Term 539.87/927.21/1047.11 MiB/Schicht).
- P_MAMBA_MIB_PER_LINEAR_LAYER_PER_SLOT 1.5588 (27B); NF 1.5594/1.5602/1.5573 -> 1.5602.
- Aktivierungsposten max(1024, groesste Stufe) = 3697 fuer JEDE Stufe; gemessen (Planer-Definition peak - allocated, jedes WEG2-VRAM-PEAK-Chunkfenster) PP0 3441 bei einer Sequenz je Chunk, 4394/5310/5979 bei 2/3/4 Sequenzen im 16k-Chunk; PP1 2945, PP2 2941 in jedem Lastzustand.
Live-Boot dkrnfh91dprsavisnoadopts0bar1dauer09281111 (rc12z17): PP-POOL-JOIN priced minus realised -758/-988/-2883 MiB.

Fix:
- nextflash.json: P_ACTIVATION_MIB 5984/2952/2944 (Chunk 16384, Abdeckung bs 1..5 je Chunk, bs6 nicht gesehen, elastisch), P_PP_STAGE_FIXED_MIB und P_MAMBA_MIB_PER_LINEAR_LAYER_PER_SLOT als eigene Records (pp_layer_ratio 29,11,8), aus borrow gestrichen. P_OVERSHOOT_MIB bleibt geborgt: unter der P-KV-Klemme (262144) bindet das Budget keine Allokation, peak - Budget hat keinen Fixpunkt (wie D_OVERSHOOT, rc12c) -- gehoert an die Form, nicht in diesen Record.
- launcher: p_transient_support() -- der Record ersetzt den eingebauten 16384-Stuetzpunkt (RECORD > BUILTIN) fuer den Runtime-Posten (SGLANG_KV_BUDGET_PREFILL_TRANSIENT_MIB) und das Pool-Modell; die P-KARTE nimmt max(builtin, record) je Stufe, bis ihre Referenz auf dieser Form neu gemessen ist. p_prefill_activation_reserve_by_stage_mib() + Logzeile 'PP-CUT activation post (sgl-project#242)'.
- pp_cut.PhasePoolModel.activation_reserve_mib_by_stage: der Posten je Stufe (leer = der Skalar, 27B byte-identisch).

Planer-Dry-Run gegen den Live-Boot (offline, CPU): Pool je Rang 796942/778073/653934 -> 573058/1229543/2294866 Token (bindend PP2 -> PP0), PP-POOL-JOIN <= 1 MiB je Rang; Boden 262144 und YaRN x2 524288 bestehen. P-KARTE PP0 Kopfraum 2932 -> 645 MiB (Rechnung, T +2287), PP1/PP2 unveraendert.

Tests: test_weg2_p_records_242 (10, alle rot auf ff7a9cb, gruen mit Fix); Pin-Tests test_unify_s3_model_profile / test_unify_s9_records auf die eigenen NF-Records nachgezogen. Betroffene Suiten (17 Dateien, 437 Tests): 0 neue Rote; 2 Altlasten identisch auf der Basis (test_pp_cut_boot_sizing_1286 runtime-post-census, test_pp_cut_pool_floor_1286b launcher-seam).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 28, 2026
…ern -- Chunk-0-Punkt nur Ein-Sequenz-Chunk, Wachstum = Grundstand (Rate je Request-Instanz, Kappe ueber alle Lastzustaende)

Befund (28.09., Boots der H91-Dauerform rc12z14..rc12z19, 13 P-Logs mit GRAPH-POOL): p_card_reference_from_logs nahm das Wachstum aus der Hochwassermarke last = max(samples, key=(chunk_index, peak)) minus Chunk-0-Punkt. Eine GRAPH-POOL-Zeile ist ein Hochwasser (Schritt 0,25 GiB), ihr Chunk-Index ist der Start des ERSTEN Requests, und unter H91 traegt ein 16k-Chunk 2-5 Sequenzen. Boot dkrnfh91dprsavisbar1dauer09280831 08:45:23: bs4-Chunk am Chunk-Index 1, Spitze +1942 MiB ueber dem Chunk-0-Punkt -> PP0-Wachstum 1942 MiB je 16k, P-KARTE PP0 Kopfraum -10646 MiB bei 262144 Token. Das ist die Mehr-Sequenz-TRANSIENTE (traegt P_ACTIVATION_MIB, sgl-project#242), kein Wachstum mit der Tiefe. Dazu wiederholen sich rids (weg2-4-2 startet bei 0 neu, waehrend die erste Instanz bei 53185 parkt).

Messung (H55 WEG2-VRAM-PEAK phase=chunk je Chunk, allocated NACH dem Chunk = Grundstand): der Grundstand waechst mit der Tiefe und saettigt -- ueber alle Lastzustaende der heutigen Boots PP0 +1211, PP1 +1056, PP2 +398 MiB gegen den Ein-Sequenz-Chunk-0 (bs1 bis Tiefe 98304, bs2-4 bis 96880); innerhalb EINER Request-Instanz in Ein-Sequenz-Chunks steilster Anstieg 377/347/340 MiB je 16k-Chunk. Die Spitze darueber ist Transiente (peak - allocated danach): heute max 4585/2945/2943, Record 5984/2952/2944.

Fix: p_card_reference_from_logs(windows=True) -- der Launcher waehlt es, wenn ALLE Referenz-Logs H55-Fenster und #969N ADMIT tragen (logs_carry_seq_windows; fnFL2x163-165 bleiben beim alten Weg, P_CARD_REFERENCE_FNFL2 byte-gleich):
- seq_windows: je H55-Chunkfenster Sequenzzahl (letzte #969N ADMIT), Request-Instanz (rid#n, neuer Start bei 0 = neue Instanz, aus allen reqs der sgl-project#969 EXTENT), Tiefe, Grundstand gegen den ersten Ein-Sequenz-Chunk-0 der Stufe;
- Chunk-0-Punkt nur ein Ein-Sequenz-Chunk voller Breite, normiert mit SEINER gemessenen Transiente statt dem Stuetzpunkt;
- window_growth: Rate = steilster Anstieg je Chunk in einer Instanz (nie unter einem Messpunkt), Kappe = hoechster Grundstand ueber alle Fenster jeder Last, Saettigung = ceil(Kappe / Rate); Fenster aller Boots gepoolt (Instanzen je Boot benannt), auch Boots ohne eigenen Chunk-0-Punkt;
- PCardReference.growth_cap_mib (neu, leer = ungekappt): solve_p_card kappt Rate x Chunks am gemessenen Maximum.

Planer-Dry-Run (offline, CPU, Live-Form rc12z17: Schnitt 29,11,8, Chunk 16384, 6 Sitze, Mamba 32, Budgets 28240/17680/17168, NF-Records sgl-project#242, Mitbewohner-Spanne 2310/1012/1012, Stuetzpunkt Karte = max(builtin, Record)), P-KARTE bei 262144 Token, FR_P heute 0.324/0.637/0.734 (198/359/408 Zeilen):
- Referenz ALT fnFL2x163-165: PP0 Kopfraum 338 (STIRBT) Decke f 0.322 (197 Z.), PP1 1100 Decke 0.689 (385), PP2 3407 Decke 0.996 (563)
- Referenz naiv neu (Hochwasser): PP0 -10646 (Wachstum 1942/16k) -- das Instrument, nicht die Karte
- Referenz NEU (Fenster): PP0 Kopfraum -462 Decke f 0.298 (185 Z.), PP1 519 Decke 0.646 (363), PP2 3316 Decke 0.996 (558; W120-Kappe 2 Scratch-Zeilen)
- Pool (PP-Cut-Modell) an der Decke 185/363/558: Tokens je Rang 706365/1193240/809739, Pool 706365; nur PP2 an die Decke: 573058/1229543/809739; Boeden 262144 und 524288 halten.
Luft am Metall (H55-Fenster, NVML card_free am Fensterende, 390 Chunks je Stufe): PP0 min 167 (bs1) / 319 (bs2) / 171 (bs>=3), PP1 86/88/88, PP2 2098/2284/2144 MiB -- NVML ist Untergrenze (Allokator-Polster reserved - peak kommt dazu).
Abdeckung: nur P-Phase Chunk-Forward; Last bs1..4 gemessen (bs5 nur im Record 5984), Tiefe bis 121868 Token (Wachstum saettigt ab Chunk 4, dahinter Saettigung angenommen), Mitbewohner D-TP schlafend (Flips bis 6); NICHT abgedeckt: Flip-Phase (Wake-Kredit H54/W126) und D-Phase -- dort ist PP2s Mehr-Residenz eigens zu rechnen.

Tests test_weg2_p_card_windows_242b (8, Fixture = gefilterte echte P-Zeilen dkrnfh91dprsavisbar1dauer09280831, 645 Zeilen): alle 8 rot auf d604c34, gruen mit Fix (darunter: alter Weg liest die bs4-Transiente als 1942/16k; Instanz-Neustart bei 0; ein Boot mit nur Chunk 1 kuerzt die Saettigung nicht; Kappe im Solve; ausgelieferte Referenz ungekappt). Gate betroffene Dateien (p_card_chunk/launcher-Leser: h41, h92c, h55, h57, 1a, h101, 242): NEU 203 gruen, Basis 195 gruen + 8 neue rot, 0 neue Rote.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 29, 2026
…tt 27B-Borrow [920,0,512]

Die NF-Linie buchte den P-Ueberstand mit der 27B-Zeile (boot weg2ls2b2):
920 auf der 5090, 0 auf PP1, 512 auf PP2. Gemessen an der KARTE ueber die
zehn NF-Boots mit sgl-project#242 (28.09. 12:09-19:38Z, 69-596 WEG2-VRAM-PEAK-Fenster
je Rang): excess = Korridor + gebuchter Ueberstand - freie Karte am
Fenster-Peak; der Record ist, was der builtin awake_overshoot 404 nicht
traegt. Schlimmstes Fenster: PP0 +856 (frei 1523, 7d50735 14:47) -> 452,
PP1 +801 (frei 698, dwell30 14:59) -> 397, PP2 <= +74 (frei >= 1700) -> 0.
Budget gegen den Borrow: PP0 +468, PP1 -397, PP2 +512 MiB.

Die P-Budgetzeile nennt jetzt die Boots des Profil-Records
(_pconst_boots) statt fest 'boot weg2ls2b2'. Die 27B-Zeile und der
Launcher-Alias P_OVERSHOOT_MIB bleiben [920, 0, 512].

Test test_weg2_nf_records_240 (5): 4 rot auf f833fcb, gruen mit Fix;
s9/s3-Record-Tests auf 13 geborgte Zeilen angepasst; 84 passed in den 5
betroffenen Dateien.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants