Skip to content

Fix issues in TRT model ID generator#13837

Merged
stevenlix merged 10 commits intomainfrom
stevenlix/hashid
Dec 15, 2022
Merged

Fix issues in TRT model ID generator#13837
stevenlix merged 10 commits intomainfrom
stevenlix/hashid

Conversation

@stevenlix
Copy link
Contributor

@stevenlix stevenlix commented Dec 5, 2022

There are some issues in #13015,

  1. Model name should be used rather than graph name in the model ID generator.
  2. Hash collision is observed in ID cache, which means different model may have the same key and thus load same hash id from the cache.
  3. For the class and function that generate model id, MetaDef in the name is not appropriate.
  4. Should reuse murmurhash3 rather than copy it over to TRT EP
    This PR fixes those issues.

@jywu-msft
Copy link
Member

seems like we have a testing gap that should have caught this previously?

if (!model_path.IsEmpty()) {
// Get model name
PathString leaf = model_path.GetComponents().back();
std::string model_name = ToUTF8String(leaf.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we hash model name here, will it be a case that a model has different model names and ends up with different hashed ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. If user just changed model name and model itself doesn't change, ORT will treat it as a different model and generate a new engine.

Copy link
Contributor

@yf711 yf711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!


// Test loading same model in different way, when hash id is generated via model name/model content/env metadata
TEST(TensorrtExecutionProviderTest, TRTMetadefIdGeneratorUsingModelHashing) {
TEST(TensorrtExecutionProviderTest, TRTModelIdGeneratorUsingModelHashing) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Steven this test compares model hash when importing same model from file path/byte. Since model imported from byte has no path, model name can't be parsed from it and hash will be different from model imported from file. Will this be a valid use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's something we discussed internally. If user loads model bytes rather than onnx model, a new engine will be generated. I will update ORT document to reflect this.

@stevenlix
Copy link
Contributor Author

seems like we have a testing gap that should have caught this previously?

Maybe there is a way to check hash id collision. Will think about it and add a test case in a separated PR

@stevenlix stevenlix merged commit c4ecbb9 into main Dec 15, 2022
@stevenlix stevenlix deleted the stevenlix/hashid branch December 15, 2022 21:51
simon-moo pushed a commit to simon-moo/onnxruntime that referenced this pull request Dec 26, 2022
There are some issues in
microsoft#13015,
1. Model name should be used rather than graph name in the model ID
generator.
2. Hash collision is observed in ID cache, which means different model
may have the same key and thus load same hash id from the cache.
3. For the class and function that generate model id, MetaDef in the
name is not appropriate.
4. Should reuse murmurhash3 rather than copy it over to TRT EP
This PR fixes those issues.
mszhanyi added a commit that referenced this pull request Jan 4, 2023
yf711 pushed a commit that referenced this pull request Jan 6, 2023
There are some issues in
#13015,
1. Model name should be used rather than graph name in the model ID
generator.
2. Hash collision is observed in ID cache, which means different model
may have the same key and thus load same hash id from the cache.
3. For the class and function that generate model id, MetaDef in the
name is not appropriate.
4. Should reuse murmurhash3 rather than copy it over to TRT EP
This PR fixes those issues.
adrianlizarraga added a commit that referenced this pull request Jan 7, 2023
mszhanyi added a commit that referenced this pull request Jan 8, 2023
mszhanyi added a commit that referenced this pull request Jan 10, 2023
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.

4 participants