Skip to content

--scheme-to-openfhe drops the crypto-context helpers when entry function name starts with two underscores #3421

Open

Description

@BAder82t

Hello
I hit this while taking MLIR that heir_py produced and running heir-opt on it by hand.

When the --scheme-to-openfhe runs without entry-function=, the entry-function inference does not match a function whose name starts with two underscores. The pass still exits 0, but <fn>__generate_crypto_context and <fn>__configure_crypto_context are missing from the output. The only sign is a warning on stderr.

Reproducer. Two files with the same body, only the name differs.

works.mlir:

func.func @foo(%arg0: f64 {secret.secret}, %arg1: f64) -> f64 {
  %0 = arith.mulf %arg0, %arg1 : f64
  return %0 : f64
}

fails.mlir: the same, with @foo renamed to @__main___foo_0.

Command, identical for both:

heir-opt --annotate-module="backend=openfhe scheme=ckks" \
  --mlir-to-ckks=min-slot-count=1024 --scheme-to-openfhe <file>.mlir

works.mlir gives 7 functions:

foo__preprocessing        foo__preprocessed        foo
foo__encrypt__arg0        foo__decrypt__result0
foo__generate_crypto_context     foo__configure_crypto_context

fails.mlir gives 5. The last two are gone, and stderr has:

warning: Entry function not found, please provide entry-function in the pass options

Exit code is 0 in both cases.

It is the two leading underscores specifically. I tried the neighbouring names, same body each time:

function name crypto-context helpers
@foo present
@foo_0 present
@_foo present
@__foo missing
@__main___foo_0 missing

So one underscore is fine and two is not, with everything else held constant.

Workaround: pass the name, --scheme-to-openfhe=entry-function=__main___foo_0, and the output is complete

On heir_py 2026.9.1 from PyPI, macOS arm64

Activity

  1. github-actions commented on Sep 22, 2026

    @github-actions

    Welcome to HEIR!

    Thank you for opening your first issue! We appreciate you joining our community.

    Please note that our contributing policy) requires unrecognized users to meet a maintainer in a non-textual format before opening their first PR.

    If you have already met a maintainer, or you're sure the maintainers know who you are, you can safely ignore this message. Otherwise, you can join one of our open meetings on our community calendar, schedule a dedicated call with a maintainer, or reach out in the #heir channel on Discord.

    We look forward to connecting with you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions