Skip to content

fix: IntruderScorer(type="internal") crashes when picking the intruder quantile - #183

Open
flyingdoubleG wants to merge 1 commit into
EleutherAI:mainfrom
flyingdoubleG:fix/intruder-internal-quantile
Open

flyingdoubleG wants to merge 1 commit into
EleutherAI:mainfrom
flyingdoubleG:fix/intruder-internal-quantile

Conversation

@flyingdoubleG

Copy link
Copy Markdown

Summary

IntruderScorer(type="internal") crashes while building its batches:

all_quantile_examples = list(quantiled_intruder_sentences.values())
all_quantile_examples.remove(all_active_examples)

list.remove compares each quantile's list with all_active_examples. Lists of the same length are compared element by element, and ActivatingExample uses the default dataclass __eq__, which compares its tokens/activations tensors and raises

RuntimeError: Boolean value of Tensor with more than one value is ambiguous

With the default sampler every quantile holds n_examples_test // n_quantiles examples, so this happens for every batch whose source quantile is not the first one. A record with 10 quantiles × 5 test examples fails on the second batch.

Change

Select the other quantiles by their key (quantile != active_quantile) instead of removing by equality.

Tests

Added test_intruder_internal_takes_intruder_from_another_quantile to tests/test_scorers/test_intruder_example_embedding.py: 3 quantiles × 2 examples. It checks that _prepare_and_batch returns one batch per non-activating example and that each intruder comes from a different quantile than its batch. It raises the error above on main and passes with this change. ruff check and black --check pass.

…r quantile

The internal intruder type removed the source quantile from the list of
quantiles with list.remove, which compares the quantile lists for
equality. Lists of the same length are compared element by element, and
ActivatingExample's dataclass __eq__ compares its tensors, which raises
'Boolean value of Tensor with more than one value is ambiguous'. With the
default sampler every quantile holds the same number of examples, so
every batch whose quantile is not the first one crashed.

Select the other quantiles by their key instead.
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.

1 participant