Skip to content

Commit

Permalink
Use alibi
Browse files Browse the repository at this point in the history
  • Loading branch information
irenedea committed Oct 12, 2023
1 parent 11b86e4 commit e433530
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tests/test_mpt_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def forward(

@pytest.mark.world_size(2)
@pytest.mark.gpu
@pytest.mark.parametrize('attn_impl', ['triton', 'torch'])
@pytest.mark.parametrize('use_alibi', [True, False])
@patch('llmfoundry.models.mpt.modeling_mpt.MPTForCausalLM', new=MockMPTForCausalLM)
def test_mpt_generate_multi_gpu():
def test_mpt_generate_multi_gpu(attn_impl: str, use_alibi: bool):
"""Tests mpt generation with mutiple gpus.
and generations of different lengths.
Expand All @@ -58,14 +60,17 @@ def test_mpt_generate_multi_gpu():

model_config = DictConfig({
'name': 'mpt_causal_lm',
'config_overrides': {
'd_model': 128,
'n_heads': 4,
'n_layers': 2,
'expansion_ratio': 2,
'no_bias': False,
'use_cache': False
}
'd_model': 128,
'n_heads': 4,
'n_layers': 2,
'expansion_ratio': 2,
'no_bias': False,
'use_cache': True,
'attn_config': {
'attn_impl': attn_impl,
'attn_uses_sequence_id': True,
'alibi': use_alibi
},
})

# build tokenizer
Expand All @@ -78,8 +83,7 @@ def test_mpt_generate_multi_gpu():

model.model = FSDP(model.model)

with get_precision_context('amp_bf16' if composer_device.name ==
'gpu' else 'fp32'):
with get_precision_context('amp_bf16'):
_ = model.generate(composer_device.tensor_to_device(
tokenizer('hello', return_tensors='pt')['input_ids']),
max_new_tokens=3,
Expand Down

0 comments on commit e433530

Please sign in to comment.