Skip to content

Fix Ruff lint findings in gguf _builder.py - #544

Merged
justinchuby merged 2 commits into
mainfrom
fix/gguf-builder-lint
Aug 22, 2026
Merged

justinchuby merged 2 commits into
mainfrom
fix/gguf-builder-lint

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

Fixes the current CI lint failures in src/mobius/integrations/gguf/_builder.py reported by lintrunner (Ruff):

  • UP037: Removed redundant quotes from torch.Tensor annotations in the local helper functions of _reorder_deltanet_v_heads (_expand, _index_dim0, _index_dim1, _apply_rows, _apply_bare). The module already has from __future__ import annotations, so quoting these string-forward-references is unnecessary.
  • PIE810: Combined k.endswith(".linear_attn.A_log") or k.endswith(".linear_attn.dt_bias") into a single k.endswith((".linear_attn.A_log", ".linear_attn.dt_bias")) call.
  • RUFF-FORMAT: Reflowed the layer_stems set comprehension and the _reorder_out_proj_cols signature that were affected by the above changes.

No behavior change — purely lint/formatting fixes.

Testing

  • lintrunner on the changed file: clean (ok No lint issues.)
  • lintrunner against merge_base_with = main: clean (ok No lint issues.)
  • python -m pytest tests/gguf_test.py src/mobius/integrations/gguf/_builder_test.py -q: 91 passed
  • python -m pytest tests/build_graph_test.py tests/cli_test.py src/ -q -k "gguf": 321 passed

Co-authored-by: Copilot [email protected]

- Remove redundant quotes from torch.Tensor annotations in
  _reorder_deltanet_v_heads (Ruff UP037); the module already has
  `from __future__ import annotations` so quoting is unnecessary.
- Combine two endswith() calls into a single tuple-based call in the
  bare linear_attn parameter loop (Ruff PIE810).
- Apply ruff-format to reflow the layer_stems set comprehension and
  the _reorder_out_proj_cols signature that these changes affected.

No behavior change; verified with lintrunner and targeted GGUF tests.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 22, 2026 02:08

Copilot AI 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.

Pull request overview

This PR fixes Ruff lint and formatting findings in the GGUF builder without changing behavior.

Changes:

  • Removes redundant quoted torch.Tensor annotations.
  • Combines suffix checks.
  • Applies Ruff formatting updates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 0776f56 → 2862871

Model Sub-model Changes Status

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 0776f56 → 2862871

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 105 105 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 264 264 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 126 126 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 428 428 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 166 166 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

return t.index_select(0, idx)

def _index_dim1(t: "torch.Tensor", idx: "torch.Tensor") -> "torch.Tensor":
def _index_dim1(t: torch.Tensor, idx: torch.Tensor) -> torch.Tensor:
@justinchuby

Copy link
Copy Markdown
Member Author

Reviewed the automated feedback on this PR:

  • Copilot code review: summarized the change accurately, no concerns raised.
  • CodeQL/code-quality inline comment (unused _index_dim1 helper, line 825): this dead-code helper pre-dates this PR (present unchanged on main before this fix) — this PR only removed the quotes from its torch.Tensor annotations. Leaving it out of scope to keep this PR a focused, minimal lint fix as requested; happy to clean it up in a follow-up if desired.
  • CI Lint job: still shows failing, but this is a pre-existing failure already present on main HEAD (0776f56) itself, caused by unrelated Ruff findings (D205, RUFF-FORMAT) in src/mobius/integrations/gguf/_config_mapping_test.py and src/mobius/rewrite_rules/_group_query_attention_test.py — neither file is touched by this PR. The standalone lintrunner check (scoped via merge_base_with = main) passes cleanly for the diff in this PR.
  • Architecture Diff / Performance bots: no architecture or performance changes detected, as expected for a lint-only fix.

Follow-up to the gguf _builder.py lint fix: clears every other current
lintrunner (Ruff) finding on main so the CI Lint gate is fully green,
not just free of new alerts. All changes are mechanical and
behavior-neutral (test files only):

- _builder_test.py: RUF005 - replace list concatenation with iterable
  unpacking for new_shape; RUFF-FORMAT reflow of the out_proj.weight /
  out_proj.scales dict entries.
- _config_mapping_test.py: D205 - join the wrapped docstring summary
  line in TestQwen35RopeInterleave onto one line so it is followed by
  a blank line before the description (matches the existing docstring
  convention elsewhere in this file); RUFF-FORMAT blank-line spacing
  before TestMuseGlimmerPostprocess.
- _group_query_attention_test.py: RUFF-FORMAT collapse of a short
  multi-line assert onto one line and blank-line spacing before
  TestSlidingWindowSurvivesFusion.

Verified with `lintrunner --all-files` (pinned ruff 0.16.2): clean.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
@justinchuby
justinchuby merged commit 08a19bf into main Aug 22, 2026
23 of 24 checks passed
@justinchuby
justinchuby deleted the fix/gguf-builder-lint branch August 22, 2026 14:37
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