Skip to content

[tests] Remove redundant test snapshots and clarify review guidance - #5786

Merged
acisseJZhong merged 7 commits into
mainfrom
codex/test-value-cleanup
Nov 4, 2026
Merged

acisseJZhong merged 7 commits into
mainfrom
codex/test-value-cleanup

Conversation

@acisseJZhong

@acisseJZhong acisseJZhong commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Why

Reduce test maintenance by removing redundant coverage and checks that unnecessarily lock in implementation details, while preserving meaningful regression tests.

What changed

  • Remove 65 test functions: 43 core CPU, 11 core GPU, 8 RL CPU, and 3 experiment tests. Parameterized functions are counted once; this is not a count of expanded pytest cases. The complete inventory and per-test reasons are below.
  • Remove one redundant 8-GPU features integration entry, 3d, and its now-unused config factory. Keep pp_dp_tp, which runs the same training configuration with checkpoint save/load.
  • Extend the existing .claude/rules/tests.md guidance to reject private-layout snapshots and assertions that only repeat mock calls, and require naming retained coverage before deleting a redundant test. The PR-review skill already references this rule file.
  • Mechanically move four fused-SwiGLU checkpoint/adapter tests from the GPU suite to tests/unit_tests/cpu/recipes/test_fused_swiglu.py; retain the two accelerator forward-parity tests in the GPU suite. Test bodies and decorators are unchanged. Existing CI discovers both directories, so no workflow edit is needed.
  • Mechanically remove imports, helpers, empty classes and section banners left unused by deleted tests. Retained test function bodies and decorators are unchanged (AST comparison against 8e3da8b50b).

Production code, recipes, numerical goldens and CI workflow files are unchanged. In particular, these semantic RL guards remain:

  • tests/rl/unit_tests/cpu/test_rl_dist_moe_recipe.py::test_rl_integration_recipe_runs_dist_moe_on_both_roles
  • tests/rl/unit_tests/cpu/test_model_defaults.py::test_rl_recipes_get_model_defaults (LM-head precision and frozen routing across recipes)

The B200 integration and CPU RL workflows still invoke those checks. Compiler-lowering checks, model/dataset geometry checks, numerical/gradient comparisons and real-collective coverage also remain. The MoE backend-selection, Qwen 27B full-rematerialization, DAPO thinking-mode, 671B precision/fusion, dataset absolute-path and Generator finalizer and profiler output-directory guards are retained.

The four moved tests are retained and are not included in the deletion count:

  • TestFusedSwiGLU.test_saves_native_layout_without_copy
  • TestFusedSwiGLU.test_fused_roundtrip
  • TestFusedSwiGLUDistGemmComposition.test_overlapping_variant_keeps_w13_checkpoint_layout
  • TestFusedSwiGLUHFAdapter.test_hf_adapter_roundtrip

Deleted tests and reasons

Each entry explains why the test is being removed. References to existing coverage identify retained tests.

Core CPU: 43 test functions

tests/unit_tests/cpu/components/checkpointer/test_checkpoint.py

  • TestCheckpointManager.test_checkpointer_package_import_path: Remove because retained fresh-process checks exercise the public CheckpointManager import, and retained ModelWrapper/optimizer tests use the public exports. The extra assertion fixes re-export identity with the implementation modules; it does not exercise additional checkpoint behavior.
  • TestCheckpointManager.test_legacy_import_path: Remove because the public CheckpointManager import is covered by retained fresh-process tests and public ModelWrapper is exercised by state-dict and export tests. This test adds only exact identity with their implementation-module classes.
  • TestCheckpointManager.test_trainer_uses_optional_checkpointer_interface: Remove because ConfigLoader does not use this annotation to parse configuration, and in-repo recipes explicitly select their checkpointer. The exact DCP type/default snapshot does not exercise the runtime None/build branches.
  • TestConfigPostInit.test_legacy_config_only_adds_dcp_specific_fields: Remove because it fixes which fields are declared locally on a subclass; redeclaring an inherited field unchanged would fail it. Retained config validation and save/load tests check the effective configuration.
  • TestSharedDiscoveryAndRetention.test_bodies_are_defined_on_the_base: Remove because moving methods between base and derived classes need not change their results; the retained TestSharedDiscoveryAndRetention cases check discovery and retention decisions directly.
  • TestShouldPurge.test_defined_on_the_base_not_the_dcp_manager: Remove because method ownership is not the purge contract; the remaining TestShouldPurge cases check rank, retention and folder conditions regardless of where the method lives.

tests/unit_tests/cpu/components/checkpointer/test_state_dict_keys.py

  • TestStateDictKeys.test_model_structure_anchors: Remove because fixed debug-model parameter names add no checkpoint roundtrip coverage. Retained tests compare every actual parameter key and optimizer-state value, allowing supported native-layout changes.

tests/unit_tests/cpu/components/checkpointer/test_torch_checkpointing.py

  • TorchCheckpointingManagerTest.test_config_adds_no_checkpoint_options: Remove because valid backend-specific options would fail an exact match with the base field set; serialization and backend-configuration behavior have separate retained tests.
  • TorchCheckpointingManagerTest.test_legacy_config_has_no_backend_selector: Remove because absence of two old attribute names does not establish correct backend selection. Retained test_config_builds_independent_manager and save/load tests check which manager actually runs.

tests/unit_tests/cpu/components/data/test_grain_data.py

  • test_hf_lineage_fields_are_serialized: Remove because both sources use the unchanged generic serializer: nested-config serialization tests cover that mechanism, and test_hf_explicit_fields_are_passed_to_load_dataset checks all four HF fields for both sources.

tests/unit_tests/cpu/components/data/test_mm_dataset_preprocessing.py

  • TestProcessMmSampleTemporalPatchSize.test_process_mm_sample_forwards_configured_temporal_patch_size: Remove because correct preprocessing may inline or replace this helper; test_image_placeholders_match_across_temporal_patch_sizes checks the resulting placeholders without requiring that call structure.

tests/unit_tests/cpu/components/data/test_qwen_multimodal_data.py

  • test_multimodal_registry_does_not_enable_packing: Remove because test_qwen_recipe_geometry_matches_dataset_processor already reads every registered processor, including cc12m, and catches an incompatible packing wrapper. Requiring one concrete config class adds no independent usable-registry check.

tests/unit_tests/cpu/components/optim/test_lr_scheduler.py

  • TestLRScheduler.test_optimizer_package_import_path: Remove because retained mixed-optimizer scheduler tests import LRSchedulersContainer from the public package, build it and verify learning-rate behavior; fresh-process tests cover its import order. The extra assertion only fixes identity with the leaf-module class.

tests/unit_tests/cpu/components/optim/test_optimizer_param_groups.py

  • TestOptimizersContainerWithParamGroups.test_build_optimizer_default_groups: Remove because TestOptimizerConfig.test_catch_all_optimizer already checks the same group count plus parameter selection and hyperparameters, so this weaker case adds no coverage.

tests/unit_tests/cpu/components/test_renderer.py

  • test_from_renderers_returns_adapter: Remove because test_custom_renderer_builds_the_same_renderer_from_its_serialized_config calls the factory and uses its result; an additional wrapper-type/input-identity assertion unnecessarily fixes its representation.

tests/unit_tests/cpu/config/test_parallelism_config.py

  • test_parallelism_config_default_load_balancer: Remove because a different valid default load balancer should not fail a None-value snapshot; TestDecoderCpSharding checks configured balancing and metadata handling.
  • test_parallelism_config_default_schedule: Remove because selecting another supported default schedule is legitimate; retained schedule-validation tests and pipeline integrations cover supported choices without fixing the default string.
  • test_parallelism_config_disables_fsdp_symm_mem_by_default: Remove because enabling this CUDA-only option by default already breaks retained CPU config construction. test_enable_fsdp_symm_mem_scope also checks that scope=None leaves symmetric communication disabled.
  • test_parallelism_config_rejects_unknown_schedule_when_pp_disabled: Remove because test_parallelism_config_rejects_invalid_schedule already rejects invalid schedules with the default PP=1, making this another copy of the same case.

tests/unit_tests/cpu/config/test_transforms.py

  • TestPublicApi.test_relation_graph_is_not_caller_configurable: Remove because adding a valid optional argument need not change transform behavior; ordering and composition tests should determine correctness, not the permanent absence of a parameter name.

tests/unit_tests/cpu/models/common/test_cp_attention.py

  • TestCpGroup.test_cp_attention_holds_no_mesh_state: Remove because it checks only that CPInnerAttention.dict lacks the name cp_group; it cannot detect group state stored on an instance or under another name. Retained mesh-lookup and no-active-group tests check observable group behavior.
  • TestUlysses.test_is_still_a_flex_kernel: Remove because the retained Ulysses redistribution test builds the same concrete kernel and executes its Flex-dispatch path; this additional config-inheritance check adds no numerical or dispatch coverage.
  • TestUlysses.test_shared_base_is_a_cp_attention: Remove because test_ptrr_prefers_ulysses_full_metadata reaches Decoder._cp_shard, which requires the selected Ulysses kernel to implement CPInnerAttention. That retained consumer check guards the CP capability; redistribution alone would not establish it.
  • TestUlyssesVarlen.test_is_still_a_varlen_kernel: Remove because test_dispatches_to_varlen_inner_attention executes the concrete Ulysses Varlen wrapper and checks its exact backend call and metadata. The additional config-inheritance assertions are weaker than that dispatch check.

tests/unit_tests/cpu/models/flux/test_flux_mxfp8_readme.py

  • test_flux_mxfp8_readme_custom_example_uses_converters: Remove because harmless documentation rewrites can fail its string checks, while an invalid Python example can still pass. It neither executes the example nor verifies converter behavior.

tests/unit_tests/cpu/observability/test_profiler.py

  • TestProfilerConfig.test_build_returns_profiler_instance: Remove because Configurable tests already cover the inherited build mechanism, while enabled-profiler tests check actual handles; a separate owner-type assertion adds no profiler-specific behavior.
  • TestProfilerConfig.test_custom_field_values: Remove because it sets dataclass fields and reads the same values without using the profiler. Retained tests exercise enabled handles and memory-frequency selection; the removed assertions do not check schedule-option forwarding.
  • TestProfilerDisabledPaths.test_build_memory_profiler_disabled_returns_none: Remove because test_context_manager_step_is_noop already enters the disabled path, checks both handles are None and calls step, covering this weaker assertion.
  • TestProfilerDisabledPaths.test_build_torch_profiler_disabled_returns_none: Remove because test_context_manager_step_is_noop already checks the disabled torch-profiler handle while exercising context entry and stepping.
  • TestProfilerDisabledPaths.test_default_args_context_manager: Remove because test_context_manager_step_is_noop executes the same context-manager path and adds handle/identity assertions.
  • TestProfilerDisabledPaths.test_exit_resets_profiler_attrs: Remove because both handles start as None, so a broken cleanup implementation could still pass; the disabled context path is already covered.
  • TestProfilerDisabledPaths.test_step_noop_when_both_profilers_none: Remove because test_context_manager_step_is_noop already calls step twice with both profilers disabled.
  • TestProfilerInit.test_default_runtime_attrs: Remove because test_active_updates_runtime_args already asserts the initial step and folder values, while the default-context test checks usable disabled handles. Production starts the profiler by building and immediately entering it, so this additional pre-entry field snapshot adds no exercised caller behavior.

tests/unit_tests/cpu/observability/test_structured_logging.py

  • TestStepTags.test_step_tags_are_tuples: Remove because the retained add-tag and multiple-tag tests already assert exact tuple results, and the concurrent-task test checks isolation. A shared mutable list would fail those existing assertions.

tests/unit_tests/cpu/recipes/test_debug_config_defaults.py

  • test_debug_config_default_seq_len: Remove the duplicated list of debug-factory signature defaults. It does not construct a model or enforce a resource bound, and changing the shared constant would pass every assertion.
  • test_graph_trainer_debug_config_default_seq_len: Remove because it requires every graph recipe to repeat the shared debug-length constant; it neither imposes a context limit nor exercises training, and valid per-model defaults would fail it.

tests/unit_tests/cpu/recipes/test_inference_moe.py

  • TestInferenceMoEComposition.test_grouped_linears_and_dispatcher_are_siblings: Remove because this case rechecks grouped projections created by its own fixture and the dispatcher class explicitly passed to the transform. Retained composition tests execute that transform and verify the fused activation and generator/trainer dispatch modes.

tests/unit_tests/cpu/test_gc_freq.py

  • test_training_engine_owns_garbage_collector_defaults: Remove because it snapshots GC field ownership and the default interval rather than running collection. Retained tests validate frequencies, build the collector and verify debug collection and freeze behavior.

tests/unit_tests/cpu/test_integration_test_definitions.py

  • test_b200_tests_are_registered_in_separate_suite: Remove the exact suite-name inventory: adding a valid B200 case fails it, while changing a case to the wrong backend can still pass. The actual B200 jobs remain; this deletion stops pinning the complete name list.
  • test_flux_fake_pg_filters_real_collective_cases: Remove because the runner rejects fake-PG checkpoint jobs, which covers the current Flux entry; requiring every future Flux case to stay outside fake PG is broader than that constraint.
  • test_h100_tests_are_registered_in_separate_suite: Remove the exact suite-name inventory and obsolete-attribute checklist. They pin registration layout without verifying the advertised backends; the H100 jobs and their backend-specific execution remain.
  • test_llama3_debug_config_defaults_to_short_context: Remove because integration recipes explicitly select their context lengths; this additional 2048 snapshot checks no model output or resource bound.
  • test_llama3_pp_numerics_has_one_microbatch_per_stage: Remove because the retained models-suite PP numerical job uses this exact recipe, and Schedule1F1B rejects fewer microbatches than stages. The standalone inequality adds no extra validity check.
Core GPU: 11 test functions

tests/unit_tests/gpu/models/common/test_async_linear.py

  • TestAsyncTensorParallelConfig.test_projection_boundaries_survive_lora_config_wrappers: Remove because retained CPU LoRA tests check adapter redistribution and execute a real TP forward/backward with and without sequence parallelism. This extra case applies only LoRA and snapshots outer None fields; it does not exercise async TP or additional communication.
  • TestAsyncTensorParallelConfig.test_sharding_setup_declares_common_communication_contracts: Remove because the enabled dist_gemm integration builds and parallelizes the actual async recipe, while CPU transform tests assert the selected Async projection types. The removed None-field checklist is not a collective count; equal-layout metadata emits no collective.
  • TestAsyncTensorParallelSharding.test_parallelize_keeps_async_collectives_in_projection_leaves: Remove because the enabled H100 dist_gemm job uses this exact recipe and real parallelization. The old test only pins metadata to None and would still pass if the recipe selected synchronous projections; CPU transform tests separately guard Async type selection.
  • TestAsyncTensorParallelSharding.test_w13_tp_shards_the_matrix_row_dimension: Remove because test_stacked_w13_typechecks builds the same FFN, runs real _parallelize, and executes forward/backward on its two-rank CPU fallback. The retained GPU numerical test additionally checks exact weight-gradient slices when explicitly run on two GPUs.

tests/unit_tests/gpu/models/kimi_k3/test_kimi_k3.py

  • TestKimiK3.test_varlen_config_uses_mla_backend: Remove because retained CPU builder tests require Kimi MLA/default Varlen, and test_flex_attention_mask builds the explicit Flex branch and requires actual BlockMask metadata. These checks exercise both backend selections without another config-only permutation.

tests/unit_tests/gpu/recipes/test_fused_swiglu.py

  • TestFusedSwiGLU.test_gate_up_projection_is_linear: Remove because the fixture itself selects Linear.Config, while retained state-dict tests already build the expected physical W13 shape and check both parameter keys and storage aliasing. The extra projection-class assertion adds no fused-activation behavior.
  • TestFusedSwiGLU.test_preserves_converted_linear_config: Remove because fused_swiglu receives only the activation config and cannot replace the sibling projection. The test explicitly installs its converted Linear config itself, so it does not exercise a converter-preservation path.
  • TestFusedSwiGLU.test_replaces_only_activation: Remove because test_hf_adapter_roundtrip invokes the same factory, builds the model, and explicitly asserts FusedSwiGLU before checking checkpoint conversion; this standalone return-type assertion is duplicated.
  • TestFusedSwiGLU.test_strict_load_reports_missing: Remove because missing-key rejection comes from inherited PyTorch load_state_dict; neither the FFN nor fused activation implements special loading. Retained tests cover the TorchTitan-specific native/fused checkpoint layout.
  • TestFusedSwiGLUDistGemmComposition.test_dist_gemm_config_keeps_overlap: Remove because CPU transform tests already require AsyncColumn/Row configs, and the HF-adapter test checks the fused activation type. The activation factory cannot modify sibling projections; the extra combination adds no independent conversion path.

tests/unit_tests/gpu/recipes/test_fused_swiglu_override.py

  • TestFusedSwiGLUOverride.test_swiglu_config_is_replaced: Remove because test_hf_adapter_roundtrip invokes the same factory, builds the model, and explicitly asserts FusedSwiGLU before checking checkpoint conversion; this standalone return-type assertion is duplicated.
RL CPU: 8 test functions

tests/rl/unit_tests/cpu/test_bin_scheduler.py

  • test_greedy_can_have_a_higher_maximum_than_zigzag: Remove because it requires a known worse partition and would reject a balancing improvement; test_three_pp_microbatches_balance_accumulated_cost retains the useful balancing check.

tests/rl/unit_tests/cpu/test_generator.py

  • test_generator_defaults_to_the_vllm_engine: Remove because retained recipe-construction and RL integration tests already require a usable default engine. The class-identity snapshot adds no independent execution check.
  • test_vllm_uneven_decode_tp_padding: Remove the CPU-suite copy: the same token-count and finite-logprob assertions remain in the GPU suite, with an explicit four-GPU workflow launch.

tests/rl/unit_tests/cpu/test_metrics.py

  • TestMetricsProcessorBuild.test_console_log_keys_round_trip: Remove because TestIsValidationSwitch checks actual console selection from both allow lists, while test_default_builds_no_backends already covers the empty-backend assertion.
  • test_metric_backend_is_base_logger: Remove the alias-identity assertion; TestMetricsProcessorFanOut retains observable dispatch and failure-isolation checks without fixing the backend to one class object.

tests/rl/unit_tests/cpu/test_trainer.py

  • test_rl_trainer_accepts_core_sdc_replay_config: Remove because it only assigns a replay config and reads back its type; it cannot detect whether the RL trainer ever runs replay for that model/debug/graph combination.
  • test_rl_trainer_uses_training_engine_config_defaults: Remove because it repeats TrainingEngine's inherited boolean default using a mock model; RL supplies no separate defaulting behavior. The test does not exercise graph capture.
  • test_trainer_has_thin_actor_adapter: Remove the inheritance-tree checklist; retained forward/backward, state-restoration and close tests check contracts that remain meaningful across equivalent implementations.
Experiments: 3 test functions

torchtitan/experiments/graph_trainer/tests/test_autoparallel.py

  • test_autoparallel_integration_matrix: Remove because it fixes only two job names and GPU counts and passes while both jobs are disabled. Retained pass/policy tests inspect AutoParallel behavior; this list snapshot does not establish execution.

torchtitan/experiments/graph_trainer/tests/test_chunked_loss.py

  • TestChunkedLossWrapperWithParamGrads.test_config_builds_param_grads_loss: Remove because the enabled dense-Llama GraphTrainer numerical test loads the real recipe, builds its specialized chunked loss, binds lm_head, and computes explicit parameter gradients before comparing 20 training steps. A Config owner falling back to the base wrapper fails that execution path.

torchtitan/experiments/torchft/tests/test_torchft_trainer.py

  • test_ft_trainer_composes_specialized_training_engine: Remove because test_ft_applies_ffn_lora_override_before_model_build enters the real FaultTolerantTrainer-to-engine initialization path, while retained tests check the FT all-reduce hook and replica-loss behavior. The two inheritance assertions add no engine-selection check.

Integration task (8 GPUs)

  • features / 3d in tests/integration_tests/features.py: remove because pp_dp_tp runs the same FSDP=2/TP=2/PP=2 training configuration and additionally checks save/resume; another 8-GPU run adds no distinct coverage. Its unused factory llama3_debugmodel_fsdp2_tp2_pp2 is also removed.

Numerics / performance

This change removes redundant test definitions, moves CPU-runnable tests, and updates test guidance; it does not modify a training implementation or numerical golden. Retained GPU forward/backward and checkpoint parity tests were exercised as described below. No before/after training-loss comparison, full integration matrix or end-to-end performance measurement was run. No measured runtime saving is claimed.

Testing

Scope Result
Review feedback: moved fused-SwiGLU CPU tests plus RL metrics 81 passed with CUDA hidden, including all four moved tests
Review feedback: remaining fused-SwiGLU accelerator tests 2 passed on one H100
Rebase onto main 8e3da8b50b: conflict-related CPU tests 169 passed
Rebased fused-SwiGLU GPU tests 5 passed on one H100; the initial CUDA-hidden run could not initialize CUDA, so the file was rerun with a visible GPU
Current review: restored profiler default-path guard and retained profiler file 13 passed, 2 subtests passed on CPU
Temporary fault injection: change the default memory-snapshot directory The original default guard failed as expected; all 12 retained profiler tests and 2 subtests passed, confirming the coverage gap. No production file was modified
GraphTrainer chunked-loss construction probe Actual recipe Config.build plus the production gradient helper returned a nonzero parameter gradient; a process-local wrong-owner mutation was rejected. This was a small CPU probe, not the full 8-GPU comparison
Earlier re-audit: six restored guards 4 passed; the Verifiers and Dist-MoE modules skipped because their optional dependencies are unavailable
Temporary fault injection: MoE aux-loss backend changed to eager The restored CPU guard failed while the retained GPU forward/backward test still passed on H100. The mutation was process-local; production files were unchanged
Previous re-audit: restored core CPU guards 25 passed; 3 other files could not collect because installed renderers/attention-gym APIs are unavailable
Previous re-audit: restored RL guards 12 passed; 3 optional-dependency modules skipped and Search-R1 could not collect on the missing renderer API
Previous re-audit: restored graph-trainer DistMoE recipe guards 3 failed and 3 skipped because the optional dist_moe package is unavailable; the restored file is byte-identical to the base commit
Retained GPU MoE local-compile forward/backward comparison 1 passed on H100
Temporary fault injection: remove only MSE's loss-region registration The restored loss-registration guard correctly failed; the other 7 compile-config tests passed. No production file was modified
Earlier revision: affected core CPU files 521 passed, 2 skipped, 79 subtests passed; four collection errors from installed dependencies; nine socket-related setup errors in the sandbox
The nine affected CPU distributed tests, rerun outside the sandbox 9 passed (530 core CPU passes across the two runs)
Earlier revision: affected RL/experiment CPU sweep 219 passed, 14 skipped, 2 subtests passed; five failures reproduced on base commit ff96670a26
Earlier revision: four changed core GPU files on H100s 21 passed; one KDA dependency error reproduced on ff96670a26
Graph-trainer Dist-MoE registration test rerun with a visible GPU Passed; its CPU-only run cannot initialize CUDA
Final retained RL recipe guards 4 passed, 3 skipped; one Search-R1 case fails on the same unavailable CustomRendererConfig API
Retained checkpoint import/default guards 3 passed, 4 subtests passed; the two fresh-process import tests and default config construction were checked separately
Formatting/lint hooks, including the review-feedback changes SKIP=pyrefly-check pre-commit run --all-files passed; full pre-commit was attempted, but Pyrefly failed while traversing local virtualenv/dependency trees
Diff validation git diff --check; Python AST comparison verifies all retained test bodies/decorators are unchanged

Exact commands for the review-feedback changes, after activating the workspace runtime:

CUDA_VISIBLE_DEVICES='' OMP_NUM_THREADS=1 pytest tests/unit_tests/cpu/recipes/test_fused_swiglu.py tests/rl/unit_tests/cpu/test_metrics.py -q --tb=short
CUDA_VISIBLE_DEVICES=0 OMP_NUM_THREADS=1 pytest tests/unit_tests/gpu/recipes/test_fused_swiglu.py -q --tb=short
SKIP=pyrefly-check pre-commit run --all-files

Earlier representative commands:

pytest tests/unit_tests/cpu/components/checkpointer/test_checkpoint.py::TestCheckpointManagerEMAResumeFlexibility tests/unit_tests/cpu/models/common/test_cp_attention.py::TestAllGatherCollective -q --tb=short

CUDA_VISIBLE_DEVICES=0,1 OMP_NUM_THREADS=1 pytest \
  tests/unit_tests/gpu/models/common/test_async_linear.py \
  tests/unit_tests/gpu/models/kimi_k3/test_kimi_k3.py \
  tests/unit_tests/gpu/recipes/test_fused_swiglu.py \
  tests/unit_tests/gpu/recipes/test_fused_swiglu_override.py -q --tb=short

CUDA_VISIBLE_DEVICES='' OMP_NUM_THREADS=1 pytest \
  tests/rl/unit_tests/cpu/test_model_defaults.py \
  tests/rl/unit_tests/cpu/test_rl_dist_moe_recipe.py -q --tb=short

SKIP=pyrefly-check pre-commit run --all-files

Coverage limits

  • Two-GPU async parity classes lack the multi_gpu marker: current single-GPU CI skips them and multi-GPU CI deselects them. Collection with the current multi-GPU filter confirmed zero selected cases in the two relevant files. They remain available for explicit developer runs; the deletion reasons cite enabled CPU/Gloo checks and the H100 dist_gemm integration where applicable.
  • The latest review-feedback check reran both remaining fused-SwiGLU GPU tests; other GPU results above are from the earlier recorded runs. The full GPU and integration suites were not rerun.

Existing environment failures

  • The original CPU collection already failed on unavailable renderers.CustomRendererConfig and attn_gym.sparse.gather_attn APIs. These affect four files in the reduced CPU sweep.
  • In the RL/experiment sweep, two Search-R1 cases fail on CustomRendererConfig; two autoparallel cases fail because autoparallel is not installed; the Dist-MoE graph registration case needs a GPU. All five fail on ff96670a26 as well; the GPU rerun of registration passes.
  • The retained Kimi KDA numerical test fails with TypeError: l2norm() got an unexpected keyword argument 'autotune', identically on the base commit.
  • The final retained-recipe check also fails for the Search-R1 module on the same CustomRendererConfig import. That test file and the imported recipe are unchanged from the base commit. The optional dist_moe module is unavailable, so its recipe guard is skipped locally.
  • The full Pyrefly hook traverses unrelated local virtualenv/dependency trees and reports existing errors. Its automatic changes outside this PR's scope were reverted; the other pre-commit hooks pass.

@pytorch-bot pytorch-bot Bot added the ciflow/rl label Nov 3, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@acisseJZhong
acisseJZhong force-pushed the codex/test-value-cleanup branch from 9e1b76c to 9c87bbb Compare November 4, 2026 00:52
@acisseJZhong
acisseJZhong marked this pull request as ready for review November 4, 2026 00:54
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 4, 2026
@github-actions
github-actions Bot requested a review from pzhan9 November 4, 2026 00:54
@tianyu-l

tianyu-l commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@claude review

@claude

claude Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 2m 25s —— View job


Approve with two small items to fix before merging: review

@claude claude Bot 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.

Verdict: Approve -- please address the items below before merging. The deleted tests check config values, class identity, or method ownership rather than behavior, and I spot-checked several of the "still covered by" claims; they hold. The one real problem is the new review-guidance section, which repeats rules/tests.md in the wrong file.

What this PR does. It deletes 65 test functions, deletes the features / 3d 8-GPU integration entry along with its config factory, and cleans up imports and helpers left unused by those deletions. It also adds a "Deciding Whether a PR Needs Tests" section to the pr-review skill. No production code, recipe, golden file, or CI workflow is changed.

Example. The integration deletion, in tests/integration_tests/features.py:

before: "3d"       -> llama3_debugmodel_fsdp2_tp2_pp2              (FSDP2 x TP2 x PP2, 8 microbatches, 8 GPUs)
        "pp_dp_tp" -> llama3_debugmodel_fsdp2_tp2_pp2_{save,load}  (same parallelism, + checkpoint every 10 steps, resume to step 20)
after:  only "pp_dp_tp"

I checked that _save sets the same degrees, microbatch count, token count, and type-checking setting as the removed factory; the only additions are the checkpointer and the resume step. So no parallelism combination loses coverage. The same is true for test_vllm_uneven_decode_tp_padding: a copy remains at tests/rl/unit_tests/gpu/test_generator_uneven_decode.py, and unit_test_gpu_rl.yaml runs it.

Must fix

  1. .claude/skills/pr-review/SKILL.md:106-120 -- the new section repeats rules/tests.md, review-checklist.md section 6, and CLAUDE.md PR Expectation 4. It is also in a file that authors never load. Delete it and move the ~2 genuinely new bullets into rules/tests.md.
  2. tests/rl/unit_tests/cpu/test_metrics.py:540-542 -- the # Backend identity section banner is left empty after the deletion; remove it.

Should consider

  • tests/unit_tests/gpu/recipes/test_fused_swiglu.py:10 -- the remaining tests in this file look CPU-runnable but sit in the GPU suite, so they use GPU runner time. Consider moving them to tests/unit_tests/cpu/recipes/.
Details
  • Gate: the problem is real (tests that pin config defaults, isinstance/issubclass results, vars(cls) membership, or README strings, and that fail on valid refactors). Tests are the right layer, and I found no overlapping open PR. The net change is -970 LoC.
  • Claims I verified at HEAD:
    • test_context_manager_step_is_noop checks that both profiler handles are None and calls step() twice, which covers the five disabled-path profiler tests that were deleted.
    • Every debug recipe factory takes its seq_len default from DEFAULT_DEBUG_MODEL_SEQ_LEN rather than a literal, so the deleted test_debug_config_defaults.py could only catch someone hard-coding a different value in one factory. That is low value.
  • One borderline deletion: test_parallelism_config_default_schedule / _default_load_balancer are default snapshots. That is consistent with the rest of the PR, but note that TestProfilerConfig.test_default_field_values (also a default snapshot) is deliberately kept as the output-path guard. The description explains why, which is enough.

Not verified: the GPU and integration suites were not rerun here. I also did not check that each deleted test's import cleanup leaves no unused or missing imports; lint covers that.

Comment thread .claude/skills/pr-review/SKILL.md Outdated
Comment on lines +106 to +120
## Deciding Whether a PR Needs Tests

When authoring or reviewing a PR, do not add a test automatically for every fix.

- **Identify the gap.** Name the behavior existing tests miss; cite existing
coverage when it is sufficient.
- **Extend before adding.** Prefer an existing test or integration configuration
over another fixture, file, or model/flag permutation.
- **Check behavior independently.** Avoid config echoes, source/README greps,
private-layout snapshots, and assertions that only repeat mock calls.
- **Keep meaningful regressions.** A specific combination can protect numerics,
gradients, checkpoints, collectives, or demonstrated performance requirements.
Delete redundant cases only after identifying the coverage that remains.
- **Control cost.** Use the smallest necessary hardware, put GPU tests in the GPU
suite, and report what actually ran and what was skipped.

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.

This section mostly repeats guidance that already exists in three places: .claude/rules/tests.md ("When to Add a Test", "Prefer Extending Existing Coverage", cheapest hardware, "Verify that the intended test actually ran"), review-checklist.md section 6, and CLAUDE.md PR Expectation 4. It also says "When authoring or reviewing", but authors never load the pr-review skill, so the authoring half doesn't reach them from here. Keeping four copies means they will drift apart.

Smallest fix: delete this section. Put the few points that are actually new into .claude/rules/tests.md, which applies to both authors and reviewers by glob. I count about 2 bullets of new content:

  • under "When to Add a Test", add "no private-layout snapshots, and no assertions that only repeat mock calls";
  • under "Prefer Extending Existing Coverage", add "delete a redundant test only after naming the retained test that covers it".

This also keeps the PR to one concern (test cleanup) plus a rule tweak that directly backs it.

Comment thread tests/rl/unit_tests/cpu/test_metrics.py Outdated
@@ -542,10 +542,6 @@ def test_fmt_metric_value(value, expected) -> None:
# ---------------------------------------------------------------------------

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.

After test_metric_backend_is_base_logger is removed, the # Backend identity banner (lines 540-542) has nothing under it, so it is followed directly by the MetricsProcessor fan-out + build banner. Please delete the three banner lines and the blank lines after them.

@@ -9,24 +9,18 @@
The override replaces ``DenseFeedForward.activation_fn`` while preserving the module
and its physical ``w13`` projection. These tests run on CPU unless marked CUDA.

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.

(Should consider, follow-up is fine.) The docstring says "These tests run on CPU unless marked CUDA". The remaining tests in this file (test_saves_native_layout_without_copy, test_fused_roundtrip, test_hf_adapter_roundtrip, TestFusedSwiGLUDistGemmComposition) look CPU-runnable, but they live under tests/unit_tests/gpu/, so they use GPU runner time. tests.md asks for the cheapest hardware that exercises the code. Since this PR already cleans up this file, consider moving the CPU-runnable classes to tests/unit_tests/cpu/recipes/ and keeping only the accelerator-gated ones here. Unverified that every one of them runs without a device.

@tianyu-l tianyu-l 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.

Please fix this

.claude/skills/pr-review/SKILL.md:106-120 -- the new section repeats rules/tests.md, review-checklist.md section 6, and CLAUDE.md PR Expectation 4. It is also in a file that authors never load. Delete it and move the ~2 genuinely new bullets into rules/tests.md.

and other inline comments

@acisseJZhong

Copy link
Copy Markdown
Contributor Author

@claude review latest changes

@claude

claude Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @acisseJZhong's task in 1m 15s —— View job


Approve: all three earlier review items are fixed in 1ba63a5. One item is left before merging: the empty "Summary (human-written)" section. Review

@claude claude Bot 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.

Verdict: Approve -- please address the item below before merging. Commit 1ba63a5 resolves all three items from the previous review, and it adds no new problems.

What changed since the last review. The pr-review skill section was deleted and its two new rules were moved into rules/tests.md. The empty test_metrics.py banner was removed. The four fused-SwiGLU tests that can run on CPU were moved into the CPU suite.

Example. Where each fused-SwiGLU test runs now:

before: tests/unit_tests/gpu/recipes/test_fused_swiglu.py  (GPU runner)
        test_saves_native_layout_without_copy, test_fused_roundtrip,
        TestFusedSwiGLUDistGemmComposition, TestFusedSwiGLUHFAdapter,
        test_triton_checkpoint_loads_into_native, test_native_checkpoint_loads_into_triton
after:  tests/unit_tests/cpu/recipes/test_fused_swiglu.py  (picked up by `pytest tests/unit_tests/cpu`)
        the first four, unchanged
        tests/unit_tests/gpu/recipes/test_fused_swiglu.py
        only the two tests gated by `skipUnless(_HAS_OP_DEVICE)`

Previous items

  • .claude/skills/pr-review/SKILL.md duplicate section -- resolved (tianyu-l's request). The section is deleted. rules/tests.md now says "snapshot private layouts, repeat mock calls" under "When to Add a Test" and "Delete a redundant test only after naming the retained test that covers it" under "Prefer Extending Existing Coverage", which is exactly what was asked.
  • tests/rl/unit_tests/cpu/test_metrics.py empty # Backend identity banner -- resolved.
  • CPU-runnable fused-SwiGLU tests in the GPU suite -- resolved. I compared the moved bodies against the deleted hunks: they are unchanged. The new CPU file imports triton through the override module. The CPU suite already does the same in test_fused_mla_override.py, so this adds no new dependency to the CPU suite.

Must fix

  1. PR description -- "Summary (human-written)" is still empty. Per CLAUDE.md PR Expectation 2, the author fills this in, not an agent. The earlier review missed this.

Not verified: I did not run the moved CPU tests in this job. The author reports that 81 passed with CUDA hidden.

@acisseJZhong
acisseJZhong merged commit 73c4ebd into main Nov 4, 2026
tianyu-l added a commit that referenced this pull request Nov 4, 2026
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
     this approach, and what you checked yourself. -->

## Why
The Real PG integration suite (`8 GPU Integration (Real PG - full suite
- features)`) and the ROCm integration suite have failed the `sft` loss
check on main since #5757 (`899480301`; `a87db08ea` before it passed):

```
[sft] AssertionError: 7.889825820922852 != 7.887711524963379 : loss mismatch at step 1   # A10G
[sft] AssertionError: 7.890093803405762 != 7.887524604797363 : loss mismatch at step 1   # MI350X
```

#5757 renders `bos_token`/`eos_token` in Hugging Face chat templates, an
intended change to the SFT token stream. It regenerated
`tests/assets/losses/fake_pg/a10g/sft.txt` but not the real-PG A10G and
MI350X goldens.

## What changed
- `tests/assets/losses/real_pg/a10g/sft.txt` and
`tests/assets/losses/real_pg/mi350x/sft.txt`: steps 1-10 regenerated;
headers unchanged.

## Numerics
The new values are the full-precision TensorBoard metrics of the failing
main runs' baseline training (the same values `loss_compare.py
--export-result` writes), read with `scripts/loss_compare.py`'s own
extraction from the uploaded `integration-8gpu-features-outputs`
artifacts:
- A10G: run 41746280593 (`e6ca6d861`). Step 1 matches the log's baseline
(7.889825820922852, grad_norm 4.189799785614014).
- MI350X: the ROCm run on `73c4ebdac`. Step 1 matches the log's baseline
(7.890093803405762, grad_norm 4.189815998077393).

The commits between #5757 and those runs (#5572, #5787, #5776, #5774,
#5779, #5741, #5786) do not change SFT numerics.

## Testing
- CI: Real PG (`ciflow/real-pg`) and ROCm (`ciflow/rocm`) integration
suites.
- A manual `export_results` run of the integration workflow for `sft` on
main (run 41760303504) exported a real-PG A10G golden identical to this
one.
- `Multi-GPU Unit Tests` fails here with the `_VisionEncoder ...
named_preserve_dtype_params` error that is also on main; #5795 fixes it.

This PR was AI-assisted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants