-
Notifications
You must be signed in to change notification settings - Fork 46
Add fake demo runtime vertical slice #433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jarcherNV
merged 51 commits into
dev/jarcher/inference-runtime-api
from
dev/jarcher/unified-demo-runtime
Aug 10, 2026
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
59e9a85
Add fake demo runtime vertical slice
jarcherNV 42c7859
Fix demo session invariant cleanup
jarcherNV 539911e
Finalize direct demo driver invariant failures
jarcherNV d06df9f
Add RuntimeHost worker boundary
jarcherNV d661edb
Apply Phase 3 test import formatting
jarcherNV dbf33a9
runtime: extract demo run mode session helpers
jarcherNV 6f83fdf
runtime: finalize session edges when invariant cleanup dispatch fails
jarcherNV 631963b
runtime: guard cleanup error recording during teardown
jarcherNV dbfd430
runtime: add realtime timing contracts
jarcherNV d1cb914
runtime: add realtime session driver
jarcherNV 3b08bd3
runtime: clarify unavailable host cleanup
jarcherNV b856f48
runtime: harden batch cleanup finalization
jarcherNV 4a3b807
runtime: split demo step requirements from input windows
jarcherNV 19a4449
runtime: add MP4 and null demo output sinks
jarcherNV 9d3afd9
runtime: add demo capability validation
jarcherNV b16920e
runtime: avoid serving dependency in demo timing
jarcherNV a9d3860
runtime: split demo warmup setup
jarcherNV c8314f9
runtime: guard run cleanup telemetry failures
jarcherNV 7f36767
Phase 10: unify demo metrics and error policies
jarcherNV 5abea73
Phase 11: extract legacy runner onto shared batch path
jarcherNV 386e9b0
Phase 11.5: adopt shared replay output sinks
jarcherNV 42eeaaf
Phase 12: decompose shared WebRTC session edges
jarcherNV 75a2a7d
runtime: fix WebRTC service import ordering
jarcherNV 60bef84
runtime: harden realtime WebRTC service contracts
jarcherNV 6ca870c
runtime: route WebRTC sessions through realtime driver
jarcherNV b137f75
runtime: shield async invariant cleanup
jarcherNV f021b99
runtime: attempt provider cleanup after session timeout
jarcherNV eb57155
Reshape OmniDreams replay runtime toward shared contract
jarcherNV 03de4c5
Wire OmniDreams precomputed HDMaps through provider
jarcherNV 3affc4f
Fix provider cleanup after session close timeout
jarcherNV 19a5727
Add OmniDreams replay null output mode
jarcherNV 62c3b79
Shield pre-edge provider cleanup from cancellation
jarcherNV f988ce4
Preserve worker affinity for cleanup timeouts
jarcherNV c3609f7
Mark cleanup dispatch failures unhealthy
jarcherNV e976b44
Document worker-affine cleanup timeout tradeoff
jarcherNV d7b39fd
Phase 14: add OmniDreams Ludus replay provider
jarcherNV 26735b5
Add OmniDreams Ludus keyboard trace
jarcherNV 758eabe
Mark runtime host unhealthy on cleanup close failures
jarcherNV 84b1a6c
Quarantine runtime host on cleanup failures
jarcherNV 26e4510
Document runtime cleanup quarantine rationale
jarcherNV 1acd7d5
Collapse OmniDreams WebRTC onto shared runtime session
jarcherNV 53c1b9d
Fix OmniDreams WebRTC shared runtime warmup
jarcherNV 8c68f20
Keep OmniDreams WebRTC encoders across warmup
jarcherNV a2ae69b
Cap OmniDreams WebRTC video display size
jarcherNV 16cd15d
Load OmniDreams WebRTC video sizing stylesheet reliably
jarcherNV ea817a4
Close async demo provider on pre-driver cancellation
jarcherNV 18e4d36
Route OmniDreams WebRTC through shared realtime driver
jarcherNV 24c6e07
ci: add OmniDreams demo runtime GPU workflow
jarcherNV 1a91935
ci: shorten OmniDreams demo runtime artifacts
jarcherNV 441e1bb
omnidreams: clean up shared demo runtime layout
jarcherNV 1c12ecf
docs: record validated OmniDreams demo commands
jarcherNV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Session drivers and helpers for demo runtime vertical slices.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from flashdreams.runtime.interfaces import InferenceSession | ||
|
|
||
| from .host import RuntimeHost | ||
| from .outputs import SessionInfo | ||
| from .pipeline import StepPipeline | ||
| from .run_modes import ( | ||
| DriverStatus, | ||
| RunContext, | ||
| RunMode, | ||
| RunResult, | ||
| SessionEdges, | ||
| SessionReservation, | ||
| ) | ||
| from .session_inputs import ModelInputProvider | ||
| from .spec import DemoAdapter, DemoSpec, PreparedScenario | ||
|
|
||
|
|
||
| class DriverInvariantError(RuntimeError): | ||
| """A driver invariant was violated; this is a driver bug, not a run result.""" | ||
|
|
||
|
|
||
| class BatchSessionDriver: | ||
| """Minimal finite-session driver for Phase 2 fake-model coverage.""" | ||
|
|
||
| def run_one_session( | ||
| self, | ||
| *, | ||
| host: RuntimeHost, | ||
| provider: ModelInputProvider, | ||
| session_edges: SessionEdges, | ||
| pipeline: StepPipeline, | ||
| ) -> RunResult: | ||
| session: InferenceSession | None = None | ||
| final_status: DriverStatus = "completed" | ||
| final_reason: str | None = None | ||
| final_error: Exception | None = None | ||
| setup_ok = False | ||
| try: | ||
| try: | ||
| initial_input = host.call(provider.prepare_initial_input) | ||
| session = host.call(host.start_session, initial_input) | ||
| session_info = host.call(_session_info, session) | ||
| session_edges.output_sink.open(session_info) | ||
| setup_ok = True | ||
| except Exception as exc: | ||
| action = session_edges.error_policy.handle_setup_error(exc) | ||
| if action.drop_chunk or action.result_status == "completed": | ||
| raise DriverInvariantError( | ||
| "Setup failures must resolve to failed or skipped." | ||
| ) from exc | ||
| session_edges.metrics.record_error(exc, action) | ||
| final_status = action.result_status | ||
| final_reason = str(exc) | ||
| final_error = exc if action.result_status == "failed" else None | ||
|
|
||
| while setup_ok: | ||
| if session is None: | ||
| raise DriverInvariantError("setup_ok was set without a session.") | ||
| try: | ||
| if session_edges.input_source.is_finished(): | ||
| break | ||
| request = host.call(session.next_step_request) | ||
| if request is None: | ||
| break | ||
| user_window = session_edges.input_source.next_window(request) | ||
| outcome = host.call( | ||
| pipeline.execute_step, | ||
| request=request, | ||
| user_window=user_window, | ||
| provider=provider, | ||
| session=session, | ||
| output=session_edges.output_sink, | ||
| metrics=session_edges.metrics, | ||
| ) | ||
| if outcome.control.reset: | ||
| host.call(session.reset, outcome.control.reset_input) | ||
| if not outcome.control.provider_already_reset: | ||
| host.call(provider.reset, outcome.control.reset_input) | ||
| continue | ||
| if outcome.control.close_session: | ||
| break | ||
| if outcome.output.should_stop: | ||
| break | ||
| except DriverInvariantError: | ||
| raise | ||
| except Exception as exc: | ||
| action = session_edges.error_policy.handle(exc) | ||
| session_edges.metrics.record_error(exc, action) | ||
| if action.drop_chunk: | ||
| continue | ||
| final_status = action.result_status | ||
| final_reason = str(exc) | ||
| final_error = exc if action.result_status == "failed" else None | ||
| break | ||
| except DriverInvariantError: | ||
| raise | ||
| except Exception as exc: | ||
| final_status = "failed" | ||
| final_reason = str(exc) | ||
| final_error = exc | ||
| finally: | ||
| if session is not None: | ||
| host.call(_close_safely, session.close, session_edges) | ||
| host.call(_close_safely, provider.close, session_edges) | ||
|
|
||
| return session_edges.close_result( | ||
| status=final_status, | ||
| reason=final_reason, | ||
| error=final_error, | ||
| ) | ||
|
|
||
|
|
||
| def run_demo_session( | ||
| *, | ||
| context: RunContext, | ||
| spec: DemoSpec, | ||
| scenario: PreparedScenario, | ||
| adapter: DemoAdapter, | ||
| run_mode: RunMode, | ||
| pipeline: StepPipeline, | ||
| reservation: SessionReservation | None = None, | ||
| ) -> RunResult: | ||
| """Run one prepared demo session through a selected run mode.""" | ||
| reservation = reservation or context.admission.try_reserve() | ||
| if reservation is None: | ||
| result = RunResult.rejected(reason="busy") | ||
| context.run_metrics.record_session(result) | ||
| return result | ||
|
|
||
| provider: Any | None = None | ||
| session_edges: SessionEdges | None = None | ||
| driver_started = False | ||
| try: | ||
| create_provider = getattr(adapter, "create_model_input_provider") | ||
| provider = context.host.call(create_provider, spec, scenario) | ||
| run_mode.validate_session( | ||
| spec=spec, | ||
| scenario=scenario, | ||
| adapter=adapter, | ||
| provider=provider, | ||
| ) | ||
| session_edges = run_mode.create_session_edges( | ||
| context=context, | ||
| spec=spec, | ||
| scenario=scenario, | ||
| provider=provider, | ||
| adapter=adapter, | ||
| ) | ||
| driver = run_mode.select_driver() | ||
| if not isinstance(driver, BatchSessionDriver): | ||
| raise TypeError( | ||
| "Phase 2 run_demo_session supports BatchSessionDriver only, " | ||
| f"got {type(driver).__name__}." | ||
| ) | ||
| driver_started = True | ||
| result = driver.run_one_session( | ||
| host=context.host, | ||
|
greptile-apps[bot] marked this conversation as resolved.
Outdated
|
||
| provider=provider, | ||
| session_edges=session_edges, | ||
| pipeline=pipeline, | ||
| ) | ||
| context.run_metrics.record_session(result) | ||
| return result | ||
| except DriverInvariantError: | ||
| raise | ||
| except Exception as exc: | ||
| if provider is not None and not driver_started: | ||
| try: | ||
| context.host.call(provider.close) | ||
| except Exception as close_exc: | ||
| if session_edges is not None: | ||
| session_edges.metrics.record_cleanup_error(close_exc) | ||
| else: | ||
| context.run_metrics.record_cleanup_error(close_exc) | ||
| if session_edges is not None: | ||
| result = session_edges.close_result( | ||
| status="failed", | ||
| reason=str(exc), | ||
| error=exc, | ||
| ) | ||
| else: | ||
| result = RunResult(status="failed", reason=str(exc), error=exc) | ||
| context.run_metrics.record_session(result) | ||
| return result | ||
| finally: | ||
| reservation.release() | ||
|
|
||
|
|
||
| def _session_info(session: InferenceSession) -> SessionInfo: | ||
| session_info = getattr(session, "session_info", None) | ||
| if not callable(session_info): | ||
| return SessionInfo() | ||
| value = session_info() | ||
| if not isinstance(value, SessionInfo): | ||
| raise TypeError( | ||
| "session.session_info() must return SessionInfo, " | ||
| f"got {type(value).__name__}." | ||
| ) | ||
| return value | ||
|
|
||
|
|
||
| def _close_safely(close: Any, session_edges: SessionEdges) -> None: | ||
| try: | ||
| close() | ||
| except Exception as exc: | ||
| session_edges.metrics.record_cleanup_error(exc) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "BatchSessionDriver", | ||
| "DriverInvariantError", | ||
| "run_demo_session", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Minimal runtime host for the Phase 2 demo-session vertical slice.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Callable | ||
| from typing import TypeVar | ||
|
|
||
| from flashdreams.runtime.inputs import InferenceInput | ||
| from flashdreams.runtime.interfaces import InferenceRuntime, InferenceSession | ||
|
|
||
| _T = TypeVar("_T") | ||
|
|
||
|
|
||
| class RuntimeHost: | ||
| """Thin synchronous host around an :class:`InferenceRuntime`. | ||
|
|
||
| Phase 3 moves the thread-affine worker boundary here. Phase 2 keeps the | ||
| dispatch direct so fake-model CPU tests can prove the session-driver shape | ||
| without introducing worker behavior early. | ||
| """ | ||
|
|
||
| def __init__(self, runtime: InferenceRuntime) -> None: | ||
| self._runtime = runtime | ||
| self._healthy = True | ||
|
|
||
| @property | ||
| def runtime(self) -> InferenceRuntime: | ||
| """Return the hosted runtime.""" | ||
| return self._runtime | ||
|
|
||
| @property | ||
| def is_healthy(self) -> bool: | ||
| """Return whether admission should continue accepting sessions.""" | ||
| return self._healthy | ||
|
|
||
| def mark_unhealthy(self) -> None: | ||
| """Latch the host as unhealthy.""" | ||
| self._healthy = False | ||
|
|
||
| def call(self, func: Callable[..., _T], /, *args: object, **kwargs: object) -> _T: | ||
| """Run one model-affine callable synchronously.""" | ||
| return func(*args, **kwargs) | ||
|
|
||
| async def call_async( | ||
| self, | ||
| func: Callable[..., _T], | ||
| /, | ||
| *args: object, | ||
| **kwargs: object, | ||
| ) -> _T: | ||
| """Async-compatible direct dispatch placeholder for Phase 3.""" | ||
| return self.call(func, *args, **kwargs) | ||
|
|
||
| def start_session(self, inputs: InferenceInput) -> InferenceSession: | ||
| """Start one inference session through the hosted runtime.""" | ||
| return self._runtime.start_session(inputs) | ||
|
|
||
| def close(self) -> None: | ||
| """Close the hosted runtime.""" | ||
| self._runtime.close() | ||
|
|
||
|
|
||
| __all__ = ["RuntimeHost"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.