QLayerV2 is a new, simplified quantum layer for hybrid QNNs. It is constructed from a synthesized quantum program and an optional set of observables, and produces a trainable torch.nn.Module whose outputs are the expectation values of those observables.The new interface is designed to be more intuitive than the classic QLayer and - just as importantly - it is much faster behind the scenes, so training loops run considerably quicker.Use it when your quantum layer’s output is naturally a set of expectation values. For layers that need sampling, counts, or custom classical post-processing, keep using the classic QLayer (see Choosing between the two layers).
QLayerV2 currently runs only inside Classiq Studio and is limited to circuits of up to 26 qubits. Constructing it in any other environment, or with a larger circuit, raises an error. Extending its scale and reach is planned.
QLayerV2 is a temporary name. It ships alongside the existing QLayer (also available under the alias QLayerV1), which is unchanged for now so existing code keeps working. QLayerV2 is the interface we are moving toward: once it covers the full feature set, the classic interface will go through the standard deprecation process and QLayerV2 will become the single, canonical QLayer. That deprecation has not started yet.
QLayerV2 is imported from the same package as QLayer:
from classiq.applications.qnn import QLayerV2QLayerV2( qprog, # a synthesized QuantumProgram observables=None, # optional; defaults to one <Z_i> per qubit)
qprog - a synthesized QuantumProgram. Its parameters are classified by name: the input/i_ prefixes mark inputs (the encoded classical data) and the weight/w_ prefixes mark trainable weights (for example input_0, i_x, weight_0, w_theta). See Parameters: Inputs Versus Weights.
observables - one output feature per Pauli observable. Defaults to one <Z_i> per qubit, so the default output width equals the circuit width. Accepts a single SparsePauliOp or a sequence of them. An observable narrower than the program is padded with identities to the program’s width.
The layer trains like any other torch module. Its forward is rank-preserving: an input of shape (batch, in_features) produces (batch, out_features), and an unbatched input of shape (in_features,) produces (out_features,).
Pass one SparsePauliOp per output feature to control what the layer measures. Here the single output feature is <Z_0>:
from classiq.qmod.builtins.enums import Pauli# <Z_0>: Pauli-Z on qubit 0. Narrower observables are padded to the circuit width.z0 = Pauli.Z(0)layer = QLayerV2(qprog, observables=[z0])
QLayerV1 remains available today for sampling, counts, and custom post-processing. QLayerV2 is the interface we are building toward and will eventually become the single, canonical QLayer. Reach for QLayerV2 when you want the simplest, fastest path to an expectation-value layer.
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Classiq Docs","colors":{"primary":"#119DA4","light":"#119DA4","dark":"#252525"},"logo":{"light":"https://mintcdn.com/classiq/KOIyvRl59wygyHwT/resources/images/ClassiqLogo_black.svg?fit=max\u0026auto=format\u0026n=KOIyvRl59wygyHwT\u0026q=85\u0026s=05c70b0722c0e3ce41855332613b7165","dark":"https://mintcdn.com/classiq/KOIyvRl59wygyHwT/resources/images/ClassiqLogo_yellow.svg?fit=max\u0026auto=format\u0026n=KOIyvRl59wygyHwT\u0026q=85\u0026s=bf01ead39f6725fa4849b7c481d1dff5"},"favicon":"https://mintcdn.com/classiq/sA-J-h8chQJV9OAG/resources/images/ClassiqFavicon.png?fit=max\u0026auto=format\u0026n=sA-J-h8chQJV9OAG\u0026q=85\u0026s=752f5dcd6fdc3563c87e0697e34282b1","appearance":{"default":"dark"},"background":{"color":{"dark":"#191919"}},"footer":{"socials":{"x":"https://x.com/classiqtech","github":"https://github.com/Classiq/classiq-library","linkedin":"https://www.linkedin.com/company/classiq-technologies","youtube":"https://www.youtube.com/c/ClassiqTechnologies","slack":"https://classiq-community.slack.com"}},"seo":{"metatags":{"canonical":"https://docs.classiq.io"}},"fonts":{"heading":{"family":"Lato","weight":500,"source":"https://fonts.gstatic.com/s/lato/v25/S6u9w4BMUTPHh6UVSwiPGQ3q5d0.woff2","format":"woff2"},"body":{"family":"Lato","weight":400,"source":"https://cdn.prod.website-files.com/60000db7a5f449af5e4590ac/67bc6e7dacd49b96fe00e9af_latomedium.woff2","format":"woff2"}},"icons":{"library":"lucide"},"integrations":{"ga4":{"measurementId":"G-FG13SFNT8X"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"classiq","hasAudioNarration":false,"actualSubdomain":"classiq","customDomains":["docs.classiq.io"],"gitSource":{"type":"github","owner":"classiq-technologies","repo":"classiq-docs","deployBranch":"prod","contentDirectory":"classiq","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae3da15680150d12f272c8b","collectionId":"71143b8a-9a82-4a7c-bb58-2552b98668fc","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae3da15680150d12f272c8b"},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae3da15680150d12f272c8b","clientVersion":"0.0.4043","searchFilterCounts":[{"language":"default","tag":"Library","count":180},{"language":"default","tag":"Applications","count":88},{"language":"default","tag":"User Guide","count":64},{"language":"default","tag":"Tutorials","count":63},{"language":"default","tag":"SDK Reference","count":53},{"language":"default","tag":"Algorithms","count":46},{"language":"default","tag":"Qmod Reference","count":40},{"language":"default","tag":"Qmod","count":30},{"language":"default","tag":"Functions","count":26},{"language":"default","tag":"Execution","count":22}],"searchSettings":{"showContentSnippets":false}},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"css/page_format.css","content":"[data-md-color-scheme=default]{--md-default-fg-color:#313131;--md-default-bg-color:#ffffff;--md-primary-fg-color:#119da4;--md-accent-fg-color:#119da4;--md-primary-fg-color--light:#119da4;--md-primary-bg-color--light:#119da4;--md-accent-fg-color--light:#119da4;--md-typeset-color:#1e1e1e;--md-typeset-color--light:#1e1e1e;--md-typeset-a-color:#0c7489;--md-typeset-a-color--light:#0c7489;--md-typeset-a-color--dark:#39ccd3}[data-md-color-scheme=slate]{--md-default-bg-color:#191919;--md-primary-fg-color:#119da4;--md-accent-fg-color:#119da4;--md-typeset-a-color:#39ccd3}[data-md-color-scheme=default] .md-search__input{color:rgba(0,0,0,.87);background-color:#f5f5f5}.md-search__input+.md-search__icon{color:var(--md-default-fg-color--light)}[data-md-color-scheme=default] .md-search__input::placeholder{color:rgba(0,0,0,.54)}@media (prefers-color-scheme:dark){.md-footer .md-footer-meta,.md-header,.md-header__inner{background-color:#1e1e1e!important}.md-footer,.md-footer__inner{background-color:#393939!important}}.md-header__topic{display:none}.md-header__source{flex:1;display:flex;justify-content:space-between;max-width:none;width:auto}@media (max-width:60em){.md-header__source .md-source__repository{display:none}}.md-source__repository{max-width:100%}.doc-buttons{display:flex;justify-content:center;gap:.2rem;flex-wrap:wrap;margin:1.5em 0}"}],"page":{"pagePath":"user-guide/applications/qml/qnn/qlayerv2","slug":"/user-guide/applications/qml/qnn/qlayerv2","pageMetadata":{"title":"Simplified Quantum Layer (QLayerV2)","icon":"/icons/bulletsharp.svg","description":null,"href":"/user-guide/applications/qml/qnn/qlayerv2"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Info,Note,Table}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[_jsx(_components.code,{children:`QLayerV2`}),` is a new, simplified quantum layer for hybrid QNNs. It is constructed from a synthesized quantum program and an optional set of observables, and produces a trainable `,_jsx(_components.code,{children:`torch.nn.Module`}),` whose outputs are the expectation values of those observables.`]}),`\n`,_jsxs(_components.p,{children:[`The new interface is designed to be more intuitive than the classic `,_jsx(_components.code,{children:`QLayer`}),` and - just as importantly - it is `,_jsx(_components.strong,{children:`much faster`}),` behind the scenes, so training loops run considerably quicker.`]}),`\n`,_jsxs(_components.p,{children:[`Use it when your quantum layer’s output is naturally a set of expectation values. For layers that need sampling, counts, or custom classical post-processing, keep using the classic `,_jsx(_components.a,{href:`/user-guide/applications/qml/qnn/qlayer`,children:_jsx(_components.code,{children:`QLayer`})}),` (see `,_jsx(_components.a,{href:`#choosing-between-the-two-layers`,children:`Choosing between the two layers`}),`).`]}),`\n`,_jsx(Info,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`QLayerV2`}),` currently runs only inside `,_jsx(_components.strong,{children:`Classiq Studio`}),` and is limited to circuits of `,_jsx(_components.strong,{children:`up to 26 qubits`}),`. Constructing it in any other environment, or with a larger circuit, raises an error. Extending its scale and reach is planned.`]})}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`QLayerV2`}),` is a temporary name.`]}),` It ships alongside the existing `,_jsx(_components.code,{children:`QLayer`}),` (also available under the alias `,_jsx(_components.code,{children:`QLayerV1`}),`), which is unchanged for now so existing code keeps working. `,_jsx(_components.code,{children:`QLayerV2`}),` is the interface we are moving toward: once it covers the full feature set, the classic interface will go through the standard deprecation process and `,_jsx(_components.code,{children:`QLayerV2`}),` will become the single, canonical `,_jsx(_components.code,{children:`QLayer`}),`. That deprecation has `,_jsx(_components.strong,{children:`not`}),` started yet.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`interface`,children:`Interface`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`QLayerV2`}),` is imported from the same package as `,_jsx(_components.code,{children:`QLayer`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` classiq.applications.qnn `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` QLayerV2`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`QLayerV2(`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` qprog, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# a synthesized QuantumProgram`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` observables`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# optional; defaults to one \u003cZ_i> per qubit`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`qprog`}),` - a synthesized `,_jsx(_components.a,{href:`/user-guide/synthesis/index`,children:_jsx(_components.code,{children:`QuantumProgram`})}),`. Its parameters are classified by name: the `,_jsx(_components.code,{children:`input`}),`/`,_jsx(_components.code,{children:`i_`}),` prefixes mark `,_jsx(_components.strong,{children:`inputs`}),` (the encoded classical data) and the `,_jsx(_components.code,{children:`weight`}),`/`,_jsx(_components.code,{children:`w_`}),` prefixes mark `,_jsx(_components.strong,{children:`trainable weights`}),` (for example `,_jsx(_components.code,{children:`input_0`}),`, `,_jsx(_components.code,{children:`i_x`}),`, `,_jsx(_components.code,{children:`weight_0`}),`, `,_jsx(_components.code,{children:`w_theta`}),`). See `,_jsx(_components.a,{href:`/user-guide/applications/qml/qnn/qnn#parameters-inputs-versus-weights`,children:`Parameters: Inputs Versus Weights`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`observables`}),` - one output feature per Pauli observable. Defaults to one `,_jsx(_components.code,{children:`\u003cZ_i>`}),` per qubit, so the default output width equals the circuit width. Accepts a single `,_jsx(_components.code,{children:`SparsePauliOp`}),` or a sequence of them. An observable narrower than the program is padded with identities to the program’s width.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`The layer trains like any other `,_jsx(_components.code,{children:`torch`}),` module. Its `,_jsx(_components.code,{children:`forward`}),` is rank-preserving: an input of shape `,_jsx(_components.code,{children:`(batch, in_features)`}),` produces `,_jsx(_components.code,{children:`(batch, out_features)`}),`, and an unbatched input of shape `,_jsx(_components.code,{children:`(in_features,)`}),` produces `,_jsx(_components.code,{children:`(out_features,)`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`examples`,children:`Examples`}),`\n`,_jsx(Heading,{level:`3`,id:`minimal-example`,children:`Minimal example`}),`\n`,_jsxs(_components.p,{children:[`With only a `,_jsx(_components.code,{children:`qprog`}),`, the layer measures one `,_jsx(_components.code,{children:`\u003cZ_i>`}),` per qubit using the default observables:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`16`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` classiq `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` classiq.applications.qnn `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` QLayerV2`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@qfunc`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`input_0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: CReal, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`weight_0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: CReal, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: Output[QArray]) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` allocate(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, res)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` RY(input_0, res[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# driven by the input feature`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` RY(weight_0, res[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# trainable weight`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` CX(res[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`], res[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`])`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`qprog `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` synthesize(main)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Defaults: one \u003cZ_i> per qubit.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`layer `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` QLayerV2(qprog)`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The result is a trainable `,_jsx(_components.code,{children:`torch`}),` layer that plugs into an ordinary network:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` torch.nn `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` nn`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` MyNet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`nn`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Module`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` __init__`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` super`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`__init__`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.pre `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` nn.Linear(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`4`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.quantum `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` QLayerV2(qprog)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` forward`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`x`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` x `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.pre(x)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.quantum(x)`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`custom-observables`,children:`Custom observables`}),`\n`,_jsxs(_components.p,{children:[`Pass one `,_jsx(_components.code,{children:`SparsePauliOp`}),` per output feature to control what the layer measures. Here the single output feature is `,_jsx(_components.code,{children:`\u003cZ_0>`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` classiq.qmod.builtins.enums `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Pauli`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# \u003cZ_0>: Pauli-Z on qubit 0. Narrower observables are padded to the circuit width.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`z0 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Pauli.Z(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`layer `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` QLayerV2(qprog, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`observables`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[z0])`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`choosing-between-the-two-layers`,children:`Choosing between the two layers`}),`\n`,_jsxs(_components.p,{children:[`The classic `,_jsx(_components.a,{href:`/user-guide/applications/qml/qnn/qlayer`,children:_jsx(_components.code,{children:`QLayer`})}),` is also available under the alias `,_jsx(_components.code,{children:`QLayerV1`}),`, so the two interfaces can be named side by side during the transition.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{}),_jsxs(_components.th,{children:[_jsx(_components.a,{href:`/user-guide/applications/qml/qnn/qlayer`,children:_jsx(_components.code,{children:`QLayerV1`})}),` (alias of the classic `,_jsx(_components.code,{children:`QLayer`}),`)`]}),_jsxs(_components.th,{children:[_jsx(_components.code,{children:`QLayerV2`}),` (new)`]})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Output`}),_jsxs(_components.td,{children:[`Any tensor from a custom `,_jsx(_components.code,{children:`post_process`})]}),_jsx(_components.td,{children:`Expectation values of Pauli observables`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`You provide`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`execute`}),` and `,_jsx(_components.code,{children:`post_process`}),` callables`]}),_jsxs(_components.td,{children:[`Just `,_jsx(_components.code,{children:`qprog`}),` (and optional `,_jsx(_components.code,{children:`observables`}),`)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Measurement`}),_jsx(_components.td,{children:`Sampling derived values`}),_jsx(_components.td,{children:`Expectation values only`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Speed`}),_jsx(_components.td,{children:`Standard`}),_jsx(_components.td,{children:`Much faster`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Runs`}),_jsx(_components.td,{children:`Anywhere execution is available`}),_jsx(_components.td,{children:`Classiq Studio only, up to 26 qubits`})]})]})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`QLayerV1`}),` remains available today for sampling, counts, and custom post-processing. `,_jsx(_components.code,{children:`QLayerV2`}),` is the interface we are building toward and will eventually become the single, canonical `,_jsx(_components.code,{children:`QLayer`}),`. Reach for `,_jsx(_components.code,{children:`QLayerV2`}),` when you want the simplest, fastest path to an expectation-value layer.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Simplified Quantum Layer (QLayerV2)","icon":"/icons/bulletsharp.svg","description":null,"href":"/user-guide/applications/qml/qnn/qlayerv2"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Interface","slug":"interface","depth":2,"children":[]},{"title":"Examples","slug":"examples","depth":2,"children":[{"title":"Minimal example","slug":"minimal-example","depth":3,"children":[]},{"title":"Custom observables","slug":"custom-observables","depth":3,"children":[]}]},{"title":"Choosing between the two layers","slug":"choosing-between-the-two-layers","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/classiq/588df4baa9fe4869/javascripts/mathjax.js","/_mintlify/custom/classiq/cdc2514d6b755dcf/javascripts/remove_highlights.js","/_mintlify/custom/classiq/d98eeb06669bf6a7/javascripts/hide-home-search.js"],"subdomain":"classiq","siteName":"Classiq Docs","title":"Simplified Quantum Layer (QLayerV2) - Classiq Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-29T23:44:03.302Z","originalFileLocation":"user-guide/applications/qml/qnn/qlayerv2.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Classiq Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Simplified Quantum Layer (QLayerV2) - Classiq Docs\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Classiq Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://classiq.mintlify.app/_mintlify/api/og/v2?division=QNN\u0026amp;title=Simplified+Quantum+Layer+%28QLayerV2%29\u0026amp;theme=bbd23582554c28c640e1d63a\u0026amp;signature=0c5207e8315b2eee9981556852d841d533e6bbfbc1c14f18a2edcbaf1aa1c204\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Simplified Quantum Layer (QLayerV2) - Classiq Docs\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://classiq.mintlify.app/_mintlify/api/og/v2?division=QNN\u0026amp;title=Simplified+Quantum+Layer+%28QLayerV2%29\u0026amp;theme=bbd23582554c28c640e1d63a\u0026amp;signature=0c5207e8315b2eee9981556852d841d533e6bbfbc1c14f18a2edcbaf1aa1c204\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/classiq/Fsuml838IESUxXo8/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Classiq Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#119DA4\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/user-guide/applications/qml/qnn/qlayerv2.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.classiq.io/#organization\",\"name\":\"Classiq Docs\",\"url\":\"https://docs.classiq.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/classiq/KOIyvRl59wygyHwT/resources/images/ClassiqLogo_black.svg?fit=max\u0026auto=format\u0026n=KOIyvRl59wygyHwT\u0026q=85\u0026s=05c70b0722c0e3ce41855332613b7165\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.classiq.io#website\",\"name\":\"Classiq Docs\",\"url\":\"https://docs.classiq.io\",\"publisher\":{\"@id\":\"https://docs.classiq.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2#webpage\",\"url\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2\",\"name\":\"Simplified Quantum Layer (QLayerV2)\",\"dateModified\":\"2026-10-29T23:44:03.302Z\",\"isPartOf\":{\"@id\":\"https://docs.classiq.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Applications\",\"item\":\"https://docs.classiq.io/user-guide/applications/block-encoding/index\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"QML\",\"item\":\"https://docs.classiq.io/user-guide/applications/qml/index\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"QNN\",\"item\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/index\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Simplified Quantum Layer (QLayerV2)\",\"item\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2#article\",\"headline\":\"Simplified Quantum Layer (QLayerV2)\",\"name\":\"Simplified Quantum Layer (QLayerV2)\",\"url\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2\",\"mainEntityOfPage\":{\"@id\":\"https://docs.classiq.io/user-guide/applications/qml/qnn/qlayerv2#webpage\"},\"dateModified\":\"2026-10-29T23:44:03.302Z\",\"publisher\":{\"@id\":\"https://docs.classiq.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.classiq.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Classiq Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Classiq Docs","nav":{"global":null,"tabs":[{"tab":"Home","pages":[{"title":"Home","href":""}]},{"tab":"Getting Started","pages":[{"title":"Getting Started","href":"/getting-started"}]},{"tab":"User Guide","pages":[{"title":"User Guide","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide"},{"group":"AI","expanded":false,"pages":[{"title":"AI with Classiq","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/ai/index"},{"title":"Quantum Engineering Interface","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/ai/quantum-engineering-interface"},{"title":"Quantum Engineer Plugin","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/ai/quantum-engineer-plugin"},{"title":"AI Agent in Studio","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/ai/studio-agent"}]},{"group":"Authentication","expanded":false,"pages":[{"title":"SDK Authentication","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/authentication/sdk-authentication"},{"title":"Client Credentials (M2M) Authentication","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/authentication/m2m-authentication"}]},{"group":"Modeling","expanded":false,"pages":[{"title":"Modeling","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/modeling/index"},{"title":"Quantum Numbers and Arithmetics","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/modeling/quantum-numbers-arithmetics"},{"title":"Measurements, Observables, and Hermitian Operators","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/modeling/observables-and-operators"},{"title":"Controlled Operations","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/modeling/controlled-operations"}]},{"group":"Synthesis","expanded":false,"pages":[{"title":"Quantum Program Synthesis","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/synthesis/index"},{"title":"Quantum Program Constraints","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/synthesis/constraints"},{"title":"Getting Started with Quantum Program Synthesis","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/synthesis/getting-started"},{"title":"Hardware-Aware Synthesis","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/synthesis/hardware-aware-synthesis"},{"title":"Synthesis Preferences","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/synthesis/preferences"},{"title":"Quantum Program Transpilation","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/synthesis/quantum-program-transpilation"}]},{"group":"Execution","expanded":false,"pages":[{"group":"Execution Functions","icon":"/icons/bulletsharp.svg","expanded":false,"pages":[{"title":"Execution","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/index"},{"title":"Sample","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/sample"},{"title":"Calculate State Vector","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/calculate-state-vector"},{"title":"Observe","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/observe"}]},{"title":"Execution Session","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/ExecutionSession"},{"title":"Cost Estimation","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cost-estimation"},{"group":"Hardware Benchmarking","icon":"/icons/bulletsharp.svg","expanded":false,"pages":[{"title":"Hardware Benchmarking","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/benchmarking/index"},{"title":"Predefined Benchmarks","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/benchmarking/predefined-benchmarks"}]},{"group":"Cloud Providers","icon":"/icons/bulletsharp.svg","expanded":false,"pages":[{"title":"Supported Cloud Providers","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/index"},{"title":"Execution on Alice and Bob Quantum Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/alice-and-bob-backends"},{"title":"Execution on Amazon Braket Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/amazon-backends"},{"title":"Execution on Azure Quantum Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/azure-backends"},{"title":"Execution on C12 Quantum Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/c12"},{"title":"Execution on Classiq simulators","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/classiq-backends"},{"title":"Custom noise models on Classiq simulators","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/custom-noise-models"},{"title":"Execution on Google Cloud Platform","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/google-backends"},{"title":"Execution on IBM Quantum Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/ibm-backends"},{"title":"Execution on Intel Backends","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/intel-backends"},{"title":"Execution on IonQ Quantum Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cloud-providers/ionq-backends"}]},{"title":"CUDA-Q Integration","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/cudaq_integration"},{"title":"State Vector Filtering","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/state-vector-filtering"},{"title":"Managing Execution Budget","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/execution/budget-management"}]},{"group":"Analysis","expanded":false,"pages":[{"title":"Analysis","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/analysis/index"},{"title":"Visualization of Quantum Programs","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/analysis/visualization-of-quantum-programs"},{"title":"Data Analysis and Graphs","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/analysis/data-analysis-and-graphs"}]},{"group":"Error Correction","expanded":false,"pages":[{"title":"Fault-Tolerance Engine","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/error-correction/index"},{"group":"Logical Noise Model","icon":"/icons/bulletsharp.svg","pages":[{"title":"Custom Noise Models","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/error-correction/logical-noise"},{"title":"Publicly Available Noise Models","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/error-correction/noise-models"}]},{"title":"Route a Program","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/error-correction/routing"},{"title":"Visualize the Routed Program","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/error-correction/visualization"},{"title":"Estimate the Total Error","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/error-correction/total-error"}]},{"group":"Studio","expanded":false,"pages":[{"title":"Studio - Web-based IDE with Classiq inside","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/studio/index"},{"title":"Getting Started with Studio","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/studio/Studio-Guide"},{"title":"Getting started with git","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/studio/git-getting-started"}]},{"group":"Applications","expanded":false,"pages":[{"group":"Block Encoding","icon":"/icons/bulletsharp.svg","expanded":false,"pages":[{"title":"Block Encoding","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/block-encoding/index"},{"title":"Constructing Block Encodings","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/block-encoding/constructing-block-encodings"},{"title":"Composing and Transforming Block Encodings","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/block-encoding/composing-block-encodings"}]},{"group":"Optimization","icon":"/icons/bulletsharp.svg","expanded":false,"pages":[{"title":"Combinatorial Optimization","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/optimization/index"},{"title":"Problem Formulation","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/optimization/problem-formulation"},{"title":"Supported Modeling","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/optimization/supported-modeling"}]},{"group":"QML","icon":"/icons/bulletsharp.svg","expanded":false,"pages":[{"title":"Quantum Machine Learning","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/qml/index"},{"group":"QNN","icon":"/icons/bulletsharp.svg","expanded":false,"pages":[{"title":"Quantum Neural Networks","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/qml/qnn/index"},{"title":"A Full Example","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/qml/qnn/a-full-example"},{"title":"Datasets","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/qml/qnn/datasets"},{"title":"Quantum Layer","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","description":null,"href":"/user-guide/applications/qml/qnn/qlayer"},{"title":"Simplified Quantum Layer (QLayerV2)","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","href":"/user-guide/applications/qml/qnn/qlayerv2"},{"title":"Quantum Neural Networks (QNN)","icon":"https://mintlify.s3.us-west-1.amazonaws.com/classiq/icons/bulletsharp.svg","description":null,"href":"/user-guide/applications/qml/qnn/qnn"}]}]}]}]},{"tab":"Library","pages":[{"title":"Library","href":"/explore"}]},{"tab":"Qmod Reference","pages":[{"title":"Qmod Reference","href":"/qmod-reference"}]},{"tab":"SDK Reference","pages":[{"title":"SDK Reference","href":"/sdk-reference"}]},{"tab":"Support","pages":[{"title":"Support","href":"/support"}]},{"tab":"Release Notes","pages":[{"title":"Release Notes","href":"/release-news/recap-aug-sep-2026"}]}]},"basePath":"","title":"Simplified Quantum Layer (QLayerV2) - Classiq Docs","buildId":"dpl_G9nrg4qeJSZtah1Ziwbc2n6WkLch","deploymentId":"dpl_G9nrg4qeJSZtah1Ziwbc2n6WkLch","dynamics":[],"chunks":[]}