Repository navigation
test(calibration): cover real-model left-pad capture parity (#4861) - #4944
Merged
Merged
Conversation
…er-0 inputs (#4861) The fix for #4861 landed in #4930 and its tests drive `run_input_capture` with a recording stand-in. They pin the derived `position_ids` but never check the symptom that motivated the issue: the layer-0 inputs a real absolute-position model produces for a left-padded row. Add that regression test on a tiny GPT-2 (2 layers, hidden 32, hand-built tokenizer, CPU/fp32): capture layer-0 inputs at batch_size=1 and at batch_size=2 with padding_side="left", drop the pad slots, and require max|diff| < 1e-5. It also covers the left-padded final window of `calibration_dataset_concat_size` packing, which the collation-level fix could not reach, and the negative controls the issue asked for: right padding still matches, and OPT (which derives positions from the mask itself) is unchanged. A model whose forward has no `position_ids` and no `**kwargs` is never given the keyword, and an unpadded single row stays bit-identical with and without the mask. Before the fix this file is red (4 failed, 5 passed); on current main it is green (9 passed).
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.
Summary
Follow-up coverage for #4861, whose fix landed in #4930 (
5fb25294f). That PR's tests driverun_input_capturewith a recording stand-in and pin the derivedposition_ids, but nothing checks the symptom that motivated the issue: the layer-0 inputs a real absolute-position model produces for a left-padded calibration row. This adds that end-to-end assertion plus the negative controls the issue asked for.What Changed
tests/test_calibration_left_pad_positions_4861.py, CPU/fp32, no hub download (hand-built 2-layer, hidden-32 GPT-2 and tiny OPT, plus atokenizersWordLevel tokenizer).batch_size=1(reference) and atbatch_size=2withpadding_side="left", drop pad slots, requiremax|diff| < 1e-5.calibration_dataset_concat_sizepacking — the case a collation-only fix could not reach.forwardwith noposition_idsand no**kwargsis never given the keyword; an unpadded single row is bit-identical with and without the mask; interior zeros keep the running position.Tests
Measured with the new file (layer-0 inputs of the real tokens,
batch_size=2vsbatch_size=1):concat_size=24tailThe reporter measured
4.255e+00on row 1 of realgpt2; the fixture is smaller, so the magnitude is smaller while the shift is the same in kind.Related suite (all
tests/test_calibration*.py+tests/test_prepare_dataset.py+tests/test_generator_calibration_4307.py, same command):The two remaining failures (
test_stage_capture_balanced_mode_empty_filter_fallback,test_balanced_mode_fallback_when_input_device_not_in_forward_devicesintest_calibration_data_device.py) are pre-existing and identical without this change underCUDA_VISIBLE_DEVICES="": both calltorch.cudaand raiseRuntimeError: No CUDA GPUs are availablebefore reaching this code.Model Support / Module Plan
Not applicable: test-only change.
Logic Flow Documentation
Not applicable: no production code change.
Review Requirements
register_forward_pre_hookto read layer-0 inputs, removed in afinally).main).Kernel Accuracy Requirements
Not applicable: no kernel or fusion change.
Notes
Refs #4861. The fix itself is already merged as #4930; this PR only strengthens its regression coverage with a real-model parity check and the
concat_sizetail case.