Skip to content

Run the structural efficiency tests in CI - #808

Open
ZacharyZcR wants to merge 2 commits into
JustVugg:devfrom
ZacharyZcR:ci/efficiency-gate
Open

Run the structural efficiency tests in CI#808
ZacharyZcR wants to merge 2 commits into
JustVugg:devfrom
ZacharyZcR:ci/efficiency-gate

Conversation

@ZacharyZcR

Copy link
Copy Markdown
Contributor

Draft. Stacked on #804 β€” that PR makes these tests resolve the engine at all; this one runs them.

Context

#804 fixed tests/test_inefficiency.py looking for c/glm.exe, a name that stopped existing at the glm β†’ colibri rename. All 8 tests had been skipping on every platform. Now they can run β€” and nothing runs them.

What this adds

A job in the shape of inkling-oracle: build, generate the glm_tiny fixture, verify the fixture with the token-exact oracle first, then test against it.

Three tests, all structural:

test asserts
test_telemetry_parses the tok/s and PROFILE lines the whole efficiency tooling parses
test_profile_phases_present_and_nonneg no phase missing, none negative (negative = double-counted)
test_disk_wait_not_dominant a fully-resident model does not become I/O bound

What is deliberately excluded, and why

The throughput floor (test_tiny_tok_s_floor). A shared runner's tok/s is not reproducible. A flaky perf gate gets muted within a week and then protects nothing. That one stays a local / lab-machine check.

test_cpu_vs_cpu_determinism β€” and this one is worth naming, because the exclusion looks arbitrary until you read it.

Despite the name, it makes two assertions:

self.assertEqual(a["hit_pct"], b["hit_pct"])                                  # real determinism
self.assertLess(abs(a["tok_s"] - b["tok_s"]) / max(...), 0.25)                # tok/s stability

The second is a performance bound wearing a correctness name. Two identical greedy runs on a quiet local box came out 38.8% apart β€” the tiny replay is 15 ms end to end, so scheduler noise dominates it completely. On a shared runner it would be flaky on day one.

The first assertion is a genuine determinism check and it holds. Splitting the two, so the honest half can be gated, is worth doing β€” but as its own change, not silently inside a CI commit.

Verified both directions

A gate that cannot fail is worse than no gate:

  • the three pass three times in a row locally
  • breaking the REPLAY telemetry line on purpose (tok/s β†’ BROKEN) makes test_telemetry_parses fail

Note for anyone reproducing locally

If python3 -m unittest tests.test_inefficiency... gives ModuleNotFoundError, check for a tests package in your user site-packages shadowing the repo's directory β€” PYTHONNOUSERSITE=1 confirms it. That is a local-environment issue, not a repo one; CI is clean.

tests/test_inefficiency.py looked for `c/glm.exe`. The engine was renamed
glm -> colibri, and .exe only exists on Windows, so that path resolves on no
platform at all: _engine_present() has been returning False everywhere and
all 8 tests in the file have been skipping instead of running.

    $ python3 -m unittest discover -s tests -p 'test_inefficiency.py' -v
    ... skipped 'glm.exe not built (run: make glm.exe)'      x8

They are the throughput floor, the disk-wait share ceiling, the PROFILE
phase assertions and the CPU-vs-CUDA teacher-forcing agreement -- the
regression tests for the engine being fast, which is the property this
project exists for. A green `make test-python` has been reporting on none
of it.

tools/efficiency.py had the same default (`../glm.exe`), so anything else
driving it landed on the same missing file.

Both now resolve colibri/colibri.exe, preferring whichever exists. With the
engine built, the skip reason becomes the honest one:

    ... skipped 'glm_tiny fixture absent (... run tools/make_glm_oracle.py)'

which is a real prerequisite -- the fixture is gitignored and needs torch to
generate -- rather than a name nobody updated.

CONTRIBUTING's oracle command had the same stale binary and never said where
glm_tiny comes from, so a new contributor following it hits two dead ends in
one line.
The previous commit made tests/test_inefficiency.py resolve the engine again,
so those tests can run for the first time. Nothing runs them.

This adds a job that generates the glm_tiny fixture and runs the three that
assert STRUCTURE, in the same shape as inkling-oracle: build, generate,
verify the fixture with the token-exact oracle, then test against it.

  test_telemetry_parses                    the tok/s and PROFILE lines the
                                           whole efficiency tooling parses
  test_profile_phases_present_and_nonneg   no phase missing, none negative
                                           (negative = double-counted)
  test_disk_wait_not_dominant              a fully-resident model must not
                                           become I/O bound

Not the throughput floor. A shared runner's tok/s is not reproducible, and a
flaky perf gate gets muted within a week -- the floor stays a local/lab check.

test_cpu_vs_cpu_determinism is also left out, and that one is worth naming.
Despite the name, its second assertion is a tok/s stability bound (two runs
within 25%). On this box, two IDENTICAL greedy runs came out 38.8% apart --
the tiny replay is 15 ms end to end, so scheduler noise dominates it
completely. Its first assertion (hit-rate identical between runs) is a real
determinism check and does hold; splitting the two so the honest half can be
gated is worth a separate change, not a silent edit inside a CI commit.

Verified in both directions. The three pass three times in a row locally, and
breaking the REPLAY telemetry line on purpose (tok/s -> BROKEN) fails
test_telemetry_parses, so the gate is not vacuous.
@ZacharyZcR
ZacharyZcR marked this pull request as ready for review August 3, 2026 21:11
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