Skip to content

Tests: the server's linear-time checks compare the thread's cycles on Windows - #1854

Merged
ashhart merged 2 commits into
ashhart:mainfrom
Bizuayeu:pr/linear-time-cycles
Nov 2, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
Bizuayeu:pr/linear-time-cycles

Conversation

@Bizuayeu

@Bizuayeu Bizuayeu commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

What this changes

linear_time.fastest now also returns each size's work: the thread's cycles from QueryThreadCycleTime on Windows, the ns it already took elsewhere. The checks compare work between sizes. Their limits in time (20 ms, 5 s) stay on ns, since cycles are not time.

04f2420d8 (#1482) put these checks on the thread's CPU clock where std has one and left Windows on the awake clock, because Clock.cpu_thread.resolution gives ClockUnavailable there. So a busy runner can still slow only the larger size. zig-windows failed this way three times in about 600 No GPU runs over the two days to 11-01, on branches that do not touch the server (pr/glm-l2pf, lfm3-xpu, dsv41-up/dspark-statics). Each time it was another reader and page, and the job's only failure.

Receipt

  • Environment: main at 9e8c368b0, Zig 0.17.0. Windows 11 natively, eight cores. Linux x86_64 under WSL2. Host tests only, no GPU.
  • Exactness: n/a, test-only change.
  • Decode speed before and after: n/a, test-only change.
  • Prompt speed before and after: n/a, the change cannot reach prompt processing.
  • Tests run:
    • Reproduction on Windows: the Debug build of cortheon fuzz: every reader takes linear time on long inputs, main and this head in turn, beside busy processes:

      Busy processes main failed This head failed
      24 17 of 20 runs, 107 pairs over the line (clean 7 ms → 233 ms) 0 of 10
      8 1 of 20 0 of 10
      0 0 of 40 0 of 20
    • The same rounds on both counts, 959 reader and page pairs of three rounds with 8 busy processes: 48 over the line on the awake clock (up to 375x), 0 on cycles (7.6x at the median, 9.8x at most).

    • Mutations: with work set to ns, the new test fails on Windows. With a toText that searches back to the page start for every mark, the linear-time check fails on 9 pairs (9 ms → 619 ms).

    • Windows: zig build test --test-timeout 10m 421/421 steps, zig build fuzz-cortheon 3/3 steps (19/19 tests).

    • Linux: zig build test 458/458 steps (6,111 of 6,140 tests, 29 skipped), test-cuda-host 278/278 steps, test-server-security test-pull-security 14/14 steps, fuzz-cortheon 3/3 steps (19/19 tests).

    • zig fmt --check clean. tools/zig/lean_check.py: 424 problems on main and on this branch, zero new.

  • Not run: macOS, where work is the ns it already took. A GitHub runner under load: time the host takes from a VM's CPU may still count in cycles, and I could not measure that here. CUDA and Metal device checks do not apply.

On the same rounds, 12 more rounds after a miss left 21 of the 48 pairs over the line, and a floor of 100 ms left 2, so neither was the fix. The check in tool_parse_test.zig that reads clock itself stays on the awake clock; it allows 64x for 32x the calls and did not fail in these runs.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (Test-only change.)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Test-only change.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No bits change.)
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No kernel changes.)
  • Prompt processing is no slower than the last release. (The change cannot reach it.)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not. (Windows and Linux host tests; no GPU run, as above.)
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (fastest's work leaves out a sleep in a run fails on Windows with work set to ns, and skips where there is no CPU clock.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

Bizuayeu and others added 2 commits November 2, 2026 05:30
… Windows

04f2420 put these checks on the thread's CPU clock where std has one and left Windows on the awake clock, so tests
running beside them can still slow only the larger size. `fastest` now also returns each size's `work`: the thread's
cycles from QueryThreadCycleTime on Windows, the ns it already took elsewhere. The checks compare `work` between
sizes. Their limits in time stay on `ns`, since cycles are not time.
@ashhart
ashhart force-pushed the pr/linear-time-cycles branch from b950f2e to d0fadd9 Compare November 2, 2026 05:30
@ashhart
ashhart merged commit 62c9d48 into ashhart:main Nov 2, 2026
9 checks passed
@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thank you @Bizuayeu. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

ashhart added a commit that referenced this pull request Nov 2, 2026
…t's fields

#1854 made linear_time.fastest return Fastest{ns, work}; #1898's new test in
program.zig, landed after it, still indexed the old [2]u64, so main's test build
failed to compile (8e35d52). Same change #1854 made in html.zig: the time bound
on ns, the 8x growth bound on work.
@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu! This is in TensorFold 1.2.2, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.2

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