Repository navigation
test: make the capacity-loser scheduler test deterministic - #164
Conversation
Add the Fork Tests workflow. It builds the package on a macos-26 runner, builds the full MLX Metal library with cmake, copies it next to the test binaries, and runs six CBv2 paged suites one step each. A suite step fails when the suite executes zero tests or skips a test. Port the scripts from d-inference and add them to fork.yaml. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
system_profiler SPDisplaysDataType prints nothing on the hosted macos-26 VM. The CPU, memory and disk lines stay. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Pick the newest Xcode_26.x app whose name is only a version number. Beta and release candidate apps are left out, so a new beta on the runner image cannot change CI without a pull request. The step still fails when the selected Swift is older than 6.3. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
swift build makes no Metal library. The pinned mlx-swift excludes the MLX kernel sources and nojit_kernels.cpp from Cmlx, so SwiftPM builds MLX in JIT mode, and every MLX operation traps without a staged mlx.metallib. The partial 459-symbol library comes from xcodebuild, which this workflow does not use. State that the 10,000-symbol floor rejects a JIT-mode or incomplete cmake build. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
End the cache key with the commit SHA, as d-inference does, so each push to main saves a new entry. The prefix restore key still restores the newest entry for the same Xcode. Before the save, delete the staged mlx.metallib copies and the coverage data, so the cache keeps only SwiftPM output. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- run-nested-suite.sh: the suites need no model weights, but one test needs DARKBLOOM_EXCLUSIVE_NATIVE_GPU_TEST=1, which the caller sets. - fork-tests.yml: runs on main are not cancelled once they start. - Say "self-contained" instead of "hermetic" in the workflow and in fork.yaml. - fork.yaml: write the Fork Tests paragraph as one sentence per line, so later pull requests can add a sentence without touching the same lines. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
testWaitingQueueBackstopEmitsCanonicalQueueFullMarker polled every 5 ms for the hog request to show as running, but the hog finished its 60 scripted tokens in milliseconds. A late poll missed the window and the test failed after 10 s (Fork Tests run 36182132297, attempt 1). Set eventBufferCapacity to 4, as testDuplicateSubmitThrowsAndFirst- StreamStillDelivers does. The unread hog stream hits backpressure, so the hog pauses with its slot retained until the test drains it. The wait now also requires the hog to be paused. Only this test changes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Run swift format format with .swift-format on the whole file, so the format check of #160 passes. It changes four places outside the backstop test: two nested CBv2Request calls and three comment alignments in CBv2EngineLoopConfig arguments. No code changes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Validation follow-up for head cf975bf: before approval, please run CBv2SchedulerLoopTests in CI with both #163 and this fix included, using a Metal library built from the resolved dependency sources. Add a gating suite step or link an equivalent CI run that executes the changed tests, rather than only compiling them. Please include validation of the latest cf975bf head, including its defer cleanup; the documented repeated-run table is for the earlier 4de5082 revision. Keep the assertions for both successful completions and capacityRequeueCount >= 1 intact. Retain the negative-control evidence and report all attempts rather than treating a green rerun alone as proof that the flake is gone. This is a validation request based on the documented CI gap, not a claim of a newly reproduced product defect. |
Add a Fork Tests step that runs CBv2SchedulerLoopTests with scripts/run-nested-suite.sh, after the six Metal suites. The step fails when the class executes zero tests or skips a test, so CI runs the backstop fix instead of only compiling it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
testCapacityLoserIsRequeuedNotErrored minted its two requests inside two async let children. Both children increment the unsynchronized CBv2SchedFixtures.nextID at the same time, so both requests can get the same id. The second submit then throws duplicateRequestID. XCTest reports the last error thrown during the test, which is the CancellationError from the cbv2SchedCollect watchdog sleep, so the failure showed as "CancellationError" at CBv2SchedulerTestSupport.swift:533. The test now mints and submits both requests on its own task. It also holds the step loop until both requests wait, so both requests compete for the single KV slot in the same step and the requeue always happens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A defer releases suspendStepExecutionAtCountForTesting on the engine queue, so a throwing submit in testCapacityLoserIsRequeuedNotErrored cannot leave the step loop held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cf975bf to
acc541d
Compare
|
Reply written by Claude (agent) on David Tai's behalf. Done. Rebased onto #163's head; the head is now acc541d with the |
…follow-up) (Layr-Labs#471) feat(paroquant): MoE architecture support, prepared checkpoint caching, and rotation kernel optimizations ### MoE Support & Architecture - **PairwiseRotation & RotateSwitchGLU:** Extracted standalone `PairwiseRotation` module and implemented `RotateSwitchGLU` to support MoE PARO models (e.g., Qwen3.6-35B-A3B). - **MoE Loader Pipeline:** Added passes to stack per-expert AWQ weights, remap shared rotations, and patch switch GLU layers without mutating dense paths. - **Conversion Robustness:** Dropped theta-filter to convert un-partnered expert weights, match scales/biases to checkpoint float dtype, and optimized prefix matching from $O(N \cdot M)$ to $O(1)$. ### Performance - **Pre-Gather MoE Rotation:** Moved `gate_up` rotation before expert gather/sort, reducing row-rotation overhead by $1/\text{topK}$. - **Simdgroup Rotation Kernel:** Rewrote the Metal rotation kernel for `groupSize == 128` to execute in a single simdgroup with `simdgroup_barrier` (with generic fallback for other sizes), delivering up to 2x speedup. - **GatedDelta Fusion:** Compile-fused the 6-kernel elementwise decay gate chain into a single dispatch. - **Prepared Checkpoints:** Added background caching of converted weights to `prepared_checkpoint.safetensors` with self-healing validation manifests, cutting warm-load times significantly. ### Fixes & Cleanups - Unified `RotationDerivedState` and batched GPU evaluation across all rotation modules at load time. - Froze `PairwiseRotation` parameters to allow fused weighted reduction in `SwitchGLU`. - Fixed tool-call format and chat convention resolution in `loadParoQuantModel`. - Fixed volume free-space detection for disk persistence on CI runners. Refs Layr-Labs#208, Layr-Labs#209, Layr-Labs#220, Layr-Labs#424, Layr-Labs#471
Proposed changes
CBv2SchedulerLoopTests.testCapacityLoserIsRequeuedNotErroredfails now and then with this message:Cause
async letchildren (CBv2SchedulerLoopTests.swift:130-135before this PR). Each child callsCBv2SchedFixtures.request, which doesnextID += 1on anonisolated(unsafe) static var(CBv2SchedulerTestSupport.swift:442and:448-450). The two children run at the same time on different threads, so both requests can get the same id.submitwith that id then throwsCBv2SchedulerError.duplicateRequestID(EngineV2.swift:662-664). The test rethrows it attry await (a, b).cbv2SchedCollectthen cancels its watchdog, and the watchdog'stry? await Task.sleep(CBv2SchedulerTestSupport.swift:533) throws aCancellationError, whichtry?swallows. That error is the last one thrown, so XCTest reports it. The run took about 1 s because XCTest symbolicates the stack.No product code throws
CancellationErroron this path. The synchronousEngineV2.submitthrows only capacity, multimodal and duplicate-id errors.Probes (not in this PR) confirm steps 1 and 3:
async letchild throwsProbeError, then a separate task'stry? await Task.sleepis cancelled, then the test rethrows the child's error, fails withcaught error: "CancellationError()"at the sleep line. XCTest names the wrong error.The test had a second race, which did not fail in any run here. If the second child submitted late, the first request could finish before the second arrived. Then nothing is requeued, and the
capacityRequeueCount >= 1assertion fails.Fix
This PR changes only
testCapacityLoserIsRequeuedNotErrored:suspendStepExecutionAtCountForTesting = 0, set on the engine queue, as other CBv2 tests do. It checks that both requests are in the waiting queue, then releases the loop. The first step admits both requests. One gets the only KV slot, and the other tripscapacityExhaustedand is requeued. The requeue always happens.deferreleases the hold on the engine queue, so asubmitthat throws cannot leave the step loop held (commit cf975bf)..length, andcapacityRequeueCount >= 1.The file stays formatted with
swift format format --configuration .swift-format. The diff holds only this change.Test plan
Local runs on a laptop with 10 CPU cores (Apple silicon). Each run executed the whole
CBv2SchedulerLoopTestsclass (37 tests) with Xcode'sxctest -XCTest MLXLMTests.CBv2SchedulerLoopTests. During the runs, 8yes > /dev/nullloops kept 8 cores busy, which leaves about 3 cores for the tests, like the hostedmacos-26runner. I stopped the loops after each set and confirmed that none were left.ci/fork-tests(526161b, unfixed)defer)caught error: "CancellationError()"atCBv2SchedulerTestSupport.swift:533.swift build --build-testswith the Xcode 27.0 toolchain (Swift 6.4),--build-system native, the Xcode XCTest search paths, and-Xbuild-tools-swiftc -target -Xbuild-tools-swiftc arm64-apple-macosx14.0(without that flag, theBenchRevisionStampplugin does not compile for the default macOS 12 host target). The full build took 2.3 min. The rebuild for each test file took 12 to 24 s.work/mlx-metallib-aotwithscripts/stage-test-metallib.sh, as in test: hold the hog in the waiting-queue backstop test #163.scripts/check_forkdiff.py --upstream-ref refs/remotes/upstream/mainpasses.fork.yamlcoversTests/MLXLMTests/CBv2*.defercleanup) were rebased onto test: hold the hog in the waiting-queue backstop test #163's head 26f54f2 without change and are now 49e35f6 and acc541d. test: hold the hog in the waiting-queue backstop test #163's head adds a gated Fork Tests step forCBv2SchedulerLoopTests.defercleanup: https://github.com/Layr-Labs/mlx-swift-lm/actions/runs/36284663877, success on the first attempt. TheCBv2SchedulerLoopTestsstep executed 37 tests with 0 failures and 0 skips.testCapacityLoserIsRequeuedNotErroredpassed in 0.022 s andtestWaitingQueueBackstopEmitsCanonicalQueueFullMarkerin 0.068 s. This is one CI run, not a repeated-run result.Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes: the changed file is formatted withswift format formatand.swift-formatDependencies
This PR is stacked on #163 (base
test/scheduler-backstop-deterministic), because both change the same file. Merge it after #163 and before #166, #167 and #161. #166 is stacked on this PR.Merge order: #160, then #159, then delete
ci/fork-testsso GitHub retargets the stacked PRs tomain, then #162, then #163, then #164, then #166, then #167, then #161.Authorship
The commits were written by Claude Opus 5.5.
🤖 Generated with Claude Code