Repository navigation
test(inference): run the real-inference test on CPU and move it out of tests/inference/tests - #144
Open
ddaihao2022 wants to merge 1 commit into
Open
ddaihao2022 wants to merge 1 commit into
ddaihao2022 wants to merge 1 commit into
Conversation
…f tests/inference/tests Closes LLMSQL#109 - 这条集成测试没有指定 device_map,用的是 inference_transformers 的默认值 "auto"。在有可见 CUDA GPU 的机器上模型会被搬到显卡上,Triton 随后 JIT 编译辅助 kernel,在缺 Python 开发头文件的环境里编不过 (Python.h: No such file or directory),一条本该纯 CPU 的测试直接失败。 现在显式传 device_map="cpu",并用 autouse fixture 把 CUDA_VISIBLE_DEVICES 置空兜底。 - CPU 上跑 fp16 既慢又容易撞到 PyTorch 未实现的 fp16 CPU 算子,这里显式用 dtype="float32"(_resolve_dtype 接受字符串,解析成 torch.float32)。 - 目录从 tests/inference/tests/integration/ 挪到 tests/integration/, 去掉多余的嵌套;仓库里没有任何地方按旧路径引用它,CI 用的是裸 pytest。 - 补上 @pytest.mark.slow(pyproject 里已注册),以及文件末尾缺失的换行。 只动这一个测试文件,未触碰 llmsql/ 下的产品代码。
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #109
Problem
test_real_inference_limitis meant to exercise the transformers backend on CPU, but it never passed adevice_map, soinference_transformersfell back to its default"auto". On a machine with a visible CUDA GPU the model is offloaded to the GPU and Triton then tries to JIT-compile a helper kernel, which fails when the Python development headers are missing (Python.h: No such file or directory).The same test also lived in
tests/inference/tests/integration/, a needless extra level of nesting.What changed
tests/inference/tests/integration/test_inference_transformers_real_limit.py->tests/integration/test_inference_transformers_real_limit.py(pure move; nothing references the old path, and CI invokes barepytest).device_map="cpu"and anautousefixture that setsCUDA_VISIBLE_DEVICES="", so even an indirectly-derived placement cannot pick the GPU.dtype="float32". Once execution is pinned to CPU there is no reason to keep the defaultfloat16: fp16 CPU kernels are slow and are the likeliest source of "unimplemented on CPU" errors._resolve_dtypeaccepts the string and resolves it totorch.float32.@pytest.mark.slowmarker next to@pytest.mark.integration.ruffno longer complains.Only this one test file is touched — nothing under
llmsql/.Verification
ruff check tests/integrationandruff format --check tests/integration: clean.inference_transformersreally acceptsdevice_map/dtypeas keyword-only arguments, and that_resolve_dtype("float32")resolves to atorch.dtype.tests/integrationend to end — not possible on my machine:torchandtransformersare not installed (multi-GB wheels, no GPU), so this file and the four other transformers tests cannot even be collected locally. The fix takes effect only on a machine with a visible GPU / the transformers extra, i.e. CI.No-regression check
Ran the CPU-runnable subset before and after the change:
Both runs give exactly the same result —
7 failed, 157 passed, 2 skipped. The 7 failures are pre-existing onmainand all come from the missing transformers/torch install (6 of them) plus one unrelatedtempfileassertion intests/utils/test_inference_utils.py. My change does not move that number.Happy to adjust if you'd rather keep fp16 and mask CUDA only — I can drop the
dtypeargument.