Medieval warfare can get ugly, particularly during sieges. Most will agree that the best course of action is to sit tight for a year or two and hope the defenders starve before your attacking force dies of illness. But sometimes that's not an option, maybe the emperor is impatient, maybe enemy reinforcements are approaching - the castle must be taken now or not at all, which leaves no option but to assault the walls.
Desigining a particular large country for my world, one I will henceforth refer to as the Empire, I have thought it appropriate that a country of such military pride and might would have a dedicated unit trained and equipped to excel in assaults on castles and fortified cities. The question is how would that unit look?
Size and purpose
Looking at the general size of Empire's army I would say the unit should be at most 4,000-5,000 men in strength (that only includes actual fighting force, the stableboys and other support personnel are outside of that count)
The primary purpose of the unit is to play the primary/major role during an assault on enemy fortifications, be it castle or walled city. By assault I mean trying to go over or through the walls, rather than wait for a surrender.
The unit is not expected to maintain a siege and perform an assault on its own - other non-specialized units will likely be present. EDIT: To clarify, the specialised unit will act as part of a larger army, but it is expected to be centerpiece/vanguard during the assault.
The unit is of course expected to fight in open field when necessary, but in this case it will likely take on a secondary/supporting role.
What are we attacking?
The fortifications in question will not be unlike your average medieval castle or walled city.
Expect one or more layer of stone walls.
There may or may not be a moat.
There may or may not be siege engines on the walls and towers.
The defenders will likely have at least one mage or wizard (more about magic below)
Available technology
In general the technology can be described as high medieval ages, with some differences. Expect enemy to have equivalent technology (we're not fighting barbarians)
No gunpowder
Steel and iron are primary metals for weapons and armor
Wide variety of armor available - from leather through mail to full plate.
Wide variety of weapons available - if it feels like it belongs in a medieval setting, there is a high chance it is available in this world
Regarding the Empire in particular: slightly inspired by Roman and Byzantine empires, the Empire has above average technological expertise in engineering and you can expect weapons and armour to be of above average quality. The roads within the empire are also well developed which may or may not matter if the unit were to include permanently assembled siege engines of sorts.
Magic
Magic exists, but it is rare and has limitations. This is war however, a matter important enough to include it. Assume 1 mage or wizard per 1,000 troops at maximum and it would be prudent to assume a similar ratio for your enemy. I will do my best to describe what can or cannot be done with magic, or - more accurately - what these mages and wizards can or cannot accomplish with it.
If you have any doubts or specific ideas requiring magic feel free to ask in the comments.
Magic is tiring - Usage of magic will gradually tire out the user. More power and complexity of the spell - more exhaustion.
Wizards and mages have the ability to electrocute, freeze, set on fire, or otherwise un-alive their enemies. A single spellcaster dedicated to that purpose can probably eliminate several hundred non-magical opponents over the course of a battle, provided he survives and has opportunity to recover his strength.
Magic can be used to shield the user and nearby allies from (non-magical) projectiles. Such a shield can be maintained for minutes up to an hour depending on intensity of fire - more kinetic energy of projectiles means less shield endurance. The shield must be actively maintained by the caster.
Magic can be used to shield the user and nearby allies from magic. Typically this kind of shielding lasts less under fire than the one above and will natrually lead to duels between mages/wizards. The duel is essentially a game of five-dimensional speed-chess and normal troops can be of great assistance by disturbing the enemy mage while not allowing your own mage to be disturbed by enemy troops.
Magic can NOT be used to blow up walls or gates.
Mages and wizard have an ability to communicate telepathetically with anyone on the battlefield, but they can only "transmit". Two magic users can establish a dialogue by using their respective skills to talk to each other, but communication with non-magic-users is one-way.
Magic can be used to a certain extent to manipualte the battlefield - dry the mud, create smoke screen, potentially clear certain obstacles (like spikes or traps)
EDIT: Answers to questions by Nosajimiki in the comments:
What is the range of magic spells? - Depends on the spell. If we're talking projectiles then most mages can compete with crossbows and longbows in terms of range. In terms of shields the question is not as much of range but of area (ties to the next question). The shorter the range of the spell the easier and less tiring it is. It is also significantly easier to conjure a fireball and propel it 100m than it is to conjure it 100m away. The mentioned telepathy can be used by ranges up to about 5 km.
Is it more exhausting to defend a larger area? - Yes. And it works int wo ways. Not only is the shield itself larger and more tiring to maintain, larger area will mean more projectiles imapcting it, which makes it even more tiring.
Do mages need line-of-sight to attack someone or can they lob spells blindly over the walls? - Line-of-sight is advisable. They can conjure a fireball and throw it over the wall like a grenade - slightly more difficult than just throwing fire into someone and there's no guarantee of hitting the target.
Can they kill more people if they are packed close together? - In most cases yes. If a spell sets 4m^2 on fire, it doesnt really matter if theres 1 or 5 people in that area.
How effective is armor at protecting against magic? - The effect is non-existent to minimal. Shields (hand-held, non-magical) can sometimes save a man, but only by merit of being a small protable wall - the shield and/or the person behind it would still need to withstand the imapct/heat/electricity. Protection is at best equal to protection from the natural element used against you, and at worst there is no protection, depending on quirks of the spell used.
And can mages detect eachother out of a crowd? - To a certain extent. Whenever a mage prepares to use a spell he draws energy, and when casting he releases it. Those fluctuations can be sensed by other mages. How accurate that detection is depends on power of used spell and distance between mages. If a mage in the city uses a rather powerful spell, a mage in siege camp can sense that "somewhere in the city". At battle ranges the mage will detect the exact direction an approximate range, and he can point a finger at the squad of people that contains the mage, even if he's not sure which of them is it. Using telepathy is slightly different - using it to "touch" a mage or someone in his immediate vicinity will reveal your exact location to him.
My thoughts so far, which you may or may not agree with
Due to its specialization, the formation will likely require little to no cavalry, with possible exception of general's bodyguard, who could benefit from mobility. On the other hand, keeping one of the mages with the general could enable him to give orders at a distance.
While longswords are the preferred weapon of kinghts, one cannot deny the usefulness of a shield when assaulting the walls. I'd think shield and one-handed weapon could be the preferred equipment of infantry of this case. Limited swing range is likely a good trade in this case.
I am uncertain how useful missile troops would be. On one hand they could harass the defenders, but on the other battlements offer a good protection from bolts and arrows.
Due to specialized nature of the unit and good engineering and ifnrastructure in the Empire the unit could potentially have a couple of "permanent" siege engines. A siege tower with iron or steel armor could certainly be useful, but I can't quite convince myself about practicality of pulling it along whenever the unit goes anywhere.
Measure of success
To summarize, the question is: what would be the composition, equipment and tactics of a specialized unit for castle assault within the constraints presented?
The unit is meant to perform well enough that it somewhat "legendary", though these legends are of course overblown. It is, however, supposed to be rather effective at its intended purpose, ideally not suffering ridiculous losses in the process or bankrupting the Empire with the demanded equipment.