Skip to content

tests: isolate CCD pools and quantization refusals - #718

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:fix-order-dependent-tests
Oct 23, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:fix-order-dependent-tests

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

작업자 수와 JSON 키 순서에 따라 실패하던 단위 시험 세 개를, 어떤 환경에서도 같은 결과가 나오도록 고칩니다.

Part of #565. Tracked in #699.

What and why

Three unit tests fail on a supported setup before they reach the contract they check. The product code is correct in each case; the fixtures assume something the test does not set up.

  1. a_ccd_dispatch_returns_the_error_of_the_lowest_failing_run asserts a pool of at least four threads and then searches pair sizes for a lane that crosses from one pair into the next. With BLOOMERY_THREADS=6 the search finds no such lane and the test panics with some lane of CCD 0 crosses a pair. This came in with d872bfc79d22.
  2. a_profiled_ccd_dispatch_counts_busy_time_by_participant asserts a pool of at least eight threads. With a smaller BLOOMERY_THREADS it fails on that assertion, and it also reads the global profile table, which other tests in the same process reset and fill. This came in with d872bfc79d22.
  3. checkpoint_configs_declare_formats_or_refuse_by_name in crates/hf/src/quant_config.rs feeds one checkpoint config that holds a Q8_0 head and an IQ2_XXS expert, and expects the error for the expert. The config rejects whichever entry the JSON parser yields first. With serde_json/preserve_order that is the Q8_0 head, so the test fails with the right error for the wrong entry. This came in with 8e55fa1297d8 (placement, model, gpu-gates: --place tp plans GLM-5.3-Flash's Hugging Face checkpoint over N ranks, each in its own node's pool #519).

Changes:

  • crates/model/src/ops.rs: the two CCD tests now run in a fresh process of the test binary with BLOOMERY_THREADS=8, so the pool has eight workers whatever the parent sets and the profile table is not shared with other tests. One helper, in_ccd_pool, is used by both tests. It asserts on the child's exit status and on its test count, so a child that runs no test is an error.
  • The error-order test uses five pairs of sixteen units instead of searching for a crossing. Units 0 and 16 fall in the first lane of CCD 0 and unit 8 in the first lane of CCD 1, so the test still tells apart ordering by the lane's first unit from ordering by the failing run's first unit. It runs at both profile levels, 0 and 1.
  • crates/hf/src/quant_config.rs: the Q8_0 head and the IQ2_XXS expert are each parsed alone, and the test checks the refusal message names that format and module. The result no longer depends on JSON key order.

No product code, public API, GPU path, gate, band, unsafe or pin changes.

Release notes: internal: three unit tests no longer depend on the worker count or the JSON key order.

Code shape

  • No second copy. The CCD tests share one helper in their test module. No reusable pool helper existed in crates/model.
  • Model code holds only architecture facts. No model code changes.
  • Dead code is gone. The pair-size search and the run-start collection in the error-order test are removed.
  • No silent failure. The helper asserts on the child's exit status and its test count.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moves. The tests assert the same contracts on fixtures that hold them.
  • cargo fmt is clean on the touched files with the repository's pinned rustfmt. cargo clippy was not run on this branch.

Duplication found or removed (path:line): none.

What I ran

The two CCD tests fail on current main with six workers, and the quantization test fails with serde_json/preserve_order:

BLOOMERY_THREADS=6 cargo test -p bloomery-model --lib ccd_dispatch -- --nocapture
test result: FAILED. 0 passed; 2 failed; 1 ignored; 0 measured; 464 filtered out; finished in 0.00s
MODEL_FAIL_FIRST_RC=101
cargo test -p bloomery-hf --lib --features serde_json/preserve_order checkpoint_configs_declare_formats_or_refuse_by_name -- --nocapture
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 85 filtered out; finished in 0.03s
HF_FAIL_FIRST_RC=101

The panics were needs a pool of 8 or more threads, some lane of CCD 0 crosses a pair, and the refusal of the Q8_0 head where the test expected IQ2_XXS.

On this branch, the CCD tests pass at six worker counts (BLOOMERY_THREADS of 1, 2, 3, 4, 6 and 8), and the quantization tests pass with and without serde_json/preserve_order:

BLOOMERY_THREADS=N cargo test -p bloomery-model --lib ccd_tests -- --nocapture
test result: ok. 8 passed; 0 failed; 2 ignored; 0 measured; 454 filtered out; finished in 0.27s
cargo test -p bloomery-hf --lib quant_config::tests -- --nocapture
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 80 filtered out; finished in 0.47s
cargo test -p bloomery-hf --lib --features serde_json/preserve_order quant_config::tests -- --nocapture
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 80 filtered out; finished in 0.51s

The two ignored CCD tests are the existing hw_ tests that pin the calling thread and read the machine's CCD topology. They stay ignored.

Not run: the rest of the workspace test suite, clippy, and any GPU test or speed comparison. This change touches two test modules only.

Reproduce:

BLOOMERY_THREADS=6 cargo test -p bloomery-model --lib ccd_tests
cargo test -p bloomery-hf --lib --features serde_json/preserve_order quant_config::tests

Hardware

The base run was on a Linux x86_64 host. The branch run was on a DGX Spark (Linux aarch64) in a CUDA 13.3.1 container with the repository's pinned nightly-2026-08-28 toolchain. All of these tests run on the CPU.

What I ran into

This does not block the PR. The same fresh-process pattern already exists in crates/model/src/moe.rs, and the other tests in ccd_tests either run pure geometry over several sizes or are the ignored hardware tests, so I found no other test there that assumes a minimum pool size. The other refusal cases in quant_config.rs parse one bad entry at a time, so they do not depend on key order either.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added the model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja label Oct 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: The fixture changes preserve the tested contracts and isolate process-wide state.

Checked

Duplicates: 2 new items checked. The helper extracts the existing MoE subprocess harness and serves three tests. No new duplication found; dryer reported 0 pairs.
Complexity: crapper flagged no changed functions.
Silent failure: 3 sites followed: the subprocess result and two fixture lookups. Spawn failure, failed child, zero selected tests, and missing fixture entries fail assertions.
Tests: static mutation checks cover all four changed tests. Keeping the lane start at ops.rs:4109 returns unit 16 instead of 8. Using the sorted index at ops.rs:3824 fails the participant assertion. Accepting either refused algorithm at quant_config.rs:484 fails its refusal assertion. Dropping lever validation at ops.rs:4417 fails the MoE panic assertion.
Gates: no bands, tolerances, pins, or gate cases relaxed.
Adversarial checks: small parent pools, zero child tests, JSON insertion order, and aarch64 lever refusal are covered by process isolation or assertions.
Escape catalog: no C1–C4 patterns matched.

Notes

Cargo tests were not run during this review. The fixture contents and CCD lane geometry were checked independently.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 39b08fa into midagedev:main Oct 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant