Repository navigation
test(kernels): load through a fresh Lora so the dense lm_head is not targeted (#4764) - #4886
Merged
Merged
Conversation
…targeted (#4764) TestKernelOutput.setUpClass materialized A/B on one Lora to learn `k`, then passed that same instance to every GPTQModel.load(adapter=...). Once A/B are materialized, Lora.targets_module() answers True for every module, so apply_dense_module_adapters targeted the dense lm_head, post_init("lm_head") found no tensors, and the A/B assertion aborted all 24 cases in setUpClass. Loads now go through _fresh_adapter(), an unmaterialized Lora with the same remote pin; setUpClass keeps its materialized instance only for `k`. Unblocking setUpClass exposed the next stale bound: TRITON bf16 declared atol=1e-5, below bf16 resolution, so it failed on every sample with and without a LoRA (and on the pre-existing non-LoRA case, which never used the adapter). Both measured values are exactly one bf16 ulp; the bound is now 0.015625, matching the other bf16 entries. No library behaviour changed. tests/kernels/test_gptq.py: 18 passed, 8 skipped (MACHETE/SWORDFISH are not supported on this sm_80 host).
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.
Fixes item 7 of #4764. Test-only; no library behaviour changed.
What was wrong
tests/kernels/test_gptq.py::TestKernelOutput.setUpClassbuilt oneLorainstance, materialized A/B on it with
post_init(target, ...)to learnk, andthen passed that same instance to every
GPTQModel.load(adapter=...)call.Once A/B are materialized,
Lora.targets_module()short-circuits toTrueforevery module (
adapter.py:355-357).apply_dense_module_adaptersthereforetries to attach the adapter to the dense
lm_head,has_weights("lm_head")returns
Truefor the same reason, andpost_init(weight_key="lm_head")findsno tensors and asserts:
All 24
TestKernelOutputcases ERROR insetUpClass.Fix
TestKernelOutput._fresh_adapter()returns an unmaterializedLorawiththe same remote pin (
allow_remote,revision,sha256). Everyloadgetsits own instance, so
targets_module()falls through to the PEFTtarget_moduleslist andlm_headis correctly not targeted.setUpClassstill materializes one instance to readk; it is no longerpassed to
load.test_kernel_*_with_loracall_fresh_adapter()instead ofdata.adapter.Also fixed: TRITON bf16
atolwas below bf16 resolutionUnblocking
setUpClassexposed the next layer.BACKEND.TRITONbf16 wasdeclared with
atol=1e-5, which is below bf16 resolution, so it failed onevery sample — with and without a LoRA, and also on the pre-existing
non-LoRA
test_kernel_bfloat16_1_triton, which never used the adapter at all:test_kernel_bfloat16_1_triton(no LoRA)test_kernel_bfloat16_with_lora_1_tritonBoth values are exactly one bf16 ulp (2^-7 at |y|~2, 2^-6 at |y|~4). The
bound is now
0.015625for the TRITON bf16 entry in both tables, matching the0.008-0.016bounds already used for EXLLAMA_V2/MACHETE/SWORDFISH/MARLIN.The f16 entry is untouched.
Red / green
Red, on
origin/main@4f287ebwith the original file:Green, same host, patched file, whole module:
All 16 executed cases pass; the 8 skips are
MACHETEandSWORDFISH, whichdeclare no support for this host's
sm_80.The reference is the TORCH backend with the same adapter, so a non-zero
MaxAbsDiff is the kernel's own dequant rounding, not adapter error.
Adapter-path regression tests
Environment note
This host's
flash_attn_2_cudahas an undefined symbol, so the runs aboveloaded
transformerswithis_flash_attn_2_available -> False(a localpytest plugin, not part of the diff). That failure is pre-existing and
unrelated to this change.
Claim:
agent-11788dff99fd, workload0df020bcd412.