Add zstd dict trainer with ZDICT_optimizeTrainFromBuffer_cover (#806) (#806)#806
Open
Victor-C-Zhang wants to merge 1 commit into
Open
Add zstd dict trainer with ZDICT_optimizeTrainFromBuffer_cover (#806) (#806)#806Victor-C-Zhang wants to merge 1 commit into
Victor-C-Zhang wants to merge 1 commit into
Conversation
|
@Victor-C-Zhang has exported this pull request. If you are a Meta employee, you can view the originating Diff in D105006229. |
fcda779 to
c0a5ca5
Compare
Victor-C-Zhang
added a commit
to Victor-C-Zhang/openzl-1
that referenced
this pull request
Jun 6, 2026
…ook#806) Summary: Add a dict training framework with an abstract DictTrainer base and a concrete ZstdDictTrainer implementation. DictTrainer interface (base_dict_trainer.h): - DictNodeInfo struct: nodeID, codecID, nodeName for discovered dict-requiring nodes. - DictTrainer abstract class with findDictNodes() and trainDict() virtual methods. - trainDictsForCandidate(): top-level orchestrator that discovers dict nodes across all registered trainers, collects per-node input samples via collectInputStreams, trains dicts, packs them into the ZL_Dict wire format, patches per-node dict_id and dict_bundle_id into the serialized compressor CBOR, and returns a TrainedCandidate. trainDictsForCandidate implementation (base_dict_trainer.cpp): - Creates all registered DictTrainer instances (currently just ZstdDictTrainer). - For each trainer, calls findDictNodes() to discover nodes, then collectInputStreams() to capture input data flowing into those nodes. - For each node with samples, calls trainDict() to get packed dict content, then wraps it in Dict_pack(). - Patches the serialized compressor CBOR with per-node dict_id values and sets the bundle ID. ZstdDictTrainer (zstd_dict_trainer.h/cpp): - findDictNodes(): discovers nodes named "zl.trainable.zstd" via ZL_Compressor_forEachNode. - trainDict(): flattens MultiInput samples into byte spans, calls trainRawDict(), then packs the raw dict into the ZL_TrainedZstdContent envelope with the compression level from ZL_LocalParams. - trainRawDict(): uses ZDICT_optimizeTrainFromBuffer_cover with fallback to ZDICT_trainFromBuffer. test_dict_training.cpp: - ZstdDictTrainer unit tests: TrainDictReturnsPackedContent, TrainDictUsesCompressionLevelFromLocalParams, FindDictNodesReturnsEmptyForDefaultCompressor, FindDictNodesFindsMultipleZstdNodes. - TrainedCandidate helper tests: ReplaceBundleID, ReplaceDictID (single + batch + missing), PackFatBundleRoundTrip, PackFatBundleThrowsOnEmpty. BUCK changes: - New dict:base_dict_trainer library target. - Add dict dep to :trainer target and test deps. Reviewed By: terrelln Differential Revision: D105006229
…ook#806) (facebook#806) Summary: Add a dict training framework with an abstract DictTrainer base and a concrete ZstdDictTrainer implementation. DictTrainer interface (base_dict_trainer.h): - DictNodeInfo struct: nodeID, codecID, nodeName for discovered dict-requiring nodes. - DictTrainer abstract class with findDictNodes() and trainDict() virtual methods. - trainDictsForCandidate(): top-level orchestrator that discovers dict nodes across all registered trainers, collects per-node input samples via collectInputStreams, trains dicts, packs them into the ZL_Dict wire format, patches per-node dict_id and dict_bundle_id into the serialized compressor CBOR, and returns a TrainedCandidate. trainDictsForCandidate implementation (base_dict_trainer.cpp): - Creates all registered DictTrainer instances (currently just ZstdDictTrainer). - For each trainer, calls findDictNodes() to discover nodes, then collectInputStreams() to capture input data flowing into those nodes. - For each node with samples, calls trainDict() to get packed dict content, then wraps it in Dict_pack(). - Patches the serialized compressor CBOR with per-node dict_id values and sets the bundle ID. ZstdDictTrainer (zstd_dict_trainer.h/cpp): - findDictNodes(): discovers nodes named "zl.trainable.zstd" via ZL_Compressor_forEachNode. - trainDict(): flattens MultiInput samples into byte spans, calls trainRawDict(), then packs the raw dict into the ZL_TrainedZstdContent envelope with the compression level from ZL_LocalParams. - trainRawDict(): uses ZDICT_optimizeTrainFromBuffer_cover with fallback to ZDICT_trainFromBuffer. test_dict_training.cpp: - ZstdDictTrainer unit tests: TrainDictReturnsPackedContent, TrainDictUsesCompressionLevelFromLocalParams, FindDictNodesReturnsEmptyForDefaultCompressor, FindDictNodesFindsMultipleZstdNodes. - TrainedCandidate helper tests: ReplaceBundleID, ReplaceDictID (single + batch + missing), PackFatBundleRoundTrip, PackFatBundleThrowsOnEmpty. BUCK changes: - New dict:base_dict_trainer library target. - Add dict dep to :trainer target and test deps. Differential Revision: D105006229 Pulled By: Victor-C-Zhang
e992c3b to
1f4f19b
Compare
Victor-C-Zhang
added a commit
to Victor-C-Zhang/openzl-1
that referenced
this pull request
Jun 10, 2026
…ook#806) (facebook#806) Summary: Add a dict training framework with an abstract DictTrainer base and a concrete ZstdDictTrainer implementation. DictTrainer interface (base_dict_trainer.h): - DictNodeInfo struct: nodeID, codecID, nodeName for discovered dict-requiring nodes. - DictTrainer abstract class with findDictNodes() and trainDict() virtual methods. - trainDictsForCandidate(): top-level orchestrator that discovers dict nodes across all registered trainers, collects per-node input samples via collectInputStreams, trains dicts, packs them into the ZL_Dict wire format, patches per-node dict_id and dict_bundle_id into the serialized compressor CBOR, and returns a TrainedCandidate. trainDictsForCandidate implementation (base_dict_trainer.cpp): - Creates all registered DictTrainer instances (currently just ZstdDictTrainer). - For each trainer, calls findDictNodes() to discover nodes, then collectInputStreams() to capture input data flowing into those nodes. - For each node with samples, calls trainDict() to get packed dict content, then wraps it in Dict_pack(). - Patches the serialized compressor CBOR with per-node dict_id values and sets the bundle ID. ZstdDictTrainer (zstd_dict_trainer.h/cpp): - findDictNodes(): discovers nodes named "zl.trainable.zstd" via ZL_Compressor_forEachNode. - trainDict(): flattens MultiInput samples into byte spans, calls trainRawDict(), then packs the raw dict into the ZL_TrainedZstdContent envelope with the compression level from ZL_LocalParams. - trainRawDict(): uses ZDICT_optimizeTrainFromBuffer_cover with fallback to ZDICT_trainFromBuffer. test_dict_training.cpp: - ZstdDictTrainer unit tests: TrainDictReturnsPackedContent, TrainDictUsesCompressionLevelFromLocalParams, FindDictNodesReturnsEmptyForDefaultCompressor, FindDictNodesFindsMultipleZstdNodes. - TrainedCandidate helper tests: ReplaceBundleID, ReplaceDictID (single + batch + missing), PackFatBundleRoundTrip, PackFatBundleThrowsOnEmpty. BUCK changes: - New dict:base_dict_trainer library target. - Add dict dep to :trainer target and test deps. Differential Revision: D105006229 Pulled By: Victor-C-Zhang
Victor-C-Zhang
added a commit
to Victor-C-Zhang/openzl-1
that referenced
this pull request
Jun 10, 2026
…ook#806) (facebook#806) Summary: Add a dict training framework with an abstract DictTrainer base and a concrete ZstdDictTrainer implementation. DictTrainer interface (base_dict_trainer.h): - DictNodeInfo struct: nodeID, codecID, nodeName for discovered dict-requiring nodes. - DictTrainer abstract class with findDictNodes() and trainDict() virtual methods. - trainDictsForCandidate(): top-level orchestrator that discovers dict nodes across all registered trainers, collects per-node input samples via collectInputStreams, trains dicts, packs them into the ZL_Dict wire format, patches per-node dict_id and dict_bundle_id into the serialized compressor CBOR, and returns a TrainedCandidate. trainDictsForCandidate implementation (base_dict_trainer.cpp): - Creates all registered DictTrainer instances (currently just ZstdDictTrainer). - For each trainer, calls findDictNodes() to discover nodes, then collectInputStreams() to capture input data flowing into those nodes. - For each node with samples, calls trainDict() to get packed dict content, then wraps it in Dict_pack(). - Patches the serialized compressor CBOR with per-node dict_id values and sets the bundle ID. ZstdDictTrainer (zstd_dict_trainer.h/cpp): - findDictNodes(): discovers nodes named "zl.trainable.zstd" via ZL_Compressor_forEachNode. - trainDict(): flattens MultiInput samples into byte spans, calls trainRawDict(), then packs the raw dict into the ZL_TrainedZstdContent envelope with the compression level from ZL_LocalParams. - trainRawDict(): uses ZDICT_optimizeTrainFromBuffer_cover with fallback to ZDICT_trainFromBuffer. test_dict_training.cpp: - ZstdDictTrainer unit tests: TrainDictReturnsPackedContent, TrainDictUsesCompressionLevelFromLocalParams, FindDictNodesReturnsEmptyForDefaultCompressor, FindDictNodesFindsMultipleZstdNodes. - TrainedCandidate helper tests: ReplaceBundleID, ReplaceDictID (single + batch + missing), PackFatBundleRoundTrip, PackFatBundleThrowsOnEmpty. BUCK changes: - New dict:base_dict_trainer library target. - Add dict dep to :trainer target and test deps. Differential Revision: D105006229 Pulled By: Victor-C-Zhang
meta-codesync Bot
pushed a commit
that referenced
this pull request
Jun 11, 2026
…#806) Summary: Add a dict training framework with an abstract DictTrainer base and a concrete ZstdDictTrainer implementation. DictTrainer interface (base_dict_trainer.h): - DictNodeInfo struct: nodeID, codecID, nodeName for discovered dict-requiring nodes. - DictTrainer abstract class with findDictNodes() and trainDict() virtual methods. - trainDictsForCandidate(): top-level orchestrator that discovers dict nodes across all registered trainers, collects per-node input samples via collectInputStreams, trains dicts, packs them into the ZL_Dict wire format, patches per-node dict_id and dict_bundle_id into the serialized compressor CBOR, and returns a TrainedCandidate. trainDictsForCandidate implementation (base_dict_trainer.cpp): - Creates all registered DictTrainer instances (currently just ZstdDictTrainer). - For each trainer, calls findDictNodes() to discover nodes, then collectInputStreams() to capture input data flowing into those nodes. - For each node with samples, calls trainDict() to get packed dict content, then wraps it in Dict_pack(). - Patches the serialized compressor CBOR with per-node dict_id values and sets the bundle ID. ZstdDictTrainer (zstd_dict_trainer.h/cpp): - findDictNodes(): discovers nodes named "zl.trainable.zstd" via ZL_Compressor_forEachNode. - trainDict(): flattens MultiInput samples into byte spans, calls trainRawDict(), then packs the raw dict into the ZL_TrainedZstdContent envelope with the compression level from ZL_LocalParams. - trainRawDict(): uses ZDICT_optimizeTrainFromBuffer_cover with fallback to ZDICT_trainFromBuffer. test_dict_training.cpp: - ZstdDictTrainer unit tests: TrainDictReturnsPackedContent, TrainDictUsesCompressionLevelFromLocalParams, FindDictNodesReturnsEmptyForDefaultCompressor, FindDictNodesFindsMultipleZstdNodes. - TrainedCandidate helper tests: ReplaceBundleID, ReplaceDictID (single + batch + missing), PackFatBundleRoundTrip, PackFatBundleThrowsOnEmpty. BUCK changes: - New dict:base_dict_trainer library target. - Add dict dep to :trainer target and test deps. Differential Revision: D105006229 Pulled By: Victor-C-Zhang fbshipit-source-id: 8cd198b0bb09ffb536ad1a3744da21a8def240a3
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.
Summary:
Add a dict training framework with an abstract DictTrainer base and a concrete ZstdDictTrainer implementation.
DictTrainer interface (base_dict_trainer.h):
trainDictsForCandidate implementation (base_dict_trainer.cpp):
ZstdDictTrainer (zstd_dict_trainer.h/cpp):
test_dict_training.cpp:
BUCK changes:
Differential Revision: D105006229
Pulled By: Victor-C-Zhang