If you have a Tier 4 student visa you can only stay in the UK if your visa is still valid on the date of your graduation ceremony. It‘s not possible to extend your Tier 4 visa for the purpose of attending your graduation ceremony. If your Tier 4 visa expires you’ll have to return home and apply for a visitor visa; applications for this must be made online here.
If you have transferred into another immigration category such as Tier 2 (Skilled worker) you may remain in the UK and attend your graduation ceremony as long as your visa is valid. For more information about what you need to do before returning for graduation, please visit our Graduation pages.