Conversation
Bump ruff-pre-commit to v0.16.9 and switch to Ruff's default rule set. Apply safe/vetted fixes, fix real issues found by the new rules, and ignore rules that are noisy or conflict with existing tooling. Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The GGUF synchronization script can destroy the bundled converter tree when a download fails partway through.
Review effort: Balanced
Findings: None
What changed in this PR
Updates Ruff to v0.16.9, adopts its default rules, and resolves resulting violations across core code, backends, tooling, and tests.
Changes:
- Modernizes annotations, imports, context managers, and redundant expressions.
- Fixes mutable defaults, resource handling, and ineffective assertions.
- Adds GGUF synchronization and ARK lm-eval helper scripts.
| File | Description |
|---|---|
test/unit/test_xpu/test_autoround.py |
Removes redundant statements. |
test/unit/test_mlx/test_mlx_format.py |
Modernizes optional annotation. |
test/unit/test_cuda/models/test_mllm.py |
Simplifies generator assertions. |
test/unit/test_cuda/models/test_get_block_name.py |
Fixes mutable defaults and assertion style. |
test/unit/test_cuda/backends/test_marlin_backend.py |
Removes self-assignments. |
test/unit/test_cuda/advanced/test_multiple_card.py |
Simplifies ranges and formatting. |
test/unit/test_cpu/quantization/test_neuqi.py |
Simplifies return and boolean expressions. |
test/unit/test_cpu/models/test_block_names.py |
Simplifies assertion. |
test/unit/test_cpu/export/test_llmc_format.py |
Closes JSON files correctly. |
test/unit/test_cpu/core/test_resume_integration.py |
Combines context managers. |
test/unit/test_cpu/core/test_autoround.py |
Removes stray comment. |
test/unit/envs.py |
Uses runtime-safe Callable import. |
test/unit/common/utils/test_weight_handler.py |
Removes redundant statement. |
test/unit/common/utils/test_model_utils.py |
Simplifies attribute access. |
test/unit/common/utils/test_missing_tensors.py |
Uses dictionary items directly. |
test/unit/common/utils/test_generation.py |
Removes self-assignment. |
test/unit/common/utils/test_device_manager.py |
Combines context managers. |
test/unit/common/utils/test_common_pure_helpers.py |
Narrows expected exception. |
test/unit/common/schemes/test_w8_asym_policy.py |
Uses next for lookup. |
test/unit/common/models/test_vlm_ram_reduction.py |
Combines patches. |
test/unit/common/models/test_unfused_moe_init.py |
Flattens patch contexts. |
test/unit/common/models/test_moe_model.py |
Simplifies boolean expression. |
test/unit/common/models/test_cosmos3.py |
Combines context managers. |
test/unit/common/models/test_block_names.py |
Modernizes super(). |
test/unit/common/models/test_bagel.py |
Updates exception-source assertions. |
test/unit/common/export/test_qlinear_fp_helpers.py |
Removes always-true assertion. |
test/unit/common/export/test_mlx_export.py |
Closes JSON file correctly. |
test/unit/common/export/test_gguf_dtype_helpers.py |
Simplifies range. |
test/unit/common/eval/test_evaluation.py |
Combines mocked contexts. |
test/unit/common/compressors/test_compressors_init.py |
Simplifies attribute access tests. |
test/unit/common/algorithms/transforms/hadamard/test_dispatcher.py |
Combines exception and patch contexts. |
test/integration/test_cpu/test_inc_integration.py |
Merges isinstance checks. |
test/helpers.py |
Simplifies dynamic calls and defaults. |
test/e2e/test_cuda/test_vllm_throughput.py |
Removes unused typing import. |
test/e2e/test_cuda/test_sglang_throughput.py |
Removes unused typing import. |
test/e2e/test_cpu/test_save_load_roundtrip.py |
Modernizes generic annotation. |
test/e2e/test_cpu/test_moe_e2e.py |
Removes unused typing import. |
test/e2e/test_cpu/test_gguf_cpu_inference.py |
Modernizes generic annotation. |
test/e2e/test_cpu/test_gguf_conversion_e2e.py |
Modernizes generic annotation. |
test/e2e/test_cpu/test_diffusion_quantize_e2e.py |
Removes unused typing import. |
test/e2e/test_cpu/test_bf16_vs_quant_quality.py |
Modernizes return annotation. |
test/conftest.py |
Uses collections.abc.Mapping. |
setup.py |
Closes README and modernizes formatting. |
pyproject.toml |
Enables Ruff defaults and documents ignores. |
auto_round/utils/resume.py |
Modernizes optional annotation. |
auto_round/utils/path_safety.py |
Modernizes collection annotations and exports. |
auto_round/utils/missing_tensors.py |
Simplifies iteration and prefix checks. |
auto_round/utils/distributed.py |
Uses functools.cache. |
auto_round/utils/common.py |
Applies Ruff simplifications. |
auto_round/utils/bit_packing.py |
Modernizes annotations and exports. |
auto_round/special_model_handler.py |
Modernizes callable and optional annotations. |
auto_round/scheme_entry.py |
Modernizes union annotations. |
auto_round/modeling/unfused_moe/qwen3_next.py |
Removes empty docstring. |
auto_round/modeling/unfused_moe/qwen3_moe.py |
Removes empty docstring. |
auto_round/modeling/unfused_moe/glm_moe_light.py |
Removes empty docstring. |
auto_round/modeling/unfused_moe/__init__.py |
Removes redundant exception alias and accessors. |
auto_round/modeling/fused_moe/qwen3_vl_moe.py |
Simplifies local annotation. |
auto_round/modeling/fused_moe/moe_experts_interface.py |
Removes redundant class statement. |
auto_round/modeling/fused_moe/grouped_experts.py |
Simplifies support predicates. |
auto_round/modeling/fused_moe/deepseek_v2.py |
Modernizes annotations. |
auto_round/modeling/fused_moe/__init__.py |
Records intentional export ordering. |
auto_round/modeling/fp8_quant.py |
Simplifies string construction. |
auto_round/modeling/finegrained_fp8_patch.py |
Simplifies item lookup and messages. |
auto_round/modeling/finegrained_fp8_patch_v4.py |
Modernizes optional annotation. |
auto_round/logger.py |
Uses cache and modern annotations. |
auto_round/inference/convert_model.py |
Simplifies generators and flattening. |
auto_round/formats.py |
Sorts public exports. |
auto_round/export/utils.py |
Simplifies predicates and iteration. |
auto_round/export/svdquant_nunchaku.py |
Uses collection ABC imports. |
auto_round/export/svdquant_adapters/__init__.py |
Sorts public exports. |
auto_round/export/formats/resolver.py |
Modernizes optional annotations. |
auto_round/export/formats/base.py |
Modernizes API annotations. |
auto_round/export/formats/backends/svdquant_nunchaku.py |
Modernizes backend annotations. |
auto_round/export/formats/backends/mlx.py |
Modernizes backend annotations. |
auto_round/export/formats/backends/llm_compressor.py |
Consolidates equivalent branches. |
auto_round/export/formats/backends/fp8.py |
Modernizes backend annotations. |
auto_round/export/formats/backends/fake.py |
Modernizes backend annotations. |
auto_round/export/formats/backends/autoround.py |
Consolidates format branches. |
auto_round/export/formats/backends/auto_gptq.py |
Modernizes backend annotations. |
auto_round/export/formats/backends/auto_awq.py |
Modernizes backend annotations. |
auto_round/export/formats/backends/__init__.py |
Sorts public exports. |
auto_round/export/formats/__init__.py |
Sorts public exports. |
auto_round/export/export_to_mlx/export.py |
Modernizes export annotations. |
auto_round/export/export_to_llmcompressor/utils.py |
Modernizes collection annotations. |
auto_round/export/export_to_llmcompressor/export.py |
Simplifies attribute assignment. |
auto_round/export/export_to_llmcompressor/export_to_static_fp.py |
Modernizes annotations and defaults. |
auto_round/export/export_to_llmcompressor/export_to_fp.py |
Simplifies assignments and defaults. |
auto_round/export/export_to_llmcompressor/config.py |
Fixes mutable default arguments. |
auto_round/export/export_to_gguf/sync_llama_cpp_conversion.py |
Adds llama.cpp conversion synchronization. |
auto_round/export/export_to_gguf/special_handle.py |
Merges suffix checks. |
auto_round/export/export_to_gguf/llama_cpp_conversion.py |
Simplifies module attribute access. |
auto_round/export/export_to_gguf/hf_checkpoint_restorer.py |
Uses collection ABC imports. |
auto_round/export/export_to_gguf/convert.py |
Simplifies mapping and quantization branches. |
auto_round/export/export_to_awq/utils.py |
Converts representation to f-string. |
auto_round/export/export_to_awq/export.py |
Modernizes export annotations. |
auto_round/export/export_to_autoround/utils.py |
Modernizes return annotation. |
auto_round/export/export_to_autoround/qlinear_triton_act.py |
Simplifies range. |
auto_round/export/export_to_autoround/qlinear_fp.py |
Removes redundant return. |
auto_round/export/export_to_autoround/export.py |
Modernizes annotations and defaults. |
auto_round/export/export_to_autoround/export_to_nvfp_mx.py |
Modernizes assignments and annotations. |
auto_round/export/export_to_autoround/export_to_fp8.py |
Modernizes annotations and defaults. |
auto_round/export/export_to_autogptq/export.py |
Modernizes types and config access. |
auto_round/experimental/utils.py |
Converts message to f-string. |
auto_round/experimental/qmodules/nvfp4.py |
Modernizes optional annotations. |
auto_round/experimental/qmodules/nvfp4_e5m3.py |
Modernizes optional annotations. |
auto_round/experimental/qmodules/mxint4_utils.py |
Modernizes dtype annotations. |
auto_round/experimental/qmodules/fp8_static.py |
Modernizes tensor annotations. |
auto_round/experimental/qmodules/fp4_utils.py |
Modernizes dtype annotations. |
auto_round/experimental/qmodules/fake.py |
Modernizes tensor annotations. |
auto_round/experimental/qmodules/base.py |
Removes unused typing imports. |
auto_round/experimental/attention.py |
Modernizes imports and exports. |
auto_round/eval/evaluation.py |
Modernizes annotations, exits, and timing output. |
auto_round/eval/eval_cli.py |
Converts timing output to f-strings. |
auto_round/envs.py |
Modernizes environment annotations. |
auto_round/data_type/utils.py |
Modernizes collection annotations and assignments. |
auto_round/data_type/neuqi.py |
Converts validation messages to f-strings. |
auto_round/data_type/mxfp.py |
Simplifies weighting and dictionary iteration. |
auto_round/data_type/int.py |
Modernizes union annotation. |
auto_round/data_type/gguf.py |
Modernizes callable and union annotations. |
auto_round/context/model.py |
Modernizes annotations and assignments. |
auto_round/context/compress.py |
Modernizes context annotations. |
auto_round/compressors/utils.py |
Simplifies predicates and redundant branching. |
auto_round/compressors/shard_writer.py |
Modernizes optional annotations. |
auto_round/compressors/orchestrator.py |
Modernizes annotations and comprehensions. |
auto_round/compressors/mllm/utils.py |
Merges URL prefix checks. |
auto_round/compressors/mllm/template.py |
Modernizes template annotations. |
auto_round/compressors/mllm/processor.py |
Uses one timezone-aware timestamp. |
auto_round/compressors/mllm/__init__.py |
Sorts public exports. |
auto_round/compressors/mllm_mixin.py |
Modernizes public API annotations. |
auto_round/compressors/layer_config_resolver.py |
Modernizes annotations and type checks. |
auto_round/compressors/diffusion/dataset.py |
Modernizes dataset annotations. |
auto_round/compressors/diffusion_mixin.py |
Modernizes diffusion API annotations. |
auto_round/compressors/config_resolution/resolve.py |
Uses collection ABC import. |
auto_round/compressors/config_resolution/__init__.py |
Sorts public exports. |
auto_round/compressors/__init__.py |
Sorts public exports. |
auto_round/cli/algorithms.py |
Replaces sorting with min. |
auto_round/calibration/utils.py |
Iterates dictionary keys directly. |
auto_round/calibration/state.py |
Modernizes optional annotation. |
auto_round/calibration/register.py |
Uses built-in generic types. |
auto_round/calibration/mllm.py |
Simplifies generator and exit handling. |
auto_round/calibration/inputs.py |
Modernizes tuple annotations and exports. |
auto_round/calibration/diffusion.py |
Uses explicit process exits. |
auto_round/calibration/base.py |
Uses collection ABC import. |
auto_round/calibration/__init__.py |
Sorts public exports. |
auto_round/auto_scheme/utils.py |
Modernizes annotations and iteration. |
auto_round/auto_scheme/gen_auto_scheme.py |
Modernizes scheme annotations. |
auto_round/algorithms/utils.py |
Removes unnecessary quoted annotation. |
auto_round/algorithms/transforms/svdquant/smooth.py |
Uses collection ABC import. |
auto_round/algorithms/transforms/svdquant/apply.py |
Simplifies exclusion predicate. |
auto_round/algorithms/transforms/spinquant/serialize.py |
Modernizes forward references and cleanup. |
auto_round/algorithms/transforms/spinquant/monkeypatch.py |
Uses collection ABC import. |
auto_round/algorithms/transforms/spinquant/inplace/apply.py |
Modernizes optional annotations. |
auto_round/algorithms/transforms/spinquant/cayley_optimizer.py |
Uses collection ABC imports. |
auto_round/algorithms/transforms/spinquant/apply.py |
Simplifies return annotation. |
auto_round/algorithms/transforms/spinquant/__init__.py |
Records intentional export ordering. |
auto_round/algorithms/transforms/member.py |
Modernizes forward references. |
auto_round/algorithms/transforms/hadamard/utils/math.py |
Sorts public exports. |
auto_round/algorithms/transforms/hadamard/transforms.py |
Modernizes types and exports. |
auto_round/algorithms/transforms/hadamard/patch.py |
Fixes shared tensor defaults. |
auto_round/algorithms/transforms/hadamard/inplace/model_config.py |
Modernizes model mapping annotations. |
auto_round/algorithms/transforms/hadamard/inplace/hooks.py |
Consolidates identical hook branches. |
auto_round/algorithms/transforms/hadamard/inplace/apply.py |
Modernizes annotations and comprehensions. |
auto_round/algorithms/transforms/hadamard/dispatcher.py |
Modernizes annotations and assignment. |
auto_round/algorithms/transforms/hadamard/config.py |
Modernizes optional fields and exports. |
auto_round/algorithms/transforms/hadamard/apply.py |
Simplifies annotations and predicates. |
auto_round/algorithms/transforms/hadamard/__init__.py |
Records intentional export ordering. |
auto_round/algorithms/transforms/base.py |
Modernizes self-references and no-op method. |
auto_round/algorithms/transforms/awq/config.py |
Merges suffix checks. |
auto_round/algorithms/transforms/awq/base.py |
Simplifies exits, annotations, and predicates. |
auto_round/algorithms/transforms/__init__.py |
Records intentional export ordering. |
auto_round/algorithms/registry.py |
Modernizes callable and forward references. |
auto_round/algorithms/quantization/sign_roundv2/quantizer.py |
Modernizes types and log formatting. |
auto_round/algorithms/quantization/sign_round/sign_sgd.py |
Modernizes optimizer annotations and formatting. |
auto_round/algorithms/quantization/sign_round/quantizer.py |
Modernizes annotations and no-op return. |
auto_round/algorithms/quantization/sign_round/config.py |
Uses collection ABC import. |
auto_round/algorithms/quantization/rtn/config.py |
Modernizes optional booleans. |
auto_round/algorithms/quantization/registry.py |
Sorts public exports. |
auto_round/algorithms/quantization/base.py |
Removes redundant re-raise wrappers. |
auto_round/algorithms/quantization/adam_round/adam.py |
Removes no-op assignment. |
auto_round/algorithms/config.py |
Modernizes forward reference. |
auto_round/algorithms/block_runner.py |
Modernizes runner annotations. |
auto_round/algorithms/base.py |
Modernizes runner annotation. |
auto_round/__init__.py |
Sorts public exports. |
auto_round_extension/triton/triton_utils/kernels.py |
Simplifies kernel ranges. |
auto_round_extension/triton/triton_utils/custom_autotune.py |
Modernizes annotations and numeric expressions. |
auto_round_extension/triton/triton_utils_zp/kernels.py |
Simplifies kernel ranges. |
auto_round_extension/triton/triton_utils_zp/custom_autotune.py |
Modernizes annotations and numeric expressions. |
auto_round_extension/triton/qlinear_tritonv2.py |
Uses explicit exits and simpler ranges. |
auto_round_extension/triton/qlinear_tritonv2_zp.py |
Uses explicit exits and simpler ranges. |
auto_round_extension/triton/neuqi_sweep.py |
Simplifies Triton loop ranges. |
auto_round_extension/torch/qlinear_torch.py |
Simplifies packing range. |
auto_round_extension/torch/qlinear_torch_zp.py |
Simplifies packing range. |
auto_round_extension/mlx/__init__.py |
Sorts public exports. |
auto_round_extension/humming/qlinear_humming.py |
Sorts public exports. |
auto_round_extension/cuda/gptqmodel_marlin.py |
Modernizes types and boolean expression. |
auto_round_extension/cuda/cute_nvfp4_e5m3.py |
Uses cache and modern annotations. |
auto_round_extension/ark/tools/measure_sycl_tla_compile_memory.py |
Uses capture_output. |
auto_round_extension/ark/tools/lm_eval_with_ark_sdpa.py |
Adds patched lm-eval launcher. |
auto_round_extension/ark/test/validate_non_int8_cpu_sdpa.py |
Makes subprocess behavior explicit. |
auto_round_extension/ark/test/ut_utils.py |
Removes obsolete headers. |
auto_round_extension/ark/test/test_weightonly.py |
Combines XPU contexts. |
auto_round_extension/ark/test/test_sdpa_varlen.py |
Removes identical conditional arms. |
auto_round_extension/ark/test/test_sagev1_varlen.py |
Removes identical conditional arms. |
auto_round_extension/ark/test/test_packq.py |
Removes obsolete encoding header. |
auto_round_extension/ark/test/test_mxfp4_hadamard.py |
Removes redundant integer conversion. |
auto_round_extension/ark/test/test_moe.py |
Removes obsolete encoding header. |
auto_round_extension/ark/test/test_moe_unified.py |
Removes obsolete encoding header. |
auto_round_extension/ark/test/test_moe_prefill_perf.py |
Converts diagnostics to f-strings. |
auto_round_extension/ark/test/test_moe_prefill_accuracy.py |
Removes obsolete encoding header. |
auto_round_extension/ark/test/test_moe_decode_perf.py |
Converts diagnostics to f-strings. |
auto_round_extension/ark/test/test_matmul.py |
Removes obsolete encoding header. |
auto_round_extension/ark/test/test_flash_attn.py |
Simplifies boolean argument. |
auto_round_extension/ark/test/conftest.py |
Removes obsolete headers. |
auto_round_extension/ark/test/bench_ark_cpu_sdpa.py |
Clarifies formatted tuple expression. |
auto_round_extension/ark/setup.py |
Simplifies subprocess and README handling. |
auto_round_extension/ark/examples/run_flux.py |
Combines inference contexts. |
auto_round_extension/ark/benchmarks/bench_sparse_topk.py |
Removes obsolete encoding header. |
auto_round_extension/ark/benchmarks/bench_mxfp4_hadamard.py |
Removes obsolete encoding header. |
auto_round_extension/ark/auto_round_kernel/xpu_loader.py |
Uses collection ABC import. |
auto_round_extension/ark/auto_round_kernel/utils.py |
Uses functools.cache. |
auto_round_extension/ark/auto_round_kernel/sparse_attention.py |
Modernizes annotations. |
auto_round_extension/ark/auto_round_kernel/sparge_preprocess_triton.py |
Uses collection ABC import. |
auto_round_extension/ark/auto_round_kernel/qlinear.py |
Modernizes formatting and exports. |
.pre-commit-config.yaml |
Bumps Ruff to v0.16.9. |
.azure-pipelines/scripts/ut/collect_result.py |
Clarifies multiline formatting. |
.azure-pipelines/scripts/compat_smoke_test.py |
Makes subprocess behavior explicit. |
.azure-pipelines/scripts/ai_analysis/ai_analyze.py |
Uses datetime.UTC. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Description
Ruff 0.16 greatly expanded its default rule set. This PR bumps
ruff-pre-committov0.16.9, switches[tool.ruff.lint]to the defaults, and resolves all violations.Fixes
Optional,super(),functools.cache, f-strings,sys.exit, mergedisinstance/startswith, etc.).WrapperLinear._qdq_act: sharedtorch.tensor(1.0)default was mutated in place →Nonedefault.initialize_quantization: mutable list defaults and no-op self-assignments.json.dump(d, open(...)),json.load(open(...))).assert ... or Truethat could never fail;pytest.raises(Exception)→ValueError.if/elsewith identical arms, uselesstry/except: raise.Ignored rules (reason noted inline in
pyproject.toml):B023,BLE001,I001(conflicts with isort hook),PLR0402,RUF012,RUF059,RUF100,S110,S112,SIM102,SIM118(safetensors handles only expose.keys()),TRY004. Also allowdict(k=v)calls and treattorch.deviceas immutable forB008.Type of Change
Refactor
Related Issues
N/A
Checklist Before Submitting
/azp run Unit-Test-CUDA-AutoRound.Local verification:
pre-commit run --all-filespasses; CPU unit tests show no new failures compared withmain(remaining failures are environment-related and identical onmain).