Skip to content

refactor: modernize type hints to Python 3.10+ syntax (src/)#2438

Closed
NJX-njx wants to merge 1 commit intovllm-project:mainfrom
NJX-njx:refactor/python310-modernize
Closed

refactor: modernize type hints to Python 3.10+ syntax (src/)#2438
NJX-njx wants to merge 1 commit intovllm-project:mainfrom
NJX-njx:refactor/python310-modernize

Conversation

@NJX-njx
Copy link

@NJX-njx NJX-njx commented Mar 4, 2026

Summary

Ref #1927

Modernizes type annotations across 58 source files in src/llmcompressor/ to use Python 3.10+ syntax, as proposed in the tracking issue.

Changes (automated via pyupgrade --py310-plus)

Before (Python 3.9) After (Python 3.10+) PEP
Union[X, Y] X | Y PEP 604
Optional[X] X | None PEP 604
List[X] list[X] PEP 585
Dict[K, V] dict[K, V] PEP 585
Tuple[X, ...] tuple[X, ...] PEP 585
Set[X] set[X] PEP 585
Type[X] type[X] PEP 585

Unused from typing import ... entries are also removed where applicable.

Scope

This PR covers the src/llmcompressor/ directory only. The tests/ directory can follow in a separate PR to keep review manageable.

Notes

  • No behavioral changes purely syntactic modernization
  • All changes were generated with pyupgrade --py310-plus and manually reviewed
  • The project already requires Python >= 3.10 (since Drop support for python 3.9 #1910)

Ref vllm-project#1927

Apply Python 3.10+ type hint modernization across 58 source files using
pyupgrade --py310-plus:

- Replace Union[X, Y] with X | Y (PEP 604)
- Replace Optional[X] with X | None (PEP 604)
- Replace List[X] with list[X] (PEP 585)
- Replace Dict[K, V] with dict[K, V] (PEP 585)
- Replace Tuple[X, ...] with tuple[X, ...] (PEP 585)
- Replace Set[X] with set[X] (PEP 585)
- Replace Type[X] with type[X] (PEP 585)
- Remove now-unused typing imports

This is the first batch targeting the src/llmcompressor/ directory.
Tests directory will follow in a separate PR.
Copilot AI review requested due to automatic review settings March 4, 2026 10:28
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request systematically modernizes the Python type hints within the core src/llmcompressor/ directory to leverage features introduced in Python 3.10 and later. The changes enhance type clarity and consistency by adopting native union operators and built-in generic types, along with refining import statements and minor code syntax for better maintainability and adherence to modern Python standards. This is a purely syntactic update with no behavioral changes.

Highlights

  • Type Hint Modernization: Updated type annotations across 58 source files in src/llmcompressor/ to use Python 3.10+ syntax, replacing Union[X, Y] with X | Y, Optional[X] with X | None, and generic types like List[X] with list[X].
  • Import Refactoring: Migrated imports for abstract base classes such as Callable, Iterable, Generator, Mapping, and Hashable from the typing module to collections.abc.
  • Code Cleanup: Removed unused from typing import ... imports, eliminated the coding=utf-8 header, and simplified open() calls by removing the redundant 'r' mode.
  • Syntax Consistency: Converted set comprehensions from set(...) to the more concise {...} syntax and updated f-string usage for improved readability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/llmcompressor/args/dataset_arguments.py
    • Updated Callable import from typing to collections.abc.
  • src/llmcompressor/core/events/event.py
    • Modernized Optional type hints to use the | None syntax.
    • Updated Optional type hints in method signatures to use the | None syntax.
  • src/llmcompressor/core/session.py
    • Updated Callable import from typing to collections.abc.
  • src/llmcompressor/core/session_functions.py
    • Updated Generator import from typing to collections.abc.
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/datasets/utils.py
    • Updated Callable import from typing to collections.abc.
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/entrypoints/model_free/init.py
    • Updated Iterable import from typing to collections.abc.
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/entrypoints/model_free/helpers.py
    • Updated Mapping import from typing to collections.abc.
    • Converted set comprehensions from all((...)) to all(...) and any((...)) to any(...).
  • src/llmcompressor/entrypoints/model_free/process.py
    • Updated Iterable import from typing to collections.abc.
  • src/llmcompressor/entrypoints/model_free/reindex_fused_weights.py
    • Removed explicit 'r' mode from open() call as it is the default.
  • src/llmcompressor/entrypoints/model_free/save_utils.py
    • Removed explicit 'r' mode from open() call as it is the default.
  • src/llmcompressor/entrypoints/model_free/validate.py
    • Removed explicit 'r' mode from open() call as it is the default.
  • src/llmcompressor/entrypoints/oneshot.py
    • Updated Callable import from typing to collections.abc.
  • src/llmcompressor/logger.py
    • Modernized Optional type hints to use the | None syntax.
    • Updated Dict type hint to dict.
  • src/llmcompressor/modeling/fuse.py
    • Updated Iterable import from typing to collections.abc.
  • src/llmcompressor/modeling/gpt_oss.py
    • Modernized Optional type hints to use the | None syntax.
    • Updated List type hints to list.
  • src/llmcompressor/modeling/llama4.py
    • Updated Tuple type hint to tuple.
  • src/llmcompressor/modeling/qwen3_moe.py
    • Removed the coding=utf-8 header.
  • src/llmcompressor/modifiers/autoround/base.py
    • Modernized Union and Optional type hints to use the | and | None syntax.
    • Updated Dict and List type hints to dict and list respectively.
    • Updated List type hint to list.
  • src/llmcompressor/modifiers/awq/base.py
    • Updated Iterator import from typing to collections.abc.
    • Converted set comprehensions from set(...) to {...}.
  • src/llmcompressor/modifiers/gptq/base.py
    • Modernized Union and Optional type hints to use the | and | None syntax.
    • Updated Dict type hints to dict.
    • Updated Tuple type hint to tuple.
  • src/llmcompressor/modifiers/pruning/constant/base.py
    • Modernized Union type hints to use the | syntax.
    • Updated Dict type hint to dict.
  • src/llmcompressor/modifiers/pruning/helpers.py
    • Updated Callable import from typing to collections.abc.
    • Updated Dict type hint to dict.
  • src/llmcompressor/modifiers/pruning/magnitude/base.py
    • Modernized Union type hints to use the | syntax.
    • Updated Dict type hints to dict.
  • src/llmcompressor/modifiers/pruning/sparsegpt/sgpt_base.py
    • Converted set comprehensions from set(...) to {...}.
  • src/llmcompressor/modifiers/pruning/sparsegpt/sgpt_sparsify.py
    • Modernized Optional type hints to use the | None syntax.
    • Updated Tuple type hint to tuple.
    • Updated Dict type hint to dict.
  • src/llmcompressor/modifiers/pruning/wanda/wanda_sparsify.py
    • Modernized Optional type hints to use the | None syntax.
    • Updated Dict type hint to dict.
  • src/llmcompressor/modifiers/quantization/calibration.py
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/modifiers/quantization/quantization/mixin.py
    • Modernized Optional, Union, List, Dict, and Set type hints to use the | None, |, list, dict, and set syntax respectively.
  • src/llmcompressor/modifiers/transform/quip/base.py
    • Modernized List, Union, and Optional type hints to use the list, |, and | None syntax respectively.
  • src/llmcompressor/modifiers/transform/smoothquant/base.py
    • Updated Callable import from typing to collections.abc.
    • Converted set comprehensions from set(...) to {...}.
  • src/llmcompressor/modifiers/transform/spinquant/base.py
    • Updated Iterable import from typing to collections.abc.
    • Modernized List and Optional type hints to use the list and | None syntax respectively.
  • src/llmcompressor/modifiers/transform/spinquant/mappings.py
    • Modernized Optional and List type hints to use the | None and list syntax respectively.
    • Updated Dict type hint to dict.
  • src/llmcompressor/modifiers/transform/spinquant/norm_mappings.py
    • Updated List type hint to list.
    • Updated Dict type hint to dict.
  • src/llmcompressor/modifiers/utils/hooks.py
    • Updated Callable import from typing to collections.abc.
  • src/llmcompressor/observers/base.py
    • Updated Tuple type hints to tuple.
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/observers/helpers.py
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/observers/moving_base.py
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/observers/mse.py
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/pipelines/cache.py
    • Updated Generator import from typing to collections.abc.
    • Updated IntermediateValue type hint to allow direct reference.
    • Initialized defaultdict with int factory for cleaner code.
    • Updated Generator type hints to remove None arguments.
  • src/llmcompressor/pipelines/data_free/pipeline.py
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/pipelines/sequential/helpers.py
    • Updated Callable import from typing to collections.abc.
    • Converted set comprehensions from set(...) to {...}.
  • src/llmcompressor/pipelines/sequential/pipeline.py
    • Updated Iterator import from typing to collections.abc.
  • src/llmcompressor/pytorch/model_load/helpers.py
    • Modernized Union and Optional type hints to use the | and | None syntax respectively.
  • src/llmcompressor/pytorch/utils/sparsification.py
    • Modernized Optional and Dict type hints to use the | None and dict syntax respectively.
  • src/llmcompressor/pytorch/utils/sparsification_info/configs.py
    • Updated Generator import from typing to collections.abc.
    • Updated Dict and Tuple type hints to dict and tuple respectively.
    • Modernized Tuple type hints to tuple.
    • Updated Dict type hints to dict.
  • src/llmcompressor/pytorch/utils/sparsification_info/helpers.py
    • Modernized Optional and List type hints to use the | None and list syntax respectively.
    • Updated f-string usage for error messages.
  • src/llmcompressor/pytorch/utils/sparsification_info/module_sparsification_info.py
    • Updated Generator import from typing to collections.abc.
    • Updated f-string usage for error messages.
    • Modernized Tuple type hints to tuple.
  • src/llmcompressor/recipe/recipe.py
    • Updated Dict and List type hints to dict and list respectively.
    • Modernized Union and Optional type hints to use the | and | None syntax respectively.
    • Removed explicit 'r' mode from open() call as it is the default.
  • src/llmcompressor/recipe/utils.py
    • Updated Dict and List type hints to dict and list respectively.
    • Updated f-string usage for error messages.
    • Modernized Optional type hints to use the | None syntax.
  • src/llmcompressor/transformers/data/base.py
    • Updated Callable import from typing to collections.abc.
    • Converted set comprehensions from set(...) to {...}.
  • src/llmcompressor/transformers/tracing/debug.py
    • Modernized Type and Tuple type hints to use the type and tuple syntax respectively.
  • src/llmcompressor/transformers/utils/helpers.py
    • Removed redundant parentheses around f-string in logger.debug call.
    • Converted set comprehensions from set(...) to {...}.
  • src/llmcompressor/typing.py
    • Updated Iterable import from typing to collections.abc.
  • src/llmcompressor/utils/dev.py
    • Modernized Type type hints to use the type syntax.
  • src/llmcompressor/utils/dist.py
    • Updated Callable and Hashable imports from typing to collections.abc.
  • src/llmcompressor/utils/metric_logging.py
    • Updated List type hints to list.
  • src/llmcompressor/utils/pytorch/module.py
    • Modernized Union and List type hints to use the | and list syntax respectively.
    • Updated Dict type hint to dict.
  • src/llmcompressor/utils/transformers.py
    • Converted set comprehensions from set(...) to {...}.
Activity
  • The changes were generated automatically using pyupgrade --py310-plus.
  • All generated changes were manually reviewed to ensure correctness and prevent regressions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modernizes Python type hints across numerous files in the src/ directory to align with Python 3.10+ syntax. The changes, primarily automated using pyupgrade, include adopting the | operator for unions, using built-in generic types (e.g., list instead of List), and updating imports from typing to collections.abc. Additionally, some minor stylistic improvements such as using f-strings and removing redundant parentheses have been applied. The changes are correct, improve code readability and maintainability, and have no impact on runtime behavior. The codebase is now more aligned with modern Python standards.

Copy link

Copilot AI left a comment

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 modernizes type annotations across src/llmcompressor/ to Python 3.10+ syntax (PEP 585/604) and adjusts related imports/usages to match the updated typing style.

Changes:

  • Replaced typing.Union/Optional/List/Dict/Tuple forms with | None and built-in generics (e.g., list[...], dict[...], tuple[...]).
  • Moved several typing protocols/ABCs (e.g., Callable, Iterator, Generator, Iterable, Mapping) to collections.abc.
  • Small syntactic cleanups (set comprehensions, f-strings, default read-mode open()).

Reviewed changes

Copilot reviewed 58 out of 58 changed files in this pull request and generated 47 comments.

Show a summary per file
File Description
src/llmcompressor/utils/transformers.py Minor set-construction simplification.
src/llmcompressor/utils/pytorch/module.py Updated function annotations to 3.10+ typing syntax.
src/llmcompressor/utils/metric_logging.py Switched List[...] annotations to list[...].
src/llmcompressor/utils/dist.py Moved Callable/Hashable to collections.abc and updated return typing.
src/llmcompressor/utils/dev.py Updated Type[...] to type[...] for model class parameter.
src/llmcompressor/typing.py Moved Iterable to collections.abc.
src/llmcompressor/transformers/utils/helpers.py Minor logging formatting cleanup.
src/llmcompressor/transformers/tracing/debug.py Updated Type[...]/Tuple[...] to type[...]/tuple[...].
src/llmcompressor/transformers/data/base.py Moved Callable to collections.abc and minor set usage cleanup.
src/llmcompressor/recipe/utils.py Updated dict/list typing + improved error string formatting.
src/llmcompressor/recipe/recipe.py Updated model fields and method annotations to built-in generics / `
src/llmcompressor/pytorch/utils/sparsification_info/module_sparsification_info.py Moved Generator to collections.abc and updated tuple typing.
src/llmcompressor/pytorch/utils/sparsification_info/helpers.py Updated list/optional typing and error formatting.
src/llmcompressor/pytorch/utils/sparsification_info/configs.py Moved Generator to collections.abc and modernized nested union/dict typing.
src/llmcompressor/pytorch/utils/sparsification.py Updated Optional[Dict[...]] to `dict[...]
src/llmcompressor/pytorch/model_load/helpers.py Updated union/optional typing to PEP 604 style.
src/llmcompressor/pipelines/sequential/pipeline.py Moved Iterator to collections.abc.
src/llmcompressor/pipelines/sequential/helpers.py Moved Callable to collections.abc and modernized typing in several helpers.
src/llmcompressor/pipelines/data_free/pipeline.py Updated optional dataloader typing to `DataLoader
src/llmcompressor/pipelines/cache.py Moved Generator to collections.abc, modernized annotations, and minor defaultdict simplification.
src/llmcompressor/observers/mse.py Updated optional tensor typing to `torch.Tensor
src/llmcompressor/observers/moving_base.py Updated optional module typing to `torch.nn.Module
src/llmcompressor/observers/helpers.py Updated optional tensor typing to `torch.Tensor
src/llmcompressor/observers/base.py Converted tuple aliases and optional parameter typing to 3.10+ syntax.
src/llmcompressor/modifiers/utils/hooks.py Moved Callable to collections.abc.
src/llmcompressor/modifiers/transform/spinquant/norm_mappings.py Updated list/dict typing to built-in generics.
src/llmcompressor/modifiers/transform/spinquant/mappings.py Updated optional/list/dict typing to 3.10+ syntax.
src/llmcompressor/modifiers/transform/spinquant/base.py Moved Iterable to collections.abc and modernized multiple field annotations.
src/llmcompressor/modifiers/transform/smoothquant/base.py Moved Callable to collections.abc and minor set construction simplification.
src/llmcompressor/modifiers/transform/quip/base.py Modernized targets/ignore/etc typing to PEP 604/585 style.
src/llmcompressor/modifiers/quantization/quantization/mixin.py Modernized config/observer typing and internal attributes to built-in generics.
src/llmcompressor/modifiers/quantization/calibration.py Updated optional tensor typing to `torch.Tensor
src/llmcompressor/modifiers/pruning/wanda/wanda_sparsify.py Updated device/dict typing to `
src/llmcompressor/modifiers/pruning/sparsegpt/sgpt_sparsify.py Updated device/dict/tuple typing to built-in generics.
src/llmcompressor/modifiers/pruning/sparsegpt/sgpt_base.py Minor set construction simplification for hooks.
src/llmcompressor/modifiers/pruning/magnitude/base.py Modernized targets/scheduler types to built-in generics / `
src/llmcompressor/modifiers/pruning/helpers.py Moved Callable to collections.abc and modernized dict typing.
src/llmcompressor/modifiers/pruning/constant/base.py Modernized targets and parameterized layer typing.
src/llmcompressor/modifiers/gptq/base.py Modernized multiple modifier field annotations and internal dict/tuple typing.
src/llmcompressor/modifiers/awq/base.py Moved Iterator to collections.abc and modernized set construction.
src/llmcompressor/modifiers/autoround/base.py Modernized typing in modifier fields and internal structures.
src/llmcompressor/modeling/qwen3_moe.py Removed encoding header comment.
src/llmcompressor/modeling/llama4.py Updated return tuple typing to built-in tuple[...].
src/llmcompressor/modeling/gpt_oss.py Modernized optional/list typing in MoE utilities.
src/llmcompressor/modeling/fuse.py Moved Iterable to collections.abc.
src/llmcompressor/logger.py Modernized config typing and dict typing in support_log_once.
src/llmcompressor/entrypoints/oneshot.py Moved Callable to collections.abc.
src/llmcompressor/entrypoints/model_free/validate.py Simplified open(..., 'r') to default read mode.
src/llmcompressor/entrypoints/model_free/save_utils.py Simplified open(..., 'r') to default read mode.
src/llmcompressor/entrypoints/model_free/reindex_fused_weights.py Simplified open(..., 'r') to default read mode.
src/llmcompressor/entrypoints/model_free/process.py Moved Iterable to collections.abc.
src/llmcompressor/entrypoints/model_free/helpers.py Moved Mapping to collections.abc and simplified generator expr parens.
src/llmcompressor/entrypoints/model_free/init.py Moved Iterable to collections.abc and modernized optional device typing.
src/llmcompressor/datasets/utils.py Moved Callable to collections.abc and modernized optional int typing.
src/llmcompressor/core/session_functions.py Moved Generator to collections.abc and modernized optional event payload typing.
src/llmcompressor/core/session.py Moved Callable to collections.abc.
src/llmcompressor/core/events/event.py Modernized multiple optional int/float typing.
src/llmcompressor/args/dataset_arguments.py Moved Callable to collections.abc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
from typing import Iterable, Optional
from typing import Optional
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import block will likely fail ruff check:

  • Optional is unused after switching to torch.device | str | None (F401).
  • isort typically expects from collections.abc import Iterable to be sorted with the other stdlib imports and usually before typing.
    Please remove the unused import and let ruff check --fix normalize ordering.
Suggested change
from typing import Optional

Copilot uses AI. Check for mistakes.
Comment on lines +10 to 13
from typing import Any

from collections.abc import Callable

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import order likely violates ruff/isort: from collections.abc import Callable should generally be sorted before from typing import Any within the stdlib section. Running ruff check --fix should reorder this block.

Suggested change
from typing import Any
from collections.abc import Callable
from collections.abc import Callable
from typing import Any

Copilot uses AI. Check for mistakes.
Comment on lines +13 to 16
from typing import Any

from collections.abc import Callable

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import order likely violates ruff/isort: from collections.abc import Callable should be sorted with the other stdlib imports and typically come before from typing import Any. Running ruff check --fix should normalize this ordering.

Copilot uses AI. Check for mistakes.
Comment on lines 521 to +524
def dispatch_for_sequential(
model: PreTrainedModel,
onload_device: Optional[torch.device | str] = None,
offload_device: Optional[torch.device | str] = None,
onload_device: torch.device | str | None = None,
offload_device: torch.device | str | None = None,
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After changing onload_device/offload_device to torch.device | str | None, the Optional import (from typing import ... Optional) in this module appears unused and will fail ruff check (F401). Please remove the unused Optional import.

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 11
def make_empty_row_scalars(
module: torch.nn.Module, device: Optional[torch.device] = None
module: torch.nn.Module, device: torch.device | None = None
) -> torch.Tensor:
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from typing import Dict, Optional is now unused after migrating annotations to dict[...] and torch.device | None, and will fail ruff check with F401. Please remove the unused typing imports.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to 30
def expand_special_targets(targets: str | list[str]) -> list[str]:
"""
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from typing import Dict, List, Union appears unused after converting annotations to list[...]/dict[...] and | unions, and will fail ruff check with F401. Please remove the unused typing imports (or run ruff check --fix).

Copilot uses AI. Check for mistakes.
Comment on lines +87 to 90
type_: EventType | None = None
steps_per_epoch: int | None = None
batches_per_step: int | None = None
invocations_per_step: int = 1
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from typing import Optional appears unused after converting annotations to X | None (it’s only referenced in docstrings now). This will fail ruff check with F401; please remove the unused Optional import.

Copilot uses AI. Check for mistakes.
Comment on lines +115 to +127
config_groups: dict[str, QuantizationScheme] | None = None
# NOTE: targets is not the sole source of truth for finding all matching target
# layers in a model. Additional information can be stored in `config_groups`
# Use self.resolved_targets as source of truth.
targets: Union[str, List[str]] = Field(default_factory=lambda: ["Linear"])
ignore: List[str] = Field(default_factory=list)
scheme: Optional[Union[str, Dict[str, Any]]] = None
kv_cache_scheme: Optional[QuantizationArgs] = None
targets: str | list[str] = Field(default_factory=lambda: ["Linear"])
ignore: list[str] = Field(default_factory=list)
scheme: str | dict[str, Any] | None = None
kv_cache_scheme: QuantizationArgs | None = None
# Observer parameters for easy specification
weight_observer: Optional[str] = None
input_observer: Optional[str] = None
output_observer: Optional[str] = None
observer: Optional[Dict[str, str]] = None
weight_observer: str | None = None
input_observer: str | None = None
output_observer: str | None = None
observer: dict[str, str] | None = None
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After switching these annotations to built-in generics and | None, the from typing import Any, Dict, List, Optional, Set, Union import looks largely unused (Dict, List, Optional, Set, Union no longer appear in type positions). This will fail ruff check with F401; please trim the typing import to only what’s still used (likely just Any).

Copilot uses AI. Check for mistakes.
Comment on lines +150 to +160
sequential_targets: str | list[str] | None = None
# AutoRound modifier arguments
iters: int = 200
enable_torch_compile: bool = True
batch_size: int = 8
lr: Optional[float] = None
device_ids: Optional[str] = None
lr: float | None = None
device_ids: str | None = None

# private variables
_all_module_input: Dict[str, List[Tuple]] = PrivateAttr(default_factory=dict)
_q_input: Optional[torch.Tensor] = PrivateAttr(default=None)
_all_module_input: dict[str, list[tuple]] = PrivateAttr(default_factory=dict)
_q_input: torch.Tensor | None = PrivateAttr(default=None)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from typing import Dict, List, Optional, Tuple, Union appears unused after updating this module’s annotations to built-in generics and | None. This will fail ruff check with F401; please remove the unused typing imports (or run ruff check --fix).

Copilot uses AI. Check for mistakes.
Comment on lines +37 to 40
args: dict[str, Any] = Field(default_factory=dict)
stage: str = "default"
modifiers: List[Modifier] = Field(default_factory=list)
modifiers: list[Modifier] = Field(default_factory=list)

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top-level from typing import Any, Dict, List, Optional, Union import now has unused names (Dict, List, Optional) after converting to built-in generics and | None. This will raise ruff F401; please trim the import to only the names still referenced (likely Any and Union).

Copilot uses AI. Check for mistakes.
@dsikka dsikka closed this Mar 4, 2026
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.

3 participants