Skip to content

lifecycle tutorial#782

Open
nathandelcid wants to merge 1 commit into
QuEST-Kit:develfrom
nathandelcid:devel
Open

lifecycle tutorial#782
nathandelcid wants to merge 1 commit into
QuEST-Kit:develfrom
nathandelcid:devel

Conversation

@nathandelcid
Copy link
Copy Markdown

Added a simple tutorial showing a lightweight entry-point example for new users who want to see the standard QuEST workflow in one small file before exploring more advanced examples.

i.e., examples/tutorials/min_lifecycle_example.c shows the basic flow of a small QuEST simulation:

  • initialize the QuEST environment
  • create a Qureg
  • initialize the register state
  • apply a couple of simple operations
  • report the state
  • clean up the register and environment

Kept this intentionally minimal and with elaborate comments, did not modify the existing CMake configuration. If preferred, I can follow up by wiring this into the examples build system.

@TysonRayJones
Copy link
Copy Markdown
Member

Hi Nathan,

More examples is always more better, thanks very much for this! 🎉 However, doesn't it only meaningfully differ from the existing min_example.c by only these two lines?

    applyHadamard(qureg, 0);
    applyPauliX(qureg, 1);

@nathandelcid
Copy link
Copy Markdown
Author

The main contribution would be the comments. Maybe I can consolidate with min_example.c?

@TysonRayJones
Copy link
Copy Markdown
Member

That sounds better, but I note that I usually shy from redundant comments, like

// Initialise QuEST
initQuESTEnv();

// Create a qureg
Qureg qureg = createQureg(25);

// Apply some operators
applyHadamard(qureg);

// Finalise the QuEST environment.
finalizeQuESTEnv();

Such comments are just visual noise when the API function describes precisely what is happening. I much prefer "why" comments, which explain the broader context, as you can see a nice example of here. Replacing the comments with just the maths doesn't seem worthwhile - it's not a HPC simulator example's job to teach the reader what the Hadamard gate does!

I think min_example.c as exists shows the user flow fine. A longer, more meaningful example (e.g. QuEST simulating some canonical quantum algorithm) might be more worthwhile!

@nathandelcid
Copy link
Copy Markdown
Author

Right right. I mainly did it for myself whilst reading the preprint to translate notation into code. Let me dig a little deeper and see if I can cook something up.

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

Successfully merging this pull request may close these issues.

2 participants