Skip to content

Config serde #1806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Config serde #1806

wants to merge 1 commit into from

Conversation

drisspg
Copy link
Contributor

@drisspg drisspg commented Mar 1, 2025

Stacked PRs:


Summary: Convert base configs to use Pydantic

Related PRs

Overview

This PR adds serialization and deserialization capabilities to most* of our Config classes by migrating from dataclasses to Pydantic models. The implementation enables JSON serialization/deserialization and dictionary conversion for all quantization configuration classes.

Note that we have two options add this to our depedencies ( we weirdly dont have any specified currently) or I can probably write this in a way to only be enabled if we have the runtime dep>

Testing

Added a new test file test/quantization/test_config_serialization.py with tests for alot of configuration classes

Impact

W/ this we can serialize configs. However as implemented it also enforces that all params are kwarg only which may BC BREAKING, you can hack around this w/ pydantic but not sure how much of a deal this is yet.

Why do we need this?

I am currently auditing our end to end flow, and while yes the core serialization premise of tensor subclass to both define our data representation and modulate runtime behavior exists - that is not how the rest of the ecosystem is operating.

Currenlty our hugging face integration only supports 4 options:
https://huggingface.co/docs/transformers/main/en/main_classes/quantization#transformers.TorchAoConfig.quant_type

I for 1 want to have this support the full breadth of options and as well I want this to be configurable per layer. I think this gets us closer since we can specify the quant structure in a config.json on the serialized weight.

As well this config.json appears to be reused by VLLm and I am still working on the E2E flow as prototype by Jerry here:
vllm-project/vllm#13588

Copy link

pytorch-bot bot commented Mar 1, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1806

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 5 Cancelled Jobs, 1 Unrelated Failure

As of commit 7f411f7 with merge base ffb4350 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

drisspg added a commit that referenced this pull request Mar 1, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from eb015da to 0664d5c Compare March 1, 2025 01:24
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 1, 2025
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 3, 2025 21:12
drisspg added a commit that referenced this pull request Mar 3, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from 0664d5c to 07ae065 Compare March 3, 2025 21:12
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 3, 2025 21:12
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 3, 2025 21:52
drisspg added a commit that referenced this pull request Mar 3, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from 07ae065 to b3e2dbd Compare March 3, 2025 21:52
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 3, 2025 21:52
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 3, 2025 23:29
drisspg added a commit that referenced this pull request Mar 3, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from b3e2dbd to 66debad Compare March 3, 2025 23:29
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 3, 2025 23:29
@drisspg drisspg added the topic: new feature Use this tag if this PR adds a new feature label Mar 3, 2025
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 3, 2025 23:35
drisspg added a commit that referenced this pull request Mar 3, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from 66debad to 6b52e33 Compare March 3, 2025 23:35
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 3, 2025 23:35
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 4, 2025 00:59
drisspg added a commit that referenced this pull request Mar 4, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from 6b52e33 to e8195fb Compare March 4, 2025 01:00
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 4, 2025 01:00
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 4, 2025 03:57
drisspg added a commit that referenced this pull request Mar 4, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from e8195fb to 500f84d Compare March 4, 2025 03:57
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 4, 2025 03:58
@drisspg drisspg force-pushed the drisspg/stack/41 branch from 629ebf2 to ac07aa2 Compare March 4, 2025 23:15
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 4, 2025 23:15
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 5, 2025 01:29
drisspg added a commit that referenced this pull request Mar 5, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from ac07aa2 to fa88916 Compare March 5, 2025 01:29
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 5, 2025 01:29
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 5, 2025 20:46
drisspg added a commit that referenced this pull request Mar 5, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from fa88916 to 025d432 Compare March 5, 2025 20:46
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 5, 2025 20:46
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 5, 2025 21:05
drisspg added a commit that referenced this pull request Mar 5, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from 025d432 to c4235ad Compare March 5, 2025 21:05
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 5, 2025 21:05
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 5, 2025 22:06
drisspg added a commit that referenced this pull request Mar 5, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from c4235ad to 8565f48 Compare March 5, 2025 22:06
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 5, 2025 22:07
drisspg added a commit that referenced this pull request Mar 5, 2025
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg force-pushed the drisspg/stack/41 branch from 8565f48 to 6dea2e7 Compare March 5, 2025 22:32
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 5, 2025 22:32
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 5, 2025 22:32
@drisspg drisspg mentioned this pull request Mar 6, 2025
2 tasks
stack-info: PR: #1806, branch: drisspg/stack/41
@drisspg drisspg changed the base branch from drisspg/stack/39 to main March 11, 2025 22:16
@drisspg drisspg changed the base branch from main to drisspg/stack/39 March 11, 2025 22:16
@drisspg drisspg closed this Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: new feature Use this tag if this PR adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants