Skip to content
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

The annotation_in parameter seems to have no effect? #38

Open
thereisnoname opened this issue Oct 16, 2024 · 0 comments
Open

The annotation_in parameter seems to have no effect? #38

thereisnoname opened this issue Oct 16, 2024 · 0 comments

Comments

@thereisnoname
Copy link

I'm trying to use the annotation_in parameter in tl2cgen.export_lib, but it doesn't seem to have any effect. I get the same output whether I include the parameter or not. Here’s the code I’m using:

    # Generate annotations from the training data
def generate_annotations(X_train, model, output_annotation_file):
    # Convert training data to DMatrix (required for annotation)
    dmat = tl2cgen.DMatrix(X_train)
    
    # Generate branch annotations based on the training data and save to file
    tl2cgen.annotate_branch(model=model, dmat=dmat, path=output_annotation_file)
    print(f"Branch annotations saved to: {output_annotation_file}")

# Export the TL2cgen optimized model
def export_optimized_model(treelite_model, output_model_path, annotation_file):
    # Export the optimized model with quantization and branch annotations
    tl2cgen.export_lib(
        treelite_model, 
        toolchain="gcc", 
        libpath=output_model_path, 
        params={"quantize": 1, "annotate_in": annotation_file, "parallel_comp":16},
        verbose=True
    )
    print(f"Optimized model saved to: {output_model_path}")

I got same output with annotate_in removed, is there something I'm missing? Any idea why?
The annotation file seems correctly formatted and contains feature information.Its generated from annotate_branch using the same model.

  • treelite 4.3.0
  • tl2cgen 1.0.0

The verbose output is:

[11:56:26] /tmp/tmpfk5q71dd/libbuild/_deps/treelite-src/src/serializer.cc:202: The model you are loading originated from a newer Treelite version; some functionalities may be unavailable.
Currently running Treelite version 4.1.2
The model checkpoint was generated from Treelite version 4.3.0
Branch annotations saved to: branch_annotations.json
[11:56:27] /tmp/tmpfk5q71dd/libbuild/_deps/treelite-src/src/serializer.cc:202: The model you are loading originated from a newer Treelite version; some functionalities may be unavailable.
Currently running Treelite version 4.1.2
The model checkpoint was generated from Treelite version 4.3.0
[11:56:27] /project/src/compiler/ast/split.cc:35: Parallel compilation enabled; member trees will be divided into 16 translation units.
Compiling sources files in directory /tmp/tmp0_wpqw_r into object files (*.o)...
Generating dynamic shared library /tmp/tmp0_wpqw_r/predictor.so...
Generated shared library in 12.63 seconds
Optimized model saved to: tl_v3.so

Any ideas on why this might be happening? Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant