Further reduce atol for model comparison, move python 3.11 + torch 2.2 -> python 3.12 + torch 2.4.1

This commit is contained in:
Ross Wightman 2024-10-02 10:05:27 -07:00
parent fde6719403
commit 95907e69c2
2 changed files with 9 additions and 9 deletions

View File

@ -16,11 +16,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ['3.10', '3.11']
torch: [{base: '1.13.0', vision: '0.14.0'}, {base: '2.1.0', vision: '0.16.0'}]
python: ['3.10', '3.12']
torch: [{base: '1.13.0', vision: '0.14.0'}, {base: '2.4.1', vision: '0.19.1'}]
testmarker: ['-k "not test_models"', '-m base', '-m cfg', '-m torchscript', '-m features', '-m fxforward', '-m fxbackward']
exclude:
- python: '3.11'
- python: '3.12'
torch: {base: '1.13.0', vision: '0.14.0'}
runs-on: ${{ matrix.os }}

View File

@ -146,18 +146,18 @@ def test_model_inference(model_name, batch_size):
rand_output = model(rand_tensors['input'])
rand_features = model.forward_features(rand_tensors['input'])
rand_pre_logits = model.forward_head(rand_features, pre_logits=True)
assert torch.allclose(rand_output, rand_tensors['output'], rtol=1e-3, atol=1e-5)
assert torch.allclose(rand_features, rand_tensors['features'], rtol=1e-3, atol=1e-5)
assert torch.allclose(rand_pre_logits, rand_tensors['pre_logits'], rtol=1e-3, atol=1e-5)
assert torch.allclose(rand_output, rand_tensors['output'], rtol=1e-3, atol=1e-4)
assert torch.allclose(rand_features, rand_tensors['features'], rtol=1e-3, atol=1e-4)
assert torch.allclose(rand_pre_logits, rand_tensors['pre_logits'], rtol=1e-3, atol=1e-4)
def _test_owl(owl_input):
owl_output = model(owl_input)
owl_features = model.forward_features(owl_input)
owl_pre_logits = model.forward_head(owl_features.clone(), pre_logits=True)
assert owl_output.softmax(1).argmax(1) == 24 # owl
assert torch.allclose(owl_output, owl_tensors['output'], rtol=1e-3, atol=1e-5)
assert torch.allclose(owl_features, owl_tensors['features'], rtol=1e-3, atol=1e-5)
assert torch.allclose(owl_pre_logits, owl_tensors['pre_logits'], rtol=1e-3, atol=1e-5)
assert torch.allclose(owl_output, owl_tensors['output'], rtol=1e-3, atol=1e-4)
assert torch.allclose(owl_features, owl_tensors['features'], rtol=1e-3, atol=1e-4)
assert torch.allclose(owl_pre_logits, owl_tensors['pre_logits'], rtol=1e-3, atol=1e-4)
_test_owl(owl_tensors['input']) # test with original pp owl tensor
_test_owl(pp(test_owl).unsqueeze(0)) # re-process from original jpg