Skip to content

Decision probes: Core ML go/no-go (measured: NO-GO on M4 Max) and idle-billing - #16

Open
evnsnclr wants to merge 1 commit into
mainfrom
codex/v1-probes
Open

evnsnclr wants to merge 1 commit into
mainfrom
codex/v1-probes

Conversation

@evnsnclr

Copy link
Copy Markdown
Owner

Adds the two decision-settling probes from the v1 gate list — and closes one
gate outright, because the benchmark already ran on the target machine.

Core ML go/no-go probe (benchmarks/coreml-probe/)

One command (./run.sh) that downloads the prebuilt, img2img-capable
keijiro-tk/coreml-sd-turbo UNet (~1.7 GB, cached), times the forward pass on
each compute unit against verified input schema, and prints a verdict against
the pre-registered 125 ms rule.

Measured on the M4 Max (48 GB, macOS 15.6): 131.6 ms median on CPU_AND_GPU,
178.6 ms on ALL → NO-GO.
The local inference tier stays out of v1. The
README records the nuance for later: the conversion is batch-2 (~66 ms/frame
of raw compute), so a batch-1 SDXS-512 conversion is the sensible v1.1
experiment, not a lost cause.

Idle-billing probe (benchmarks/idle-billing-probe/)

Settles the last unverified cost claim: does an idle-but-connected realtime
socket bill anything? Mints a token exactly the way app.py does, holds the
socket idle for N minutes sending nothing, then queries the usage API (with a
dashboard fallback for non-admin keys). Owner-run only — it uses the local
FAL_KEY; expected cost $0. Not executed in this PR; ready whenever.

Review hardening

A code-review pass cross-checked the WS URL against the vendored
@fal-ai/client and found 7 issues, all fixed here: the URL no longer
duplicates /realtime (mirrors fal's own dedup guard), connect/handshake
failures are caught with type-only messages so the JWT-bearing URL can never
reach a traceback, download/metadata/usage-parse failures exit with guidance
instead of stack traces, usage_params rejects naive datetimes, and the
Neural Engine path warms up 3× longer.

Test plan

  • pytest -q — 20 passed (6 new: schema parsing, verdict boundaries,
    env-parser injection inertness, URL dedup, UTC guard)
  • Full suite passes in an env with none of coremltools / websockets /
    huggingface_hub installed — CI never needs the heavy deps
  • Core ML probe executed end-to-end on the target machine (result above)
  • Idle-billing probe: owner-run with the real key (~10 min, ~$0)

🤖 Generated with Claude Code

…M4 Max verdict

benchmarks/coreml-probe: one-command benchmark of the prebuilt
keijiro-tk/coreml-sd-turbo UNet per compute unit, with the pre-registered
125 ms decision rule. Measured on the target machine (M4 Max, macOS 15.6):
131.6 ms median on CPU_AND_GPU, 178.6 ms on ALL — NO-GO, so the local
inference tier stays out of v1 (batch-2 nuance and the SDXS-512 v1.1 path
recorded in the README).

benchmarks/idle-billing-probe: mints a realtime token exactly like app.py,
holds the socket idle for N minutes sending nothing, then checks the usage
API (dashboard fallback for non-admin keys) — settles whether idle
connections bill anything. Owner-run only; never touches CI.

Both probes defer heavy imports so their pure helpers are unit-tested (6 new
tests) without coremltools/websockets in CI. A code-review pass found 7
issues, all fixed: the WS URL no longer duplicates /realtime (matches fal's
own client guard), handshake failures are caught without ever printing the
JWT-bearing URL, HF-download/metadata/usage-parse errors exit with guidance,
usage_params rejects naive datetimes, and the ANE path warms up longer.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T21:57:39.211302Z 82a1ec4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82a1ec40d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +143 to +145
if session["dropped_early"]:
print(f"Connection ended early: {session['dropped_early']}")
print("An early drop at token expiry is itself a finding — note the time above.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Abort the verdict when the socket never connects

When the WebSocket handshake fails, hold_idle() returns dropped_early, but this branch only prints the error and continues to query usage. Since no idle connection existed, a zero-cost response will still trigger the later guidance that idle connections are free, producing exactly the false experimental conclusion this probe is meant to prevent. Distinguish handshake failures from post-connect drops and exit without a billing verdict when connection was never established.

Useful? React with 👍 / 👎.

usage = httpx.get(
FAL_USAGE_ENDPOINT,
headers=auth,
params=usage_params(window_start, dt.datetime.now(dt.timezone.utc)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exclude the accounting wait from the usage window

The recorded window_end marks when the socket closes, but after waiting 90 seconds this request uses the current time as the query end. Any unrelated fal usage on the account during that settlement delay is therefore included and may be misattributed to the idle socket, while the output misleadingly prints the earlier window_end as the inspected boundary. Wait before querying, but use the captured socket-close time as the usage interval's end.

Useful? React with 👍 / 👎.

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