freesolo-flash 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. freesolo_flash-0.2.0/.dockerignore +15 -0
  2. freesolo_flash-0.2.0/.env.example +34 -0
  3. freesolo_flash-0.2.0/.github/workflows/ci.yml +28 -0
  4. freesolo_flash-0.2.0/.github/workflows/main-source-guard.yml +20 -0
  5. freesolo_flash-0.2.0/.github/workflows/publish-image.yml +69 -0
  6. freesolo_flash-0.2.0/.github/workflows/publish.yml +43 -0
  7. freesolo_flash-0.2.0/.github/workflows/worker-image.yml +70 -0
  8. freesolo_flash-0.2.0/.gitignore +26 -0
  9. freesolo_flash-0.2.0/Dockerfile +21 -0
  10. freesolo_flash-0.2.0/Dockerfile.worker +104 -0
  11. freesolo_flash-0.2.0/LICENSE +201 -0
  12. freesolo_flash-0.2.0/PKG-INFO +99 -0
  13. freesolo_flash-0.2.0/README.md +62 -0
  14. freesolo_flash-0.2.0/docker/make_rp_handler.py +53 -0
  15. freesolo_flash-0.2.0/flash/__init__.py +11 -0
  16. freesolo_flash-0.2.0/flash/_fileio.py +35 -0
  17. freesolo_flash-0.2.0/flash/_logging.py +49 -0
  18. freesolo_flash-0.2.0/flash/catalog.py +245 -0
  19. freesolo_flash-0.2.0/flash/cli/__init__.py +1 -0
  20. freesolo_flash-0.2.0/flash/cli/main/__init__.py +220 -0
  21. freesolo_flash-0.2.0/flash/cli/main/__main__.py +6 -0
  22. freesolo_flash-0.2.0/flash/cli/main/commands.py +430 -0
  23. freesolo_flash-0.2.0/flash/cli/main/envpush.py +333 -0
  24. freesolo_flash-0.2.0/flash/client/__init__.py +14 -0
  25. freesolo_flash-0.2.0/flash/client/config.py +46 -0
  26. freesolo_flash-0.2.0/flash/client/http.py +202 -0
  27. freesolo_flash-0.2.0/flash/client/specs.py +23 -0
  28. freesolo_flash-0.2.0/flash/engine/__init__.py +7 -0
  29. freesolo_flash-0.2.0/flash/engine/accounting.py +37 -0
  30. freesolo_flash-0.2.0/flash/engine/chalk_kernels.py +150 -0
  31. freesolo_flash-0.2.0/flash/engine/multiturn_rollout.py +273 -0
  32. freesolo_flash-0.2.0/flash/engine/recipe.py +86 -0
  33. freesolo_flash-0.2.0/flash/engine/vram.py +382 -0
  34. freesolo_flash-0.2.0/flash/engine/worker/__init__.py +1960 -0
  35. freesolo_flash-0.2.0/flash/engine/worker/__main__.py +4 -0
  36. freesolo_flash-0.2.0/flash/engine/worker/lora.py +137 -0
  37. freesolo_flash-0.2.0/flash/engine/worker/perf.py +467 -0
  38. freesolo_flash-0.2.0/flash/envs/__init__.py +10 -0
  39. freesolo_flash-0.2.0/flash/envs/adapter/__init__.py +384 -0
  40. freesolo_flash-0.2.0/flash/envs/adapter/rubric.py +222 -0
  41. freesolo_flash-0.2.0/flash/envs/base.py +49 -0
  42. freesolo_flash-0.2.0/flash/envs/registry.py +76 -0
  43. freesolo_flash-0.2.0/flash/mcp/__init__.py +1 -0
  44. freesolo_flash-0.2.0/flash/mcp/server.py +83 -0
  45. freesolo_flash-0.2.0/flash/providers/__init__.py +59 -0
  46. freesolo_flash-0.2.0/flash/providers/_auth.py +24 -0
  47. freesolo_flash-0.2.0/flash/providers/_http.py +100 -0
  48. freesolo_flash-0.2.0/flash/providers/_poll.py +87 -0
  49. freesolo_flash-0.2.0/flash/providers/allocator.py +173 -0
  50. freesolo_flash-0.2.0/flash/providers/base.py +496 -0
  51. freesolo_flash-0.2.0/flash/providers/preflight.py +80 -0
  52. freesolo_flash-0.2.0/flash/providers/runpod/__init__.py +108 -0
  53. freesolo_flash-0.2.0/flash/providers/runpod/api.py +109 -0
  54. freesolo_flash-0.2.0/flash/providers/runpod/auth.py +24 -0
  55. freesolo_flash-0.2.0/flash/providers/runpod/gpus.py +46 -0
  56. freesolo_flash-0.2.0/flash/providers/runpod/jobs.py +519 -0
  57. freesolo_flash-0.2.0/flash/providers/runpod/preflight.py +30 -0
  58. freesolo_flash-0.2.0/flash/providers/runpod/pricing.py +108 -0
  59. freesolo_flash-0.2.0/flash/providers/runpod/train/__init__.py +141 -0
  60. freesolo_flash-0.2.0/flash/providers/runpod/train/deps.py +371 -0
  61. freesolo_flash-0.2.0/flash/providers/runpod/train/endpoints.py +501 -0
  62. freesolo_flash-0.2.0/flash/providers/vast/__init__.py +120 -0
  63. freesolo_flash-0.2.0/flash/providers/vast/_bootstrap.py +288 -0
  64. freesolo_flash-0.2.0/flash/providers/vast/api.py +215 -0
  65. freesolo_flash-0.2.0/flash/providers/vast/auth.py +19 -0
  66. freesolo_flash-0.2.0/flash/providers/vast/gpus.py +21 -0
  67. freesolo_flash-0.2.0/flash/providers/vast/jobs/__init__.py +555 -0
  68. freesolo_flash-0.2.0/flash/providers/vast/jobs/builders.py +205 -0
  69. freesolo_flash-0.2.0/flash/providers/vast/preflight.py +27 -0
  70. freesolo_flash-0.2.0/flash/providers/vast/pricing.py +51 -0
  71. freesolo_flash-0.2.0/flash/providers/vast/train.py +27 -0
  72. freesolo_flash-0.2.0/flash/py.typed +0 -0
  73. freesolo_flash-0.2.0/flash/runner/__init__.py +290 -0
  74. freesolo_flash-0.2.0/flash/runner/deploy.py +349 -0
  75. freesolo_flash-0.2.0/flash/runner/lifecycle.py +437 -0
  76. freesolo_flash-0.2.0/flash/schema/__init__.py +285 -0
  77. freesolo_flash-0.2.0/flash/schema/fields.py +210 -0
  78. freesolo_flash-0.2.0/flash/serve/__init__.py +1 -0
  79. freesolo_flash-0.2.0/flash/serve/deploy.py +195 -0
  80. freesolo_flash-0.2.0/flash/server/__init__.py +1 -0
  81. freesolo_flash-0.2.0/flash/server/__main__.py +20 -0
  82. freesolo_flash-0.2.0/flash/server/app.py +424 -0
  83. freesolo_flash-0.2.0/flash/server/auth.py +132 -0
  84. freesolo_flash-0.2.0/flash/server/db.py +152 -0
  85. freesolo_flash-0.2.0/flash/server/envs.py +449 -0
  86. freesolo_flash-0.2.0/flash/spec.py +291 -0
  87. freesolo_flash-0.2.0/pyproject.toml +141 -0
  88. freesolo_flash-0.2.0/tests/__init__.py +2 -0
  89. freesolo_flash-0.2.0/tests/_helpers/__init__.py +1 -0
  90. freesolo_flash-0.2.0/tests/_helpers/runner.py +25 -0
  91. freesolo_flash-0.2.0/tests/_helpers/specs.py +18 -0
  92. freesolo_flash-0.2.0/tests/_helpers/vast.py +38 -0
  93. freesolo_flash-0.2.0/tests/conftest.py +37 -0
  94. freesolo_flash-0.2.0/tests/fixtures/math_eval.jsonl +3 -0
  95. freesolo_flash-0.2.0/tests/fixtures/math_train.jsonl +2 -0
  96. freesolo_flash-0.2.0/tests/live/__init__.py +0 -0
  97. freesolo_flash-0.2.0/tests/live/conftest.py +22 -0
  98. freesolo_flash-0.2.0/tests/live/test_runpod_live.py +47 -0
  99. freesolo_flash-0.2.0/tests/live/test_vast_live.py +56 -0
  100. freesolo_flash-0.2.0/tests/test_agent_slm_cli_contract.py +201 -0
  101. freesolo_flash-0.2.0/tests/test_algorithms.py +72 -0
  102. freesolo_flash-0.2.0/tests/test_allocator.py +163 -0
  103. freesolo_flash-0.2.0/tests/test_backend_jobspec_contract.py +159 -0
  104. freesolo_flash-0.2.0/tests/test_cancel_remote.py +304 -0
  105. freesolo_flash-0.2.0/tests/test_catalog_consistency.py +57 -0
  106. freesolo_flash-0.2.0/tests/test_chalk_kernels.py +170 -0
  107. freesolo_flash-0.2.0/tests/test_cli_commands.py +200 -0
  108. freesolo_flash-0.2.0/tests/test_cli_errors.py +105 -0
  109. freesolo_flash-0.2.0/tests/test_cli_managed.py +127 -0
  110. freesolo_flash-0.2.0/tests/test_client.py +85 -0
  111. freesolo_flash-0.2.0/tests/test_client_server_integration.py +263 -0
  112. freesolo_flash-0.2.0/tests/test_config_overrides.py +61 -0
  113. freesolo_flash-0.2.0/tests/test_disk_gb.py +95 -0
  114. freesolo_flash-0.2.0/tests/test_endpoint_name.py +45 -0
  115. freesolo_flash-0.2.0/tests/test_env_install.py +74 -0
  116. freesolo_flash-0.2.0/tests/test_env_publish.py +663 -0
  117. freesolo_flash-0.2.0/tests/test_env_push.py +195 -0
  118. freesolo_flash-0.2.0/tests/test_envs_coverage.py +53 -0
  119. freesolo_flash-0.2.0/tests/test_flash_mvp.py +137 -0
  120. freesolo_flash-0.2.0/tests/test_flash_worker.py +400 -0
  121. freesolo_flash-0.2.0/tests/test_gpus.py +149 -0
  122. freesolo_flash-0.2.0/tests/test_grpo_params.py +389 -0
  123. freesolo_flash-0.2.0/tests/test_jobs.py +724 -0
  124. freesolo_flash-0.2.0/tests/test_logging.py +51 -0
  125. freesolo_flash-0.2.0/tests/test_login_perms.py +57 -0
  126. freesolo_flash-0.2.0/tests/test_metrics_schema_agent_contract.py +170 -0
  127. freesolo_flash-0.2.0/tests/test_multiturn_rollout.py +197 -0
  128. freesolo_flash-0.2.0/tests/test_open_model_policy.py +102 -0
  129. freesolo_flash-0.2.0/tests/test_orchestrator_flash.py +109 -0
  130. freesolo_flash-0.2.0/tests/test_preflight.py +124 -0
  131. freesolo_flash-0.2.0/tests/test_pricing_cache.py +65 -0
  132. freesolo_flash-0.2.0/tests/test_provider_routing.py +327 -0
  133. freesolo_flash-0.2.0/tests/test_providers_symmetry.py +286 -0
  134. freesolo_flash-0.2.0/tests/test_runmgmt.py +89 -0
  135. freesolo_flash-0.2.0/tests/test_runpod_api_delete.py +90 -0
  136. freesolo_flash-0.2.0/tests/test_serve.py +202 -0
  137. freesolo_flash-0.2.0/tests/test_serve_modes.py +107 -0
  138. freesolo_flash-0.2.0/tests/test_server_api.py +700 -0
  139. freesolo_flash-0.2.0/tests/test_spec_and_validation.py +415 -0
  140. freesolo_flash-0.2.0/tests/test_thinking_config.py +118 -0
  141. freesolo_flash-0.2.0/tests/test_vast_api.py +177 -0
  142. freesolo_flash-0.2.0/tests/test_vast_offers.py +101 -0
  143. freesolo_flash-0.2.0/tests/test_vast_runner.py +684 -0
  144. freesolo_flash-0.2.0/tests/test_verifiers.py +420 -0
  145. freesolo_flash-0.2.0/tests/test_version.py +34 -0
  146. freesolo_flash-0.2.0/tests/test_wandb_naming.py +213 -0
  147. freesolo_flash-0.2.0/tests/test_worker_dryrun.py +199 -0
  148. freesolo_flash-0.2.0/tests/test_worker_hardexit.py +77 -0
  149. freesolo_flash-0.2.0/tests/test_worker_stack.py +381 -0
  150. freesolo_flash-0.2.0/tests/test_worker_thinking.py +142 -0
  151. freesolo_flash-0.2.0/uv.lock +4894 -0
@@ -0,0 +1,15 @@
1
+ .venv/
2
+ venv/
3
+ __pycache__/
4
+ *.pyc
5
+ .ruff_cache/
6
+ .cache/
7
+ .flash/
8
+ results/
9
+ hf_cache/
10
+ uv-cache/
11
+ dist/
12
+ build/
13
+ *.egg-info/
14
+ .env
15
+ .flash/
@@ -0,0 +1,34 @@
1
+ # Flash control plane (operator-side). Copy to .env and fill in.
2
+ # Provider credentials live ONLY here — clients never see them and authenticate
3
+ # with their freesolo API key (`flash login`).
4
+
5
+ # GPU substrate. RunPod is the default; Vast is opt-in (only required when set).
6
+ RUNPOD_API_KEY=
7
+ VAST_API_KEY=
8
+ # HuggingFace token with write access to each run's [train] hf_repo (code upload +
9
+ # streamed checkpoints/adapters land in that per-run dataset repo). The artifact repo
10
+ # is per-run (set in the run TOML's [train] hf_repo), not an operator-wide env var.
11
+ HF_TOKEN=
12
+ # Prime Intellect API key for FreeSolo's MANAGED Prime account. Used to (1) `prime env install`
13
+ # the run's Hub environment on the worker, and (2) publish user-uploaded envs (`flash env push` ->
14
+ # POST /v1/envs) under this one account — so users never need their own Prime account. The `prime`
15
+ # CLI must be installed on the control plane (it ships in the `server` extra).
16
+ PRIME_API_KEY=
17
+
18
+ # --- FreeSolo auth (hosted deployment) ---
19
+ # User auth is freesolo API keys only. An unknown bearer token is verified against
20
+ # {FREESOLO_BASE_URL}/api/auth/verify and resolved to a per-user identity.
21
+ # The shared freesolo internal key (same value the platform/SDK already hold) maps
22
+ # to a single service identity without a network call. The same key authenticates
23
+ # flash's adapter registration calls to the freesolo serving app (below).
24
+ FREESOLO_INTERNAL_KEY=
25
+ # Where to verify user keys. In compose this is the backend on the internal network;
26
+ # defaults to https://api.freesolo.co when unset.
27
+ FREESOLO_BASE_URL=http://backend:8000
28
+
29
+ # --- FreeSolo serving (adapter deploy/chat) ---
30
+ # Adapter serving is delegated to the freesolo platform's multi-LoRA serving app (a
31
+ # Modal app that serves every adapter on one GPU per base model, scaling to zero when
32
+ # idle). `flash deploy`/`undeploy`/`chat` register/deregister/chat against it. Defaults
33
+ # to the hosted Modal URL when unset.
34
+ FREESOLO_SERVING_URL=https://clado-ai--freesolo-lora-serving.modal.run
@@ -0,0 +1,28 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ pull_request:
7
+ branches: [main, dev]
8
+
9
+ jobs:
10
+ test:
11
+ name: lint + offline tests
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v6
15
+
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v6
18
+ with:
19
+ python-version: "3.11"
20
+
21
+ - name: Sync (server extra + dev)
22
+ run: uv sync --extra server --dev
23
+
24
+ - name: Ruff
25
+ run: uv run ruff check .
26
+
27
+ - name: Tests (CPU, offline)
28
+ run: uv run pytest -q
@@ -0,0 +1,20 @@
1
+ name: Main source guard
2
+ on:
3
+ pull_request:
4
+ branches: [main]
5
+ permissions:
6
+ contents: read
7
+ jobs:
8
+ source-is-dev:
9
+ name: Source branch is dev
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Require PRs into main to originate from dev
13
+ env:
14
+ HEAD_REF: ${{ github.head_ref }}
15
+ run: |
16
+ if [ "$HEAD_REF" != "dev" ]; then
17
+ echo "::error::PRs into main must come from 'dev' (got '$HEAD_REF'). Merge into dev, then promote dev -> main."
18
+ exit 1
19
+ fi
20
+ echo "Source branch '$HEAD_REF' is allowed."
@@ -0,0 +1,69 @@
1
+ name: Publish flash image
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - dev
8
+ paths:
9
+ - "flash/**"
10
+ - "Dockerfile"
11
+ - "pyproject.toml"
12
+ - ".github/workflows/publish-image.yml"
13
+ workflow_dispatch:
14
+
15
+ concurrency:
16
+ group: publish-flash-image-${{ github.ref }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ publish-flash-image:
21
+ name: Build and push flash control-plane image
22
+ runs-on: ubuntu-latest
23
+ permissions:
24
+ contents: read
25
+ packages: write
26
+ env:
27
+ IMAGE: ghcr.io/freesolo-co/freesolo-flash
28
+
29
+ steps:
30
+ - uses: actions/checkout@v6
31
+
32
+ - name: Set up Docker Buildx
33
+ uses: docker/setup-buildx-action@v3
34
+
35
+ - name: Log in to GHCR
36
+ uses: docker/login-action@v3
37
+ with:
38
+ registry: ghcr.io
39
+ username: ${{ github.actor }}
40
+ password: ${{ secrets.GITHUB_TOKEN }}
41
+
42
+ - name: Compute tags
43
+ id: tags
44
+ run: |
45
+ # main publishes :main + :latest; any other branch (dev) publishes
46
+ # :<branch>. every build also gets an immutable :sha-<short> tag.
47
+ short_sha="$(git rev-parse --short HEAD)"
48
+ branch="${GITHUB_REF_NAME}"
49
+ {
50
+ echo "tags<<EOF"
51
+ if [ "$branch" = "main" ]; then
52
+ echo "${IMAGE}:main"
53
+ echo "${IMAGE}:latest"
54
+ else
55
+ echo "${IMAGE}:${branch}"
56
+ fi
57
+ echo "${IMAGE}:sha-${short_sha}"
58
+ echo "EOF"
59
+ } >> "$GITHUB_OUTPUT"
60
+
61
+ - name: Build and push
62
+ uses: docker/build-push-action@v6
63
+ with:
64
+ context: .
65
+ file: ./Dockerfile
66
+ push: true
67
+ tags: ${{ steps.tags.outputs.tags }}
68
+ cache-from: type=gha
69
+ cache-to: type=gha,mode=min
@@ -0,0 +1,43 @@
1
+ name: Publish flash package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "flash-v*"
7
+ workflow_dispatch:
8
+
9
+ concurrency:
10
+ group: publish-flash-${{ github.ref }}
11
+ cancel-in-progress: false
12
+
13
+ jobs:
14
+ publish-pypi:
15
+ name: Publish flash PyPI package
16
+ runs-on: ubuntu-latest
17
+ permissions:
18
+ contents: read
19
+ env:
20
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
21
+
22
+ steps:
23
+ - uses: actions/checkout@v6
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v6
29
+ with:
30
+ python-version: "3.11"
31
+
32
+ - name: Build distributions
33
+ run: |
34
+ rm -rf dist
35
+ uv build
36
+
37
+ - name: Publish to PyPI
38
+ run: |
39
+ if [ -z "$UV_PUBLISH_TOKEN" ]; then
40
+ echo "::error::PYPI_API_TOKEN is not configured; refusing to skip publish."
41
+ exit 1
42
+ fi
43
+ uv publish --token "$UV_PUBLISH_TOKEN"
@@ -0,0 +1,70 @@
1
+ name: flash worker image
2
+
3
+ # Builds the prebuilt flash worker image (full training stack + flash-attn baked in) and
4
+ # pushes it to GHCR, so Vast/RunPod cold-start skips the per-host dep install (the dominant
5
+ # cold-start cost). Training and serving both default to the pinned WORKER_IMAGE constant
6
+ # (flash/providers/runpod/train.py) — bump that to the new tag. FLASH_WORKER_IMAGE is an
7
+ # operator env override honored by BOTH training (providers/runpod/{jobs,train}.py) and serving
8
+ # (flash/serve/deploy.py).
9
+ #
10
+ # Manual trigger (the build is heavy: vllm + the full training stack; flash-attn installs from
11
+ # the prebuilt FLASH_ATTN_SPEC wheel, with a bounded source build only as fallback).
12
+
13
+ on:
14
+ workflow_dispatch:
15
+ inputs:
16
+ tag:
17
+ description: image tag
18
+ default: cu128
19
+ required: false
20
+ push:
21
+ branches: [main]
22
+ paths:
23
+ - Dockerfile.worker
24
+ - .github/workflows/worker-image.yml
25
+
26
+ permissions:
27
+ contents: read
28
+ packages: write
29
+
30
+ jobs:
31
+ build:
32
+ runs-on: ubuntu-24.04-8core
33
+ steps:
34
+ - uses: actions/checkout@v6
35
+
36
+ - name: Free disk space
37
+ run: |
38
+ sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/.ghcup \
39
+ /usr/local/lib/android /opt/hostedtoolcache /usr/share/swift \
40
+ /usr/local/share/boost /usr/local/lib/node_modules \
41
+ /usr/local/share/powershell /usr/share/miniconda || true
42
+ sudo apt-get clean || true
43
+ sudo docker image prune -af || true
44
+ df -h /
45
+
46
+ - uses: docker/setup-buildx-action@v3
47
+
48
+ - name: Log in to GHCR
49
+ uses: docker/login-action@v3
50
+ with:
51
+ registry: ghcr.io
52
+ username: ${{ github.actor }}
53
+ password: ${{ secrets.GITHUB_TOKEN }}
54
+
55
+ - name: Build + push worker image
56
+ uses: docker/build-push-action@v6
57
+ with:
58
+ context: .
59
+ file: Dockerfile.worker
60
+ push: true
61
+ # Pin the freesolo-co namespace: both RunPod and Vast pull the hardcoded
62
+ # WORKER_IMAGE = ghcr.io/freesolo-co/flash-worker:cu128 (flash/providers/runpod/train.py),
63
+ # so a fork run must not push to its own owner namespace and leave the real image stale.
64
+ tags: ghcr.io/freesolo-co/flash-worker:${{ github.event.inputs.tag || 'cu128' }}
65
+ provenance: false
66
+ # Install a PREBUILT flash-attn wheel instead of compiling from source (a multi-arch
67
+ # source compile is huge and OOM-kills the runner). The wheel matches the base exactly
68
+ # (cu128 / torch2.10 / cp312).
69
+ build-args: |
70
+ FLASH_ATTN_SPEC=https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.9.0/flash_attn-2.8.3%2Bcu128torch2.10-cp312-cp312-linux_x86_64.whl
@@ -0,0 +1,26 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ venv/
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .ruff_cache/
9
+ .cache/
10
+ artifacts_local/
11
+ hf_cache/
12
+ *.log
13
+
14
+ # Run artifacts: adapters (large binaries) live on the HF dataset repo, not in git
15
+ results/
16
+ # ...but the benchmark's committed results ARE the deliverable. Un-ignore that subtree
17
+ # HERE: git won't descend into an ignored dir to read a nested benchmark/results/.gitignore,
18
+ # so the exception must live at the root. benchmark/results/.gitignore then whitelists the
19
+ # specific json/md to track.
20
+ !benchmark/results/
21
+ .flash/
22
+ uv-cache/
23
+ .flash/
24
+
25
+ # Operator credentials (use .env.example as the template)
26
+ .env
@@ -0,0 +1,21 @@
1
+ # Flash control plane (operator-side).
2
+ #
3
+ # docker build -t flash-server .
4
+ # docker run -p 8080:8080 \
5
+ # -e RUNPOD_API_KEY=... -e HF_TOKEN=... \
6
+ # -v flash-state:/root/.flash flash-server
7
+ #
8
+ # All persistent state (key DB, run records, results) lives under ~/.flash (fixed paths,
9
+ # = /root/.flash for the default root user) — mount a volume there. Run exactly ONE
10
+ # container instance per state volume (state is local files + SQLite; no horizontal scaling).
11
+
12
+ FROM python:3.12-slim
13
+
14
+ WORKDIR /app
15
+ COPY . .
16
+ RUN pip install --no-cache-dir ".[server]"
17
+
18
+ VOLUME /root/.flash
19
+ EXPOSE 8080
20
+
21
+ CMD ["flash-server", "--host", "0.0.0.0", "--port", "8080"]
@@ -0,0 +1,104 @@
1
+ # Flash prebuilt WORKER image — the full training stack baked in so Vast/RunPod cold-start
2
+ # skips the per-host dep install (the dominant cold-start cost; measured 7-86s on fresh Vast).
3
+ # The worker still fetches the flash `code/**` from HF at runtime, so only DEPS live here.
4
+ #
5
+ # This image is the default worker image — Vast always uses it; on RunPod, FLASH_WORKER_IMAGE
6
+ # overrides it and the Flash live-endpoint path boot-installs deps instead. It is referenced by name
7
+ # in providers/runpod/train/deps.py:WORKER_IMAGE. It MUST be published to GHCR and the package set PUBLIC
8
+ # (no registry login is configured) — otherwise Vast/RunPod can't pull it. Normally built by
9
+ # .github/workflows/worker-image.yml (manual dispatch); to build/push by hand:
10
+ #
11
+ # docker build -f Dockerfile.worker -t ghcr.io/freesolo-co/flash-worker:cu128 .
12
+ # docker push ghcr.io/freesolo-co/flash-worker:cu128
13
+ # # then make the GHCR package public (org packages settings) once.
14
+ #
15
+ # Base is torch 2.10 / cu12.8 / cudnn9 (-devel = has nvcc for any source builds); it ships the
16
+ # CUDA 12.8 runtime libs the PyPI wheels link against. The pinned stack mirrors
17
+ # providers/runpod/train/deps.py:WORKER_DEPS.
18
+ FROM pytorch/pytorch:2.10.0-cuda12.8-cudnn9-devel
19
+
20
+ ENV DEBIAN_FRONTEND=noninteractive \
21
+ HF_HUB_ENABLE_HF_TRANSFER=1 \
22
+ PIP_BREAK_SYSTEM_PACKAGES=1 \
23
+ PYTHONUNBUFFERED=1
24
+
25
+ # build-essential for Triton/Inductor (Liger) + any source builds; git for pip VCS installs.
26
+ RUN apt-get update && apt-get install -y --no-install-recommends build-essential git curl \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ # The pinned worker stack (torch already in the base image, version-matched so pip skips it).
30
+ RUN pip install --no-cache-dir \
31
+ "transformers>=5.6,<5.13" \
32
+ "trl>=1.6,<1.7" \
33
+ "peft>=0.19" \
34
+ "vllm==0.19.1" \
35
+ "bitsandbytes>=0.49" \
36
+ "datasets>=4.7,<6" \
37
+ "huggingface_hub>=0.25" \
38
+ "accelerate>=1.4" \
39
+ "wandb>=0.17" \
40
+ "liger-kernel>=0.5" \
41
+ "flash-linear-attention==0.5.0" \
42
+ "hf_transfer" \
43
+ "verifiers>=0.1.10" \
44
+ "prime" \
45
+ "runpod"
46
+ # Gated-DeltaNet (Qwen3.5/3.6) runs on flash-linear-attention's Triton kernels, which are correct
47
+ # on consumer cards (Ampere/Ada/Blackwell). On Hopper (sm90) fla's GDN chunk_bwd is miscomputed
48
+ # (fla #640) and its cumsum kernels hit a num_warps=8 LinearLayout assertion (fla #734); both fixes
49
+ # are unreleased (post-0.5.0 git main) and #640's backward correctness is unconfirmed, so on Hopper
50
+ # the worker DROPS fla (engine.worker._drop_fla_on_hopper) and transformers uses its native
51
+ # pure-PyTorch delta rule — slower but correct.
52
+
53
+ # FlashAttention: PREFER a prebuilt wheel. There is no OFFICIAL Dao-AILab wheel for torch 2.10 yet,
54
+ # but community CI publishes matching wheels (cu128/torch2.10/cp312); CI passes one as FLASH_ATTN_SPEC
55
+ # (see .github/workflows/worker-image.yml). Installing a wheel takes seconds and gives full arch
56
+ # coverage. Compiling FA2 from source instead is enormous (tens of GB RAM, ~1h for 5 arches) and
57
+ # OOM-killed/starved every CI runner we tried — so the source path is only a LOCAL fallback.
58
+ # FLASH_ATTN_SPEC is a pip spec: a wheel URL (preferred), a pinned "flash-attn==X", or the default
59
+ # unpinned "flash-attn" (source build). Best-effort either way: on failure the image still works via
60
+ # the SDPA fallback, so the layer never blocks the cold-start win.
61
+ ARG FLASH_ATTN_SPEC=flash-attn
62
+ # Source-build fallback only (ignored when FLASH_ATTN_SPEC is a wheel): bound the compile so it
63
+ # doesn't OOM. TORCH_CUDA_ARCH_LIST restricts to the catalog's arches — Ampere (8.0 A100 / 8.6
64
+ # 3090/A40), Ada (8.9 4090), Hopper (9.0 H100), Blackwell (12.0 RTX 5090; sm120); MAX_JOBS bounds
65
+ # peak compile memory. (A from-source build still needs a big-RAM host; the wheel avoids all of it.)
66
+ RUN TORCH_CUDA_ARCH_LIST="8.0 8.6 8.9 9.0 12.0" MAX_JOBS=4 \
67
+ pip install --no-cache-dir "${FLASH_ATTN_SPEC}" --no-build-isolation \
68
+ && echo "flash-attn: installed (${FLASH_ATTN_SPEC})" || echo "flash-attn: build failed, SDPA fallback"
69
+
70
+ # Sanity: the worker imports must succeed (catches a broken stack at build time, not run time).
71
+ # Import EVERY package the worker runtime uses (derived from a full AST scan of the engine/envs/
72
+ # bootstrap code + the WORKER_DEPS list above): the core stack, the optimizer/accelerator libs
73
+ # (liger, flash-linear-attention=fla, flash_attn, bitsandbytes, triton), and the HF/env libs. A
74
+ # missing or ABI-broken package fails the build HERE instead of silently shipping (the FA wheel in
75
+ # particular can install yet fail to import against this torch). cuDNN comes from the base image.
76
+ # `prime` is a CLI dist (no importable top-level module) and the worker never imports it, so we
77
+ # verify its PRESENCE via metadata rather than importing it. Everything else the worker imports at
78
+ # runtime is imported strictly here.
79
+ # flash_attn is BEST-EFFORT (the install above tolerates a build failure -> SDPA fallback), so it
80
+ # is imported optionally here: a missing FA must NOT abort the build, or the SDPA-fallback image
81
+ # could never be produced. The rest of the stack is mandatory.
82
+ RUN python -c "import importlib.metadata as M; \
83
+ import torch, transformers, trl, peft, vllm, datasets, huggingface_hub, accelerate, wandb, \
84
+ liger_kernel, fla, bitsandbytes, hf_transfer, triton, verifiers, runpod; \
85
+ import importlib; \
86
+ fa_ok = False; \
87
+ exec('try:\n import flash_attn\n fa_ok = True\nexcept Exception:\n fa_ok = False'); \
88
+ cudnn = torch.backends.cudnn.version(); assert cudnn, 'cuDNN not compiled into torch'; \
89
+ ver = lambda n: M.version(n); \
90
+ print('worker stack OK | torch', torch.__version__, '| cudnn', cudnn, '| triton', triton.__version__, '| flash_attn', 'present' if fa_ok else 'ABSENT (SDPA fallback)'); \
91
+ [print(' ', d, ver(d)) for d in ['transformers','trl','peft','vllm','datasets','huggingface-hub', \
92
+ 'accelerate','wandb','liger-kernel','flash-linear-attention','bitsandbytes', \
93
+ 'hf-transfer','verifiers','prime','runpod']]"
94
+
95
+ # RunPod Serverless worker entrypoint (Pattern D — Flash custom image). Generate /rp_handler.py
96
+ # from the real _train_body source in providers/runpod/train/endpoints.py (single source of truth;
97
+ # _train_body is self-contained — every name is imported inside its body) and run it as the CMD so the
98
+ # image is a self-contained RunPod Serverless worker. On Vast the image is launched in args-mode
99
+ # (`bash -c <onstart>`), which OVERRIDES this CMD — so ONE image serves both providers (Vast bash
100
+ # bootstrap vs RunPod serverless handler reading job["input"]). Build context is the repo root.
101
+ COPY flash/providers/runpod/train/endpoints.py docker/make_rp_handler.py /tmp/rpgen/
102
+ RUN python /tmp/rpgen/make_rp_handler.py /tmp/rpgen/endpoints.py /rp_handler.py \
103
+ && python -c "import ast; ast.parse(open('/rp_handler.py').read()); print('rp_handler OK')"
104
+ CMD ["python", "-u", "/rp_handler.py"]
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Freesolo
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.