Improve support for model-spec format; add support for raw layers and zstd compression#1202
Open
amisevsk wants to merge 12 commits into
Open
Improve support for model-spec format; add support for raw layers and zstd compression#1202amisevsk wants to merge 12 commits into
amisevsk wants to merge 12 commits into
Conversation
Member
|
@amisevsk Other than the CI failure this looks OK |
Contributor
Author
|
Odd, the sources are well-formatted on my end |
Fix issues around generating Kitfiles for ModelPacks that do not have
the Kitfile annotation (i.e. were not generated by Kit originally):
* Add layerinfo (digest and diffID) to generated Kitfile, as this is
potentially required in other tools
* DiffIDs depend on an optional ModelPack config object being passed
in and are omitted if the object is nil
* Retrieve ModelPack config when generating a Kitfile in our code to
ensure DiffIDs are included.
Signed-off-by: Angel Misevski <amisevsk@gmail.com>
Signed-off-by: Angel Misevski <amisevsk@gmail.com>
Kit-generated artifacts (both ModelKits and ModelPacks) have at most one "main" model layer -- i.e. layers with mediatype * application/vnd.kitops.modelkit.model.v1.tar (ModelKit) * application/vnd.cncf.model.weight.v1.tar (CNCF ModelPack) However, ModelPacks in general may have N model.weight layers, which is not representable in a Kitfile. To accommodate this, Kit generates a Kitfile for ModelPack artifacts that places additional model.weight layers within the modelparts section (as it would during normal kit init). When unpacking, we need to account for this by checking the Kitfile's modelparts for additional model.weight layers encountered after the first one; otherwise, we unpack additional weight layers to the incorrect path Signed-off-by: Angel Misevski <amisevsk@gmail.com>
The unpackRecursive function is very long and touches disk, making it hard to write test cases for its behavior, which has become rather complicated. To enable writing tests for key functionality, split the function into testable parts where possible. Signed-off-by: Angel Misevski <amisevsk@gmail.com>
…odel-spec * Update KitOps mediatype handling to support raw-formatted layers (i.e. non-tar) and zstd compression, to bring it in line with model-spec. * Fix filepath annotation handling on Windows by normalizing to unix-style paths. Signed-off-by: Angel Misevski <amisevsk@gmail.com>
* Add support for the raw mediatype from model-spec by writing layer contents directly to the file specified by the model-spec filepath annotation * Add support for zstd compression in unpacking. Signed-off-by: Angel Misevski <amisevsk@gmail.com>
Add support for packing raw layers in addition to tar layers. Raw layers are saved directly. Signed-off-by: Angel Misevski <amisevsk@gmail.com>
Signed-off-by: Angel Misevski <amisevsk@gmail.com>
ModelPacks do not support compression with raw layers; since raw layers are now generally supported by KitOps, we need to validate that the ModelPacks we generate are valid. Signed-off-by: Angel Misevski <amisevsk@gmail.com>
Add tests to ensure that layers packed in raw format contain DiffIDs that match the actual SHA256 sum of the file being packed. This is useful for tracking provenance (e.g. you know the digest of the file and want to find ModelKits that contain that file). For the no-compression case, we also assert that the layer digest matches. Signed-off-by: Angel Misevski <amisevsk@gmail.com>
1eac8c7 to
5318d4c
Compare
Contributor
Author
|
This is fun... MacOS and Linux disagree on diff --git a/testing/pack-unpack_test.go b/testing/pack-unpack_test.go
index d11b873..0d85bee 100644
--- a/testing/pack-unpack_test.go
+++ b/testing/pack-unpack_test.go
@@ -205,9 +205,9 @@ func TestPackReproducibility(t *testing.T) {
{"--layer-format", "raw"}, // raw format
{"--compression", "gzip"}, // tar + gzip
{"--layer-format", "raw", "--compression", "gzip"}, // raw + gzip
- {"--use-model-pack"}, // modelpack default
- {"--use-model-pack", "--layer-format", "raw"}, // modelpack + raw format
- {"--use-model-pack", "--compression", "gzip"}, // modelpack + tar + gzip
+ {"--use-model-pack"}, // modelpack default
+ {"--use-model-pack", "--layer-format", "raw"}, // modelpack + raw format
+ {"--use-model-pack", "--compression", "gzip"}, // modelpack + tar + gzip
}
testKitfile := ` |
Test ModelPack usage in pack-unpack scenarios in functional tests in addition to ModelKits. Signed-off-by: Angel Misevski <amisevsk@gmail.com>
Signed-off-by: Angel Misevski <amisevsk@gmail.com>
5318d4c to
e4af498
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improve support for model-spec formatted artifacts in KitOps. Our goal is to support any valid ModelPack transparently within KitOps; as a result this PR adds support for
rawlayer types (i.e. non-tar) andzstdcompression as specified by the model-spec mediatypes.model.weightlayers are now properly generated -- additionalmodel.weightlayers are included in modelparts within the Kitfilekit packnow supportszstdcompression andrawlayers:--layer-formatwith optionstar(default) andraw(no tar wrapper)zstdoption on the existing--compressionflagkit unpackalso now supportszstdcompression andrawlayers, transparently.I've tried to keep the Git commit history useful for this one, as there are a lot of changes here. Each commit should be self-contained and include a meaningful description of the changes within
Linked issues
N/A, forgot to create one
AI-Assisted Code