Skip to content

Fix test_throughput_consistency: replace np.datetime64 timing with time.perf_counter_ns#3

Merged
rwilliamspbg-ops merged 2 commits into
mainfrom
copilot/fix-github-actions-test-job
Jun 5, 2026
Merged

Fix test_throughput_consistency: replace np.datetime64 timing with time.perf_counter_ns#3
rwilliamspbg-ops merged 2 commits into
mainfrom
copilot/fix-github-actions-test-job

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

test_throughput_consistency always failed in CI because np.datetime64('now') has only microsecond resolution — the timed operation completes in <1μs, so all latencies measured as 0.0, producing 0/0 = nan which fails the < 0.2 assertion.

Changes

  • Timing: Replace np.datetime64('now') with time.perf_counter_ns() (nanosecond integer, no floating-point rounding)
  • Sampling: Best-of-10 measurements per batch size to eliminate OS scheduling noise (standard microbenchmark practice)
  • Warmup: 3 dry runs per batch size before measuring to avoid cold-cache skew
  • Safety guard: Skip if min_latency < 100 ns rather than == 0 — catches unrealistically small values even with a proper timer
# Before — zero-resolution timing
start = np.datetime64('now')
_ = single_node_forward(model, x[0])
end = np.datetime64('now')
latency = (end - start).astype(np.float64) * 1e9  # always 0.0

# After — nanosecond best-of-N
samples = []
for _ in range(10):
    start = time.perf_counter_ns()
    _ = single_node_forward(model, x[0])
    samples.append(time.perf_counter_ns() - start)
best_latency = float(min(samples))

Copilot AI changed the title [WIP] Fix failing GitHub Actions job 'test' Fix test_throughput_consistency: replace np.datetime64 timing with time.perf_counter_ns Jun 5, 2026
Copilot AI requested a review from rwilliamspbg-ops June 5, 2026 11:20
@rwilliamspbg-ops rwilliamspbg-ops marked this pull request as ready for review June 5, 2026 11:35
@rwilliamspbg-ops rwilliamspbg-ops merged commit 675ea33 into main Jun 5, 2026
1 check passed
@rwilliamspbg-ops rwilliamspbg-ops deleted the copilot/fix-github-actions-test-job branch June 5, 2026 11:35
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.

2 participants