Skip to content

chore(backward): integrate backward compat data #2493

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

Merged
merged 3 commits into from
Jul 7, 2025

Conversation

nsarlin-zama
Copy link
Contributor

@nsarlin-zama nsarlin-zama commented Jul 1, 2025

closes: please link all relevant issues

PR content/description

Integrate backward compat data inside TFHE-rs main repo. This should simplify the process to add new data. Once this pr is merged, the old repo should be archived but kept to be able to run tests on old versions.

The lfs data will not be cloned by default to avoid impacting dev experience, but running make clone_backward_compat_data will clone them.

The data cache in ci is now based on the hash of the lfs files, because we previously used the commit sha of the target repo


This change is Reviewable

@cla-bot cla-bot bot added the cla-signed label Jul 1, 2025
@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch 4 times, most recently from caf0758 to f20c604 Compare July 1, 2025 10:21
Base automatically changed from mz/centered_ms to main July 1, 2025 12:18
@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch 8 times, most recently from dbfff3d to c98e0c7 Compare July 3, 2025 09:58
@nsarlin-zama nsarlin-zama requested a review from mayeul-zama July 3, 2025 10:05
@nsarlin-zama
Copy link
Contributor Author

Note that cache seems to be temporary down?
I get "Failed to save: reserveCache failed: Cache service responded with 503" but it seems to also be the case on regular PR: https://github.com/zama-ai/tfhe-rs/actions/runs/16045513937/job/45275855427?pr=2514#step:11:25

@nsarlin-zama nsarlin-zama marked this pull request as ready for review July 3, 2025 10:11
@IceTDrinker
Copy link
Member

Note that cache seems to be temporary down? I get "Failed to save: reserveCache failed: Cache service responded with 503" but it seems to also be the case on regular PR: https://github.com/zama-ai/tfhe-rs/actions/runs/16045513937/job/45275855427?pr=2514#step:11:25

I don't know if it's a problem on our end or with the github cache service 🤔

Copy link
Contributor

@mayeul-zama mayeul-zama 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!
But I haven't reviewed the github action file change

I wonder if it would make sense to merge tfhe-backward-compat and backward-compatibility crates (in a later PR)

Thanks a lot for this PR, will be useful!

//! Tests breaking change in serialized data by trying to load historical data stored in https://github.com/zama-ai/tfhe-backward-compat-data.
//! For each tfhe-rs module, there is a folder with some serialized messages and a [ron](https://github.com/ron-rs/ron)
//! Tests breaking change in serialized data by trying to load historical data stored in
//! `utils/tfhe-backward-compat-data`. For each tfhe-rs module, there is a folder with some serialized messages and a [ron](https://github.com/ron-rs/ron)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could clarify that data is stored with git lfs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -2,9 +2,9 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

This file could be renamed pull_...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

else
git clone $1 -b $2 --depth 1 $3
fi
git lfs pull --include="$1/*" --exclude="*.hpu"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are both include and exclude needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know I copied from hpu doc which uses an empty exclude

Copy link
Contributor

Choose a reason for hiding this comment

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

"Only paths which are matched by fetchinclude and not matched by fetchexclude will have objects fetched for them." from
https://manpages.ubuntu.com/manpages/focal/man1/git-lfs-pull.1.html

I guess we could remove exclude in every git lfs pull in the repo and only use the relevant include

Also, we could have a single pull_from_lfs script which takes a wildcard as argument
And 2 make targets pull_backward_compat_data and pull_hpu_files which call the same above script with different arguments

And call these targets instead of calling git lfs pull everywhere

Copy link
Member

@IceTDrinker IceTDrinker Jul 4, 2025

Choose a reason for hiding this comment

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

what's the problem with having dedicated git lfs pull commands ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This script checks that git lfs exits
IMO either we think it's useful and we should use this script everywhere
Or not and then we should remove it and call git lfs directly everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zama-ai/hardware would a command like make pull_hpu_files (or whatever name you want) be ok for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually both include and exclude are needed because there is a default value for exclude in .lfsconfig so we need to override it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Makefile Outdated
@@ -263,6 +249,9 @@ install_mlc: install_rs_build_toolchain
.PHONY: fmt # Format rust code
fmt: install_rs_check_toolchain
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" -Z unstable-options -C utils/tfhe-backward-compat-data fmt
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use BACKWARD_COMPAT_DATA_DIR here and other places (or remove this variable)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch 2 times, most recently from 2a0fffc to 71d2476 Compare July 4, 2025 08:09
@nsarlin-zama nsarlin-zama requested a review from a team as a code owner July 4, 2025 08:09
@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch from 71d2476 to 4162559 Compare July 4, 2025 08:13
@nsarlin-zama
Copy link
Contributor Author

nsarlin-zama commented Jul 4, 2025

I wonder if it would make sense to merge tfhe-backward-compat and backward-compatibility crates (in a later PR)

Technically there is no backward-compatibility crate, this is a module inside the tests crate for integration tests.
I think we might run into dependency issues if we merge them.

However I plan to split the backward-compat-data crate to simplify the multi-tfhe-dependency thing and add the possibility to generate only the data for a single version.

@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch from 4162559 to 640c7fa Compare July 4, 2025 08:57
@nsarlin-zama
Copy link
Contributor Author

I changed the heuristic to hint that the data may have not been pulled.
Before we checked if the dir existed but we cannot do that anymore. We suggest to clone the data if all the tests fail.

else
git clone $1 -b $2 --depth 1 $3
fi
git lfs pull --include="$1/*" --exclude="*.hpu"
Copy link
Contributor

Choose a reason for hiding this comment

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

"Only paths which are matched by fetchinclude and not matched by fetchexclude will have objects fetched for them." from
https://manpages.ubuntu.com/manpages/focal/man1/git-lfs-pull.1.html

I guess we could remove exclude in every git lfs pull in the repo and only use the relevant include

Also, we could have a single pull_from_lfs script which takes a wildcard as argument
And 2 make targets pull_backward_compat_data and pull_hpu_files which call the same above script with different arguments

And call these targets instead of calling git lfs pull everywhere

@nsarlin-zama
Copy link
Contributor Author

I guess but I don't want to touch hpu workflow in this pr

@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch from 640c7fa to bdeb057 Compare July 4, 2025 15:32
@nsarlin-zama nsarlin-zama requested a review from mayeul-zama July 4, 2025 15:33
Makefile Outdated

tests/$(BACKWARD_COMPAT_DATA_DIR): clone_backward_compat_data
.PHONY: pull_hpu_files # Pull the hpu files
pull_hpu_file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Lacks an s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -217,7 +217,7 @@ source setup_hpu.sh --config v80
> NB: Error that occurred when ".hpu" files weren't correctly fetch could be a bit enigmatic: `memory allocation of ... bytes failed`
> If you encountered this issue, you should run the following command:
> ```bash
> git lfs pull --include="*" --exclude=""
> make pull_hpu_files
Copy link
Contributor

Choose a reason for hiding this comment

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

This change could also be done in benchmark_hpu_integer.yml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch from bdeb057 to 5ef12e4 Compare July 4, 2025 15:50
@nsarlin-zama nsarlin-zama requested a review from mayeul-zama July 4, 2025 16:04
Copy link
Contributor

@mayeul-zama mayeul-zama left a comment

Choose a reason for hiding this comment

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

:lgtm:

Thanks a lot!

I'm not knowledgeable to review file .github/workflows/aws_tfhe_backward_compat_tests.yml

Reviewed 13 of 125 files at r1, 9 of 9 files at r3, 4 of 4 files at r4, 4 of 4 files at r6, all commit messages.
Reviewable status: 20 of 128 files reviewed, all discussions resolved (waiting on @IceTDrinker and @soonum)

Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

questions/comments, looks good generally speaking

Reviewed 117 of 125 files at r1, 6 of 9 files at r3, 1 of 4 files at r4, 4 of 4 files at r6, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @soonum)


tests/backward_compatibility_tests.rs line 28 at r6 (raw file):

    };

    if !root_dir.exists() {

I would keep this if we move stuff around, we had an issue with Cargo manifest at some point ?


utils/tfhe-backward-compat-data/.linelint.yml line 1 at r6 (raw file):

ignore:

this file necessary ? feels like I saw the ignore for ron elsewhere


.github/workflows/aws_tfhe_backward_compat_tests.yml line 86 at r6 (raw file):

        with:
          path: |
            utils/tfhe-backward-compat-data/**/*.cbor

/data would be enough ? no need for globbing I think ?


.github/workflows/aws_tfhe_backward_compat_tests.yml line 105 at r6 (raw file):

        with:
          path: |
            utils/tfhe-backward-compat-data/**/*.cbor

same here


Makefile line 1055 at r6 (raw file):

.PHONY: test_backward_compatibility_ci
test_backward_compatibility_ci: install_rs_build_toolchain
	TFHE_BACKWARD_COMPAT_DATA_DIR="../$(BACKWARD_COMPAT_DATA_DIR)" RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \

../ seems a bit counterintuitive ?


Makefile line 1059 at r6 (raw file):

.PHONY: test_backward_compatibility # Same as test_backward_compatibility_ci but tries to clone the data repo first if needed
test_backward_compatibility: pull_backward_compat_data test_backward_compatibility_ci

what effect does the pull have if we are modifying lfs files to add new data e.g. ?

@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch from 5ef12e4 to 5fb3d15 Compare July 7, 2025 07:54
@zama-bot zama-bot removed the approved label Jul 7, 2025
@nsarlin-zama nsarlin-zama force-pushed the ns/chore/integrate_backward_data branch from 5fb3d15 to 17bfd7b Compare July 7, 2025 08:04
Copy link
Contributor Author

@nsarlin-zama nsarlin-zama left a comment

Choose a reason for hiding this comment

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

Reviewable status: 127 of 128 files reviewed, 5 unresolved discussions (waiting on @IceTDrinker, @mayeul-zama, and @soonum)


Makefile line 1055 at r6 (raw file):

Previously, IceTDrinker (Arthur Meyre) wrote…

../ seems a bit counterintuitive ?

Because $(BACKWARD_COMPAT_DATA_DIR) is from TFHE-rs root folder but the cargo test driver will run the test from the tests folder


Makefile line 1059 at r6 (raw file):

Previously, IceTDrinker (Arthur Meyre) wrote…

what effect does the pull have if we are modifying lfs files to add new data e.g. ?

git lfs pull does not override local modifications (I just tested it)


.github/workflows/aws_tfhe_backward_compat_tests.yml line 86 at r6 (raw file):

Previously, IceTDrinker (Arthur Meyre) wrote…

/data would be enough ? no need for globbing I think ?

the files are inside utils/tfhe-backward-compat-data/{0_8, 0_10, 0_11,...}/ so we need the globing. And this line is telling "any cbor file inside utils/tfhe-backward-compat-data/" which I feel is what we want (more robust that direct path)


tests/backward_compatibility_tests.rs line 28 at r6 (raw file):

Previously, IceTDrinker (Arthur Meyre) wrote…

I would keep this if we move stuff around, we had an issue with Cargo manifest at some point ?

done


utils/tfhe-backward-compat-data/.linelint.yml line 1 at r6 (raw file):

Previously, IceTDrinker (Arthur Meyre) wrote…

this file necessary ? feels like I saw the ignore for ron elsewhere

yes I forgot to remove it

Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Thanks a lot !

We should be able to set the other repo as an archive once this is merged pending the CI fix

Reviewed 1 of 1 files at r7, 1 of 1 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @soonum)


Makefile line 1055 at r6 (raw file):

Previously, nsarlin-zama (Nicolas Sarlin) wrote…

Because $(BACKWARD_COMPAT_DATA_DIR) is from TFHE-rs root folder but the cargo test driver will run the test from the tests folder

ok makes sense


.github/workflows/aws_tfhe_backward_compat_tests.yml line 86 at r6 (raw file):

Previously, nsarlin-zama (Nicolas Sarlin) wrote…

the files are inside utils/tfhe-backward-compat-data/{0_8, 0_10, 0_11,...}/ so we need the globing. And this line is telling "any cbor file inside utils/tfhe-backward-compat-data/" which I feel is what we want (more robust that direct path)

ok

Copy link
Contributor

@mayeul-zama mayeul-zama left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 127 of 128 files reviewed, all discussions resolved (waiting on @IceTDrinker and @soonum)

@nsarlin-zama nsarlin-zama merged commit bb1ff36 into main Jul 7, 2025
113 checks passed
@nsarlin-zama nsarlin-zama deleted the ns/chore/integrate_backward_data branch July 7, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants