Skip to content

fix(kernel): import resolve_kernel_config in ParoQuantTritonLinear and restore the Ruff gate - #4366

Merged
Qubitium merged 2 commits into
mainfrom
fix/4180-followup
Nov 16, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/4180-followup

Conversation

@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator

TL;DR

Follow-up to #4364, which shipped with two defects. Net: 13 files, small.

  1. ParoQuantTritonLinear.__init__ reads resolve_kernel_config(...) but the
    module never imported it, so constructing that kernel raises NameError.
  2. The Ruff Check gate is red on main for 13 files, 12 of them import-order
    fallout from the new imports and one now-unused env_flag import.

1. The bug

#4364 replaced the ParoQuant Triton environment reads with the policy object:

kernel = resolve_kernel_config(kwargs.get("kernel"))

but the import block only gained the other modules' accessors. The failure is
invisible to the suite because AUTO never selects PAROQUANT_TRITON on a
CPU-only host, so nothing in CI constructs the class:

flowchart LR
    A["AUTO backend selection on a CPU host"] --> B["never builds ParoQuantTritonLinear"]
    B --> C["NameError is never raised in CI"]
    D["explicit backend=PAROQUANT_TRITON<br/>or a CUDA host with Triton"] --> E["ParoQuantTritonLinear.__init__"]
    E --> F["resolve_kernel_config is undefined"]
    F --> G["NameError before the layer can quantize"]
Loading

2. The fix

Add the missing import, and add a regression test that does not depend on the
device or the backend selector:

from gptqmodel.nn_modules.qlinear import paroquant_triton

assert paroquant_triton.resolve_kernel_config is resolve_kernel_config
source = inspect.getsource(paroquant_triton.ParoQuantTritonLinear.__init__)
assert "resolve_kernel_config(" in source

I verified the test fails when the import is reverted and passes with it:

# import reverted
tests/test_kernel_config.py::test_paroquant_triton_linear_reads_the_policy FAILED
E   AttributeError: module ... has no attribute 'resolve_kernel_config'

# import restored
22 passed

3. The lint gate

format/check.sh on main (9b11fb3):

gptqmodel/looper/module_looper.py:16:1: I001
gptqmodel/looper/weight_only_looper.py:15:1: I001
gptqmodel/models/loader.py:8:1: I001
gptqmodel/nn_modules/qlinear/paroquant_triton.py:100:18: F821 Undefined name `resolve_kernel_config`
gptqmodel/quantization/qqq.py:25:25: F401 `..utils.env.env_flag` imported but unused
tests/... (8 files) I001
Found 13 errors

After this PR format/check.sh prints All checks passed!. No behaviour
changes beyond the missing import; the import-order and unused-import edits are
mechanical (ruff check --fix).

4. Validation

format/check.sh                      -> All checks passed!
pytest tests/test_kernel_config.py   -> 22 passed
pytest tests/test_kernel_config.py tests/test_bitsandbytes.py \
  tests/test_exl3_capture_frontier.py tests/test_exl3_projection_resume.py \
  tests/test_mimo_gptq_roundtrip.py -k "not deepseek"
                                     -> pass

tests/test_paroquant.py has two failures on this host caused by ninja not
being on PATH for the JIT extension; the identical failures reproduce on a
clean main worktree and are unrelated.

#4364 moved ParoQuantTritonLinear onto KernelConfig but dropped the accessor
import, so constructing the Triton ParoQuant kernel raised NameError:

    kernel = resolve_kernel_config(kwargs.get("kernel"))
             ^^^^^^^^^^^^^^^^^^^^^

The default backend selection never instantiates that class on a CPU-only
host, so the suite stayed green while the class was unimportable-in-practice.
Add the import and a regression test that asserts the symbol resolves and the
constructor still reads the policy.

Also sort the import blocks the new imports made unsorted in #4364 (this is
what the Ruff Check gate reported for 13 files) and drop the now-unused
env_flag import in qqq.py. format/check.sh is green again.
@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator Author

CI note: AWQ CPU (unit) and AWQ CPU (dense) fail here, and they fail the same
way on a clean origin/main (9b11fb3) worktree — I verified the identical
failure set (18 tests, same names) on both trees before opening this PR:

  • tests/test_awq_scaling_groups.py::...[falcon_h1|falcon_mamba|nemotron_h]
  • tests/test_awq_weight_mean.py::test_awq_weight_mean_matches_legacy_impl_*
    (TypeError: fake_compute_best_scale() got an unexpected keyword argument 'syms')
  • tests/test_awq_weight_mean.py::test_awq_clip_search_nan_grid_keeps_unclipped_bound
    (TypeError: nan_quantize() got an unexpected keyword argument 'sym')

These are not touched by this PR; its diff is the missing import, the
regression test, and mechanical import ordering. The Ruff Check gate that this
PR exists to restore is green on both runs of the head commit.

@Qubitium

Copy link
Copy Markdown
Collaborator

@ZX-ModelCloud fix.

@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator Author

@ZX-ModelCloud fix.

I will fix

@Qubitium
Qubitium merged commit beb6db8 into main Nov 16, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/4180-followup branch November 16, 2026 11:04
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