Skip to content

feat(gpu-backend): unified base64 contract + parameterized deployer for named instances#38

Merged
Stanley-blik merged 4 commits into
mainfrom
feat/unified-gpu-backend-deployer
Jun 30, 2026
Merged

feat(gpu-backend): unified base64 contract + parameterized deployer for named instances#38
Stanley-blik merged 4 commits into
mainfrom
feat/unified-gpu-backend-deployer

Conversation

@Stanley-blik

Copy link
Copy Markdown
Contributor

Why

BYOC ("bring your own compute") only works if the open-source GPU backend is
actually deployed into the user's account — a token/API key alone can't
generate. And the backend contract was inconsistent across three places, so real
generation would break. This makes the backend deployable as named instances
and unifies the contract end-to-end.

What

1. One backend contract (base64, path-based)

  • modal_server.py now serves a single FastAPI ASGI app (POST /generate/t2v|i2v|flf2v, GET /health) returning base64 — instead of four per-label subdomain endpoints. One base URL, path routing, matching the self-hosted server.py and the flow.Generator consumer.
  • server.py returns video_b64/last_frame_b64 (dropped the unserved /files URLs).
  • Generator._fetch_asset accepts base64 or URL (relative URLs resolve against the backend base) — previously it only handled URLs, so generation against the Modal backend (which returns base64) would KeyError.

2. Parameterized for named instances

  • modal_server.py reads FLOW_GPU_APP_NAME / FLOW_GPU_TYPE / model ids / scaledown from env, so several named instances can be deployed into one account (weights volume is namespaced per instance).

3. A real deployer + CLI

  • flow/deploy/: a Deployer interface + ModalDeployer (validates the modal CLI, passes the spec through as env, runs modal deploy, reports the *.modal.run base URL) and honest AWS/GCP scaffolds (manual_required with concrete steps — never fake success).
  • flow deploy <provider> --name … --gpu …, with defaults from a new [deploy] config section (CLI overrides config).

4. Docs

  • README "Deploy the GPU Backend" section; config.example.toml [deploy] section.

Tests

  • test_engine.py: _fetch_asset base64 / absolute-url / relative-url / missing.
  • test_deploy.py: provider registration, missing-CLI honest failure, AWS/GCP honest scaffolds, backend module is packaged/locatable.
  • Full suite: 37 passed. ruff check clean on changed files.

GPU execution itself is unchanged and still requires a funded GPU account; this PR is verified to the GPU boundary (contract, deployer wiring, CLI).

The Modal GPU backend returns inline base64 (video_b64/last_frame_b64) while a
file-serving backend returns URLs — and Generator previously only handled URLs,
so real generation against the Modal backend would KeyError. Add _fetch_asset
that decodes base64 or downloads a URL (resolving relative URLs against the
backend base), unifying the consumer contract. Tests cover both paths.
modal_server.py: serve a single FastAPI ASGI app (POST /generate/t2v|i2v|flf2v,
GET /health) returning base64 instead of four per-label subdomain endpoints, so
the base URL + path contract matches the flow.Generator consumer and the
self-hosted server.py. Parameterize APP_NAME/GPU_TYPE/models/scaledown via env
so multiple NAMED instances can be deployed into one account.

server.py: return video_b64/last_frame_b64 (drop the unserved /files URLs) so
self-hosted == Modal == what Generator consumes.
Adds flow/deploy: a Deployer interface + ModalDeployer (real — validates the
modal CLI, passes the spec through as env, runs modal deploy, reports the
*.modal.run base URL) and honest AWS/GCP scaffolds (manual_required with concrete
steps, never fake success). New [deploy] config section supplies defaults; the
"flow deploy PROVIDER --name ... --gpu ..." CLI overrides them, so users can
stand up several NAMED instances. Tests cover registration, missing-CLI failure,
and the honest AWS/GCP scaffolds.
README: add a 'Deploy the GPU Backend' section explaining that a token isn't
enough — the open-source backend must be deployed (flow deploy modal) to yield
the endpoint URL jobs route to; note named instances + self-hosted path.
config.example.toml: document the [deploy] section + clarify gpu_backend.url is
the deployed base URL.
@Stanley-blik Stanley-blik merged commit 1dd0b9d into main Jun 30, 2026
1 check passed
@Stanley-blik Stanley-blik deleted the feat/unified-gpu-backend-deployer branch June 30, 2026 10:17
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.

1 participant