Remove internal logic to handle bytecode version 3 (#57775)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57775

The minimum supported bytecode version is updated from 3 to 4. We no longer support version 3 bytecode models.

Why?
* There are hacky codes in operator loading, that performs differently on one operator on the global bytecode version 3. Instead operator related metadata should be passed (for example, in #56845). To allow future development, we remove the hacky way first.
* The bytecode version was bumped from 3 to 4 more than half a year ago. Since all the production models are all bumped to version 4, it's not practical to keep and maintain version 3. The risk to deprecate version 3 is low.

Test Plan: Imported from OSS

Reviewed By: raziel

Differential Revision: D28270791

Pulled By: cccclai

fbshipit-source-id: 70b1bd6352fdaae5f8d2173b81578d77018c8e44
(cherry picked from commit 3e930fa381cd01f3705116795c6426df992372fc)
This commit is contained in:
Martin Yuan
2022-04-06 18:39:37 -07:00
committed by PyTorch MergeBot
parent 7e9bb1c273
commit 00c1e01ad0
11 changed files with 51 additions and 89 deletions

View File

@ -311,8 +311,9 @@ void BytecodeDeserializer::parseMethods(
TORCH_CHECK(vals.size() > 0, "Bytecode has no elements. ");
// Initialized with the version number when kProducedBytecodeVersion was
// introduced. The old models (some of them already in production) without
// version number don't have to be re-generated.
int64_t model_version = 0x3L;
// version number are seen as version 3 (deprecated).
constexpr uint64_t default_version = 0x3L;
uint64_t model_version = default_version;
size_t method_i_start = 0;
if (vals[0].isInt()) {
model_version = vals[0].toInt();
@ -383,11 +384,7 @@ void BytecodeDeserializer::parseMethods(
}
init_upgrader(function.get());
// 1. First pass all operators from models
parseOperators(
std::move(ops_list),
model_version,
module_load_options_,
function.get());
parseOperators(std::move(ops_list), module_load_options_, function.get());
// 2. Decides if upgrader is needed
bool use_upgrader =