[pre-commit.ci] pre-commit autoupdate - #2022
Merged
Merged
Conversation
updates: - [github.com/astral-sh/ruff-pre-commit: v0.16.0 → v0.16.1](astral-sh/ruff-pre-commit@v0.16.0...v0.16.1)
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the ruff-pre-commit hook version used by pre-commit.ci and applies the resulting automated formatting/modernization fixes across the codebase (imports, f-strings, minor refactors, and typing syntax updates).
Changes:
- Bump
ruff-pre-commitfromv0.16.0tov0.16.1. - Apply ruff auto-fixes across tests, examples, and library code (import ordering, f-strings,
super()modernization, small cleanups). - Update some type annotations to newer syntax (e.g.,
X | None,list[int],tuple[...]) in multiple modules.
Reviewed changes
Copilot reviewed 116 out of 116 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/L1/common/main_amp.py | Ruff auto-fixes (imports and f-strings) |
| tests/L1/common/compare.py | Ruff auto-fixes (blank line and f-strings) |
| tests/L0/run_test.py | Ruff import ordering |
| tests/L0/run_optimizers/test_lamb.py | Ruff import ordering + f-strings + super() |
| tests/L0/run_optimizers/test_fused_optimizer.py | Ruff import ordering + small simplification + super() |
| tests/L0/run_optimizers/test_fused_novograd.py | Ruff import ordering + f-strings + super() |
| tests/L0/run_optimizers/test_adam.py | super() modernization |
| tests/L0/run_mlp/test_mlp.py | Ruff import ordering |
| tests/L0/run_fused_layer_norm/test_fused_layer_norm.py | Ruff import ordering/combining imports |
| tests/distributed/synced_batchnorm/two_gpu_unit_test.py | Ruff import ordering + small loop simplification |
| tests/distributed/synced_batchnorm/two_gpu_test_different_batch_size.py | Ruff import ordering + f-string |
| tests/distributed/synced_batchnorm/test_groups.py | Ruff import ordering |
| tests/distributed/synced_batchnorm/test_batchnorm1d.py | Ruff adds blank line |
| tests/distributed/synced_batchnorm/single_gpu_unit_test.py | Ruff import ordering + blank line |
| tests/distributed/synced_batchnorm/python_single_gpu_unit_test.py | Ruff import ordering |
| tests/distributed/DDP/ddp_race_condition_test.py | Ruff import ordering + super() + f-strings |
| tests/distributed/amp_master_params/amp_master_params.py | Ruff import ordering + f-strings |
| setup.py | Ruff import ordering + f-strings |
| examples/simple/distributed/distributed_data_parallel.py | Ruff import ordering |
| examples/imagenet/main_amp.py | Ruff import ordering + f-strings + class syntax modernization |
| examples/dcgan/main_amp.py | Ruff import ordering + super() modernization |
| docs/source/conf.py | Ruff whitespace/import ordering |
| apex/optimizers/fused_sgd.py | f-strings + super() modernization |
| apex/optimizers/fused_novograd.py | whitespace + super() modernization |
| apex/optimizers/fused_mixed_precision_lamb.py | import ordering + super() + generator expression tweak |
| apex/optimizers/fused_lamb.py | whitespace + super() modernization |
| apex/optimizers/fused_adam.py | whitespace + super() modernization |
| apex/optimizers/fused_adagrad.py | whitespace + super() modernization |
| apex/optimizers/init.py | reorder exported imports |
| apex/normalization/fused_layer_norm.py | import ordering + typing syntax updates |
| apex/normalization/init.py | reorder exported symbols |
| apex/multi_tensor_apply/multi_tensor_apply.py | class syntax modernization |
| apex/mlp/mlp.py | import ordering + f-strings |
| apex/fused_dense/fused_dense.py | import ordering + super() modernization |
| apex/distributed_testing/distributed_test_base.py | import ordering |
| apex/contrib/xentropy/softmax_xentropy.py | whitespace cleanup |
| apex/contrib/xentropy/init.py | whitespace cleanup |
| apex/contrib/transducer/transducer.py | import ordering + super() modernization |
| apex/contrib/transducer/init.py | combine imports |
| apex/contrib/torchsched/passes/pre_grad_passes.py | combine TYPE_CHECKING imports |
| apex/contrib/torchsched/ops/layer_norm.py | remove slice spacing + drop noqa |
| apex/contrib/torchsched/inductor/wrapper.py | reformat multi-imports + import style |
| apex/contrib/torchsched/inductor/scheduler.py | reformat multi-imports + combine imports |
| apex/contrib/torchsched/inductor/graph.py | reformat multi-imports |
| apex/contrib/torchsched/inductor/event.py | reformat imports |
| apex/contrib/torchsched/config.py | remove noqa on import |
| apex/contrib/torchsched/backend.py | combine typing imports + import style |
| apex/contrib/torchsched/init.py | combine imports |
| apex/contrib/test/xentropy/test_label_smoothing.py | import ordering + f-strings |
| apex/contrib/test/peer_memory/test_peer_halo_exchange_module.py | reorder imported names |
| apex/contrib/test/optimizers/test_distributed_fused_lamb.py | import ordering + super() |
| apex/contrib/test/optimizers/test_dist_adam.py | typing syntax updates + import ordering |
| apex/contrib/test/openfold_triton/test_sync_triton_auto_tune_cache_across_gpus.py | import ordering |
| apex/contrib/test/openfold_triton/test_openfold_mha.py | typing syntax update + import ordering |
| apex/contrib/test/openfold_triton/test_fused_adam_swa.py | import ordering + super() |
| apex/contrib/test/layer_norm/test_fast_layer_norm.py | import ordering + f-strings |
| apex/contrib/test/group_norm/test_group_norm.py | import ordering + consolidate imports |
| apex/contrib/test/fused_dense/test_fused_dense.py | import ordering |
| apex/contrib/test/cudnn_gbn/test_cudnn_gbn_with_two_gpus.py | typing syntax update + import ordering |
| apex/contrib/test/conv_bias_relu/test_conv_bias_relu.py | reorder imports + f-strings |
| apex/contrib/test/bottleneck/test_bottleneck_module.py | combine imports |
| apex/contrib/sparsity/test/toy_problem.py | import ordering |
| apex/contrib/sparsity/test/test_permutation_application.py | whitespace + small dict-membership simplification |
| apex/contrib/sparsity/test/checkpointing_test_reference.py | import ordering |
| apex/contrib/sparsity/test/checkpointing_test_part2.py | import ordering |
| apex/contrib/sparsity/test/checkpointing_test_part1.py | import ordering |
| apex/contrib/sparsity/sparse_masklib.py | import ordering |
| apex/contrib/sparsity/permutation_tests/permutation_test.py | import ordering |
| apex/contrib/sparsity/permutation_search_kernels/permutation_utilities.py | import ordering + loop simplification |
| apex/contrib/sparsity/permutation_search_kernels/exhaustive_search.py | small arithmetic simplification + loop/variable cleanup |
| apex/contrib/sparsity/permutation_search_kernels/call_permutation_search_kernels.py | import ordering + f-strings |
| apex/contrib/sparsity/permutation_lib.py | import ordering + f-strings |
| apex/contrib/sparsity/asp.py | import ordering + f-strings |
| apex/contrib/sparsity/init.py | reorder exports |
| apex/contrib/peer_memory/peer_memory.py | import ordering + class syntax modernization |
| apex/contrib/peer_memory/peer_halo_exchanger_1d.py | import ordering |
| apex/contrib/peer_memory/init.py | reorder exports |
| apex/contrib/optimizers/fused_sgd.py | whitespace + f-strings + super() + simplify branching |
| apex/contrib/optimizers/fused_lamb.py | import ordering + super() modernization |
| apex/contrib/optimizers/fused_adam.py | import ordering + super() + simplify branching |
| apex/contrib/optimizers/fp16_optimizer.py | class syntax modernization + remove redundant return |
| apex/contrib/optimizers/distributed_fused_lamb.py | import ordering + class syntax modernization + small max/min tweak |
| apex/contrib/optimizers/distributed_fused_adam.py | import ordering + typing syntax updates + small simplifications |
| apex/contrib/openfold_triton/mha.py | typing syntax updates + small control-flow consolidation |
| apex/contrib/openfold_triton/fused_adam_swa.py | typing syntax updates + import ordering |
| apex/contrib/openfold_triton/_mha_kernel.py | range simplification |
| apex/contrib/openfold_triton/_layer_norm_forward_kernels.py | import ordering |
| apex/contrib/openfold_triton/init.py | reorder exports + typing syntax updates |
| apex/contrib/nccl_allocator/nccl_allocator.py | import ordering + reorder __all__ |
| apex/contrib/layer_norm/layer_norm.py | import ordering |
| apex/contrib/index_mul_2d/index_mul_2d.py | import ordering + whitespace cleanup |
| apex/contrib/groupbn/batch_norm.py | import ordering + super() modernization |
| apex/contrib/groupbn/init.py | import ordering + whitespace |
| apex/contrib/group_norm/group_norm.py | import ordering + switch to torch.nn.init import |
| apex/contrib/focal_loss/focal_loss.py | import ordering |
| apex/contrib/focal_loss/init.py | import ordering + whitespace |
| apex/contrib/examples/nccl_allocator/toy_ddp.py | import ordering + super() modernization + import style |
| apex/contrib/examples/nccl_allocator/change_cuda_allocator.py | import style + whitespace |
| apex/contrib/examples/nccl_allocator/cache.py | import style + whitespace |
| apex/contrib/examples/nccl_allocator/allreduce.py | import style + whitespace |
| apex/contrib/examples/gpu_direct_storage/example_save.py | import ordering |
| apex/contrib/examples/gpu_direct_storage/example_load.py | import ordering |
| apex/contrib/examples/gpu_direct_storage/benchmark_save.py | import ordering + whitespace |
| apex/contrib/examples/gpu_direct_storage/benchmark_load.py | import ordering + whitespace |
| apex/contrib/cudnn_gbn/batch_norm.py | import ordering + super() modernization + f-string |
| apex/contrib/csrc/group_norm_v2/generate_gn_cuda_inst.py | whitespace cleanup |
| apex/contrib/conv_bias_relu/conv_bias_relu.py | import ordering |
| apex/contrib/conv_bias_relu/init.py | reorder exports |
| apex/contrib/clip_grad/clip_grad.py | import style + whitespace |
| apex/contrib/bottleneck/test.py | f-strings |
| apex/contrib/bottleneck/halo_exchangers.py | import ordering + class syntax modernization + super() |
| apex/contrib/bottleneck/bottleneck.py | import ordering + super() + remove redundant return |
| apex/contrib/bottleneck/init.py | reorder exports |
| apex/_autocast_utils.py | typing syntax update (and logic change in helper) |
| apex/init.py | import/order cleanup + reorder __all__ |
| .pre-commit-config.yaml | bump ruff-pre-commit rev to v0.16.1 |
Suppressed comments (1)
apex/_autocast_utils.py:19
_get_current_dtypecurrently returnstorch.float or dtype, which will always evaluate totorch.float(becausetorch.floatis truthy) and ignores the caller-provideddtype. Also, thetorch.dtype | Noneannotation will raise at import time on Python <3.10 unless annotations are postponed, so usingOptional[...]here avoids a runtime compatibility pitfall.
def _get_current_dtype(dtype: torch.dtype | None = None) -> torch.dtype:
if not torch.is_autocast_enabled():
return torch.float or dtype
else:
return torch.get_autocast_gpu_dtype()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+84
to
+87
| normalized_shape: list[int], | ||
| eps: float, | ||
| memory_efficient: bool = False, | ||
| ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]: | ||
| ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]: |
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.
updates: